/// <summary>
        /// 从UTAU音源文件夹获取音源数据
        /// 没有pitch
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static Bank getToneList(string path)
        {
            Bank tlist = new Bank(new byte[] { });

            List <byte> alldata = new List <byte>();

            string[] filelist = getSoundList(path);

            foreach (var file in filelist)
            {
                byte[] tmpdata = WAVControl.getSampleByte(WAVControl.getSample(file));
                int    begin   = alldata.Count;
                int    length  = tmpdata.Length;
                string name    = getSoundName(file);
                foreach (var t in tmpdata)
                {
                    alldata.Add(t);
                }
                tlist.sunit[name] = new Syllable(begin, length, 66);
            }

            tlist.oridata = alldata.ToArray();

            return(tlist);
        }
示例#2
0
        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));
        }
示例#3
0
 private void button10_Click(object sender, EventArgs e)
 {
     try
     {
         string path = textBox1.Text;
         int[]  data = WAVControl.getSample(path);
         pictureBox1.Image    = getPPImage(data);
         pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
         pictureBox2.Image    = getFFTImage(data);
     }
     catch
     {
     }
 }
示例#4
0
        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);
        }