private void GenerateWaveButton_Click(object sender, EventArgs e) { using (WaveGenerator waveGenerator = new WaveGenerator()) { //waveGenerator.Save("D:\\debugTest.wav"); waveGenerator.GenerateSoundStream(); waveGenerator.Play(); } }
public static void Play(short[] soundData) { using (WaveGenerator waveGenerator = new WaveGenerator(soundData)) { //waveGenerator.Save("D:\\debugTest.wav"); waveGenerator.GenerateSoundStream(); waveGenerator.Play(); } }
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)); }