public class Sound
{
private DirectSound.Buffer Buffer = null;
public Sound( long Location, BinaryReader Reader, DirectSound.Device DirectSound_Device )
{
int Frequency = 0;
int Samples = 0;
long OldPosition = Reader.BaseStream.Position;
Reader.BaseStream.Position = Location;
Reader.ReadInt16();
requency = Reader.ReadInt16();
Samples = Reader.ReadInt16();
Reader.ReadInt16();
DirectSound.BufferDescription Description = new DirectSound.BufferDescription();
Description.BufferBytes = Samples;
Description.ControlFrequency = true;
Description.GlobalFocus = true;
Buffer = new DirectSound.Buffer( Reader.BaseStream, Samples, DirectSound_Device );
//Buffer.Frequency = Frequency;
Reader.BaseStream.Position = OldPosition;
return;
}
~Sound()
{
return;
}
public void Play()
{
Buffer.Play( 0, DirectSound.BufferPlayFlags.Default );
return;
}
}
Managed DirectSound, problems creating Buffer
I'm trying to load raw 8-bit 11025Hz samples from a binary file. Right now though I can't seem to even create a damn buffer. Here's the code:
On the buffer creation line, I get "Exception System.ArgumentException -
Value does not fall within the expected range.".
The stream is open and the device isn't null, so why is it saying the values are wrong?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement