Sign in to follow this  

C# Directsound help

Recommended Posts

"Index was outside the bounds of the array." Exception is thrown when trying to create a new DirectSound.SecondaryBuffer
                DataStream = new System.IO.MemoryStream();
                for (int i = 0; i < 1000; i++)
                    double dub = Math.Sin(i / 1000.0f);
                    byte data = (byte)(dub*255);
                this.ClientSize = new System.Drawing.Size(640, 480);
                SoundDev = new Microsoft.DirectX.DirectSound.Device(); 
                SoundDev.SetCooperativeLevel(this, DirectSound.CooperativeLevel.Priority);
                DirectSound.BufferDescription desc = new Microsoft.DirectX.DirectSound.BufferDescription();
                desc.BufferBytes = 1000;
                SoundBuf = new Microsoft.DirectX.DirectSound.SecondaryBuffer(DataStream, desc, SoundDev);//exception thrown

[Edited by - Grain on January 18, 2009 5:32:09 PM]

Share this post

Link to post
Share on other sites
I figured out that if I add DataStream.Position = 0; before passing it to SecondaryBuffer's constructor I get a different exception: "Value does not fall within the expected range."

Share this post

Link to post
Share on other sites

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