Sign in to follow this  

Managed DirectSound, problems creating Buffer

This topic is 4260 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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:
	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;
		}
        
	}

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?

Share this post


Link to post
Share on other sites

This topic is 4260 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this