/// <summary>
        /// int[] => file
        /// </summary>
        /// <param name="newdata"></param>
        /// <param name="savepath"></param>
        public static void writeWAV(int[] newdata, string savepath = null)
        {
            byte[] data = WAVControl.getSampleByte(newdata);
            writeWAV(data, savepath);

            //int length = data.Length;
            //if (string.IsNullOrWhiteSpace(savepath)) savepath = @"tmp_tone.wav";
            //using (FileStream fs = new FileStream(savepath, FileMode.Create))
            //{
            //    using (BinaryWriter sw = new BinaryWriter(fs, Encoding.GetEncoding(1252)))
            //    {
            //        sw.Write("RIFF".ToCharArray());
            //        sw.Write((uint)(length + 44));
            //        sw.Write("WAVEfmt ".ToCharArray());
            //        sw.Write((uint)16);
            //        //编码格式
            //        sw.Write((UInt16)1);
            //        //声道
            //        sw.Write((UInt16)1);
            //        //采样率
            //        sw.Write((uint)44100);
            //        //采样频率
            //        sw.Write((uint)88200);
            //        //每个采样对应的字节数
            //        sw.Write((UInt16)byteSample);
            //        //采样大小
            //        sw.Write((UInt16)16);
            //        sw.Write("data".ToCharArray());
            //        sw.Write((uint)length);
            //        sw.Write(data);
            //    }
            //}
        }
Beispiel #2
0
 public void writeWAV(int[] wavdata, string filename = null)
 {
     if (filename == null)
     {
         filename = outputTone;
     }
     WAVControl.writeWAV(wavdata, filename);
 }
Beispiel #3
0
 public int[] getTone(string name)
 {
     if (this.sunit.ContainsKey(name))
     {
         return(WAVControl.getSample(oridata, sunit[name].begin, sunit[name].length));
     }
     return(new int[] { });
 }