Hi, I have to design a program that plays sounds (from WAV files). I have to create a wav and play it. Once it finishes I have to change the contents of that wave file and play it again. It is like playing a wave file that is constantly changing. I thought of creating a stream but the problem is when i edit that stream (using ms.Postion and ms.WriteByte), an error occurs saying that "the wave header file is corrupt". The following is my code:
MemoryStream ms = new MemoryStream(Sample1);
SoundPlayer myPlayer = new SoundPlayer(ms);
myPlayer.Play(); //Wav file plays
for (int x = 0; x < 50; x++)
{
ms.Position = 44 + x;
ms.WriteByte(10);
}
myPlayer.Stop();
myPlayer.Play(); //Header file corrupt
Is there maybe another way I can loop a stream, and change its contents while it is looping. For example, the stream is looping Sound1 and whenever a button is pressed, the stream's content is changed to play Sound2.
Thank you!