Jump to content
  • Advertisement
Sign in to follow this  
SharinganShuriken

SlimDX Sound Problem (I am very desperate ;( )

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

Hello Community,

 

i looking for, i have forget how many hours it was, i know only that my finger really hurts because of the type of my keyboard to search on Google sad.png

 

I want to create in SlimDX a 3D Sound, so first i have looking for, how i load a Wavefile and i have found this example:

 

        public PlaySound(IntPtr handle, string fileName)
        {
            DirectSound device = new DirectSound();
            device.SetCooperativeLevel(handle, CooperativeLevel.Priority);
            device.IsDefaultPool = false;

            SoundBuffer buffer;

            // Load wave file
            using (WaveStream waveFile = new WaveStream(fileName))
            {
                SoundBufferDescription description = new SoundBufferDescription();
                description.Format = waveFile.Format;
                description.SizeInBytes = (int)waveFile.Length;
                description.Flags = BufferFlags.ControlVolume;

                // Create the buffer.
                buffer = new SecondarySoundBuffer(device, description);

                byte[] data = new byte[description.SizeInBytes];
                waveFile.Read(data, 0, (int)waveFile.Length);
                buffer.Write(data, 0, LockFlags.None);

            }

 

            buffer.Volume = 50;
            buffer.Play(0, PlayFlags.Looping);
        }

 

So now i want to change the Soundvolume but everytime if i try to set the buffer.volume, than i get a DirectSoundException:

E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)

 

I have really really no idea whats wrong sad.png

 

i have try to looking for another example how to load/play a Wavefile with SlimDX but with no success ;(

 

Can you Guys help me ?

 

Greets

SharinganShuriken

Share this post


Link to post
Share on other sites
Advertisement

I have figure out it :D

 

I dont know why but the Volume can only be 0 or a negative value until -10000, where 0 = Volume 100 and -10000 = Volume 0,

just stupid, i know but it's so xD

 

And the Pan Value is the way so, it can be have negative and positive values, both until 10000 where 10000 is only the right Soundbox

and -10000 only the left Soundbox and 0 both Soundboxes xD

 

To get really right results, you must go in both cases in 100 steps.

 

How complicated, i know, but it exist only one truth and i find it :D

 

Greets SharinganShuriken

Share this post


Link to post
Share on other sites

I dont know why but the Volume can only be 0 or a negative value until -10000, where 0 = Volume 100 and -10000 = Volume 0,
just stupid, i know but it's so xD

 

That's because the volume property is really the attenuation, in hundredths of a decibel (dB). 

0 -> 0 dB -> 100%

-300 -> -3 dB -> 50%

-600 -> -6 dB -> 25%

-10000 -> 100 dB -> 10^-8 %

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!