示例#1
0
 private void GenerateWaveButton_Click(object sender, EventArgs e)
 {
     using (WaveGenerator waveGenerator = new WaveGenerator())
     {
         //waveGenerator.Save("D:\\debugTest.wav");
         waveGenerator.GenerateSoundStream();
         waveGenerator.Play();
     }
 }
示例#2
0
 public static void Play(short[] soundData)
 {
     using (WaveGenerator waveGenerator = new WaveGenerator(soundData))
     {
         //waveGenerator.Save("D:\\debugTest.wav");
         waveGenerator.GenerateSoundStream();
         waveGenerator.Play();
     }
 }
示例#3
0
        public static StereoWaveBuffer GenerateDefaultStereoWaveBuffer(float seconds)
        {
            int samples = (int)(seconds * samplesPerSecond);

            short[]       emptyBuffer   = new short[samples * 2];
            WaveGenerator waveGenerator = new WaveGenerator(emptyBuffer);
            MemoryStream  stream        = waveGenerator.GenerateSoundStream();

            byte[] array         = stream.ToArray();
            int    bufferLength  = samples * 4;
            int    startPosition = array.Length - bufferLength;

            return(new StereoWaveBuffer(array, samplesPerSecond, startPosition, samples, seconds));
        }