private void button2_Click(object sender, EventArgs e) { //Stopwatch sw = new Stopwatch(); //sw.Start(); //获取声调名称 int toneindex = listBox1.SelectedIndex; if (toneindex < 0) { return; } string tonename = sounds[toneindex].name; double pitch = sounds[toneindex].pitch; pitch = SemitoneTransfer.getTN(pitch); //获取声调包络 int pit = int.Parse(numericUpDown1.Value.ToString()); var pitdata = getZipDatas(pit); //获取长度比例 int len = int.Parse(numericUpDown2.Value.ToString()); //初始化音调信息 //NNTone tmp = sounds[toneindex]; //int begin = tmp.begin; //int length = tmp.length; //int head = tmp.inibegin; //int foot = tmp.tailbegin; //double rbegin = double.Parse(textBox7.Text); //double rend = double.Parse(textBox8.Text); //合成 SynTone synt = new SynTone(tonename, pitdata, len, new double[] { 1 }, 0, pitch); int[] res = sa.getSoundTone(synt); this.pictureBox2.Image = getPPImage(res); //this.pictureBox4.Image = getFFTImage(res); //sw.Stop(); //sw = new Stopwatch(); //sw.Start(); WAVControl.writeWAV(res, outputTone); //播放合成结果wav System.Media.SoundPlayer player = new System.Media.SoundPlayer(outputTone); player.PlaySync(); //sw.Stop(); //double tbegin = double.Parse(textBox5.Text); //double tend = double.Parse(textBox6.Text); //pictureBox2.Image = getImage(outputTone, tbegin, tend); //pictureBox4.Image = getFFTImage(SoundAnalysis.getSample(outputTone)); }
public void showSoundInfo(int n) { var data = sa.tl.getTone(sounds[n].name); WAVControl.writeWAV(data, outputOri); System.Media.SoundPlayer player = new System.Media.SoundPlayer(outputOri); player.Play(); //WAVControl.writeWAV(SoundAnalysis.getSampleByte(SoundAnalysis.getSample(outputOri)), output); //System.Media.SoundPlayer player2 = new System.Media.SoundPlayer(output); //player2.PlaySync(); //double tbegin = double.Parse(textBox5.Text); //double tend = double.Parse(textBox6.Text); pictureBox1.Image = getPPImage(data); pictureBox3.Image = getFFTImage(data); pictureBox4.Image = getDFFTImage(data, 0, 1000, 1); }