At the moment, I managed to separate the left and right channels of the WAVE file and include the header in the byte [] array. The next step will play both channels. How can this be done?
Here is the code snippet:
byte[] song_left = new byte[fa.Length];
byte[] song_right = new byte[fa.Length];
int p = 0;
for (int c = 0; c < 43; c++)
{
song_left[p] = header[c];
p++;
}
int q = 0;
for (s = startByte; s < length; s = s + 3)
{
song_left[s] = sLeft[q];
q++;
s++;
song_left[s] = sLeft[q];
q++;
}
p = 0;
for (int c = 0; c < 43; c++)
{
song_right[p] = header[c];
p++;
}
This part reads the header and data from both the right and light channels and stores them in the sLeft [] and sRight [] array. This part works just fine.
As soon as I got the byte arrays, I did the following:
System.IO.File.WriteAllBytes("c:\\left.wav", song_left);
System.IO.File.WriteAllBytes("c:\\right.wav", song_right);
Added button to play the saved wave file:
private void button2_Click(object sender, EventArgs e)
{
spWave = new SoundPlayer("c:\\left.wav");
spWave.Play();
}
As soon as I pressed the play button, this error appears:
An unhandled exception of type 'System.InvalidOperationException' occurred in System.dll
Additional Information: The wave header is damaged.
Any ideas?