Jump to content
  • Advertisement
Sign in to follow this  
Grain

C# Directsound help

This topic is 3534 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

"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);
                    DataStream.WriteByte(data);
                }
                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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!