Jump to content
  • Advertisement
Sign in to follow this  

C# Directsound help

This topic is 3619 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);
                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
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!