Jump to content
  • Advertisement
Sign in to follow this  
ventuz_ks

[SlimDX] How to initialize SecondarySoundBuffer?

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

Hi! I can't manage to initialize a SecondarySoundBuffer in SlimDX. I'm trying to do it like this:
    using DSound = SlimDX.DirectSound;

    public class Sound
    {
        DSound.DirectSound parent = null;
        DSound.SoundBufferDescription description;
        DSound.SecondarySoundBuffer secBuffer = null;

        public Sound(System.Windows.Forms.Form appForm, Guid driverID)
        {
            this.parent = DSoundDeviceManager.GetDevice(driverID, appForm);
            this.description = new DSound.SoundBufferDescription();

            if ( this.parent != null )
            {
                try
                {
                    this.description.Flags =
                        DSound.BufferFlags.ControlVolume |
                        DSound.BufferFlags.ControlPan |
                        DSound.BufferFlags.GlobalFocus;

                    // read in the WAVE file
                    byte[] data;

                    using ( SlimDX.Multimedia.WaveFile file = new SlimDX.Multimedia.WaveFile(@"H:\AudioMono.wav") )
                    {
                        this.description.Format = file.Format;
                        data = new byte[file.Size];
                        file.Read(data, file.Size);
                    }

                    // create new 
                    this.secBuffer = new DSound.SecondarySoundBuffer(this.parent, this.description);
                }
                catch ( Exception ex )
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
    }

I always get an exception: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809) Can't find any examples how to do it correctly. Thank you in advance Karol

Share this post


Link to post
Share on other sites
Advertisement
And what does your wave format look like? How many channels, what format tag, what sample rate, etc.

Quote:
Original post by Mike.Popoloski
Do the debug runtimes give you any extra information?
Linky

Share this post


Link to post
Share on other sites
Hi guys!

Sorry, forgot to mention that:
Debug Runtime gives no further information.
Using the November SlimDX version.

The format of the 'AudioMono.wav' is:
AverageBytesPerSecond: 22050
BitsPerSample: 8
BlockAlignement: 1
Channels: 1
FormatTag: Pcm
SamplesPerSecond: 22050

Tried it with the 'MusicMono.wav' from the SlimDX sample as well - same problems!
Is it currently possible to replace the DirectSound functionality with XAudio2?

Share this post


Link to post
Share on other sites
DirectSound should we usable, just like XAudio2. My only guess right now is that for some reason the flags you are specifying are invalid. I'll try it out on my own to see what I come up with.

Share this post


Link to post
Share on other sites
Solved!

Found the problem:
I did not set the SizeInBytes property in the SoundBufferDescription structure.

Thanks for the quick replies anyhow

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!