Sign in to follow this  
SharinganShuriken

SlimDX Sound Problem (I am very desperate ;( )

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

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
lwm    2518

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

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