public NotePainter(Canvas canvas, int width, int height, UtauBat bat) { this.canvas = canvas; this.width = width; this.height = height; this.bat = bat; this.initNote(); }
public Resampler(UtauBat bat, Form1 form) { this.bat = bat; this.mainForm = form; Utils.log(this.tempWaveName + "," + form.config.realtimeSynth.ToString()); if (bat.settings["output"] == this.tempWaveName && form.config.realtimeSynth) { Utils.log("Realtime Synth"); try { this.realtimeSynth = true; this.streamPlayer = new StreamPlayer(); } catch (Exception e) { Utils.log("error: " + string.Format("{0}, {1}", e.Message, e.StackTrace)); } Utils.log("Wav Length: " + this.bat.length.ToString()); Utils.generateWhiteWave(this.bat.length / 1000, this.tempWaveName); } if (form.config.resamplerMode == "dll") { this.useResamplerDll = true; /*this.resamplerDll = new EngineBridge(form.config.resampler, "resampler"); * this.ResamplerEvent = this.resamplerDll.call;*/ } else { this.resamplerPath = form.config.resampler; this.ResamplerEvent = this.resampler; } this.wavtoolPath = form.config.wavtool; if (!useResamplerDll && !File.Exists(this.resamplerPath)) { throw new FileNotFoundException(this.resamplerPath); } if (!File.Exists(this.wavtoolPath)) { throw new FileNotFoundException(this.wavtoolPath); } }
private void Form1_Load(object sender, EventArgs e) { this.Text = Global.lang.fetch("正在合成……"); label1.Text = Global.lang.fetch("合成进度:"); label2.Text = Global.lang.fetch("拼接进度:"); labelStatus.Text = Global.lang.fetch("加载中……"); Control.CheckForIllegalCrossThreadCalls = false; #if DEBUG //System.Environment.CurrentDirectory = @"C:\Users\Administrator\AppData\Local\Temp\utau1"; #endif string batFile = System.Environment.CurrentDirectory + "\\temp.bat"; if (!Global.config.showConsole) { Utils.hideBat(); } if (File.Exists(batFile)) { labelStatus.Text = Global.lang.fetch("正在解析数据……"); try { NoteList noteList = new NoteList(); UtauBat bat = new UtauBat(batFile); //this.painter = new NotePainter(noteCanvas.CreateGraphics(), noteCanvas.Width, noteCanvas.Height, bat); Resampler resampler = new Resampler(bat, this); Thread thread = new Thread(new ThreadStart(resampler.synthetise)); thread.Start(); } catch (FileNotFoundException fe) { MessageBox.Show(string.Format("{0}{1}", lang.fetch("文件不存在:"), fe.Message), lang.fetch("错误"), MessageBoxButtons.OK, MessageBoxIcon.Error); this.SafeClose(); } catch (Exception ex) { Utils.log("error: " + string.Format("{0}, {1}", ex.Message, ex.StackTrace)); MessageBox.Show(string.Format("{0}, {1}", ex.Message, ex.StackTrace)); } } else { MessageBox.Show(Global.lang.fetch("请在UTAU中调用!"), Global.lang.fetch("错误"), MessageBoxButtons.OK, MessageBoxIcon.Error); this.SafeClose(); } }