Jump to content

  • Log In with Google      Sign In   
  • Create Account

SlimDX Sound Problem (I am very desperate ;( )


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 SharinganShuriken   Members   -  Reputation: 95

Like
0Likes
Like

Posted 05 May 2013 - 07:41 PM

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



Sponsor:

#2 SharinganShuriken   Members   -  Reputation: 95

Like
0Likes
Like

Posted 07 May 2013 - 03:53 PM

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



#3 lwm   Members   -  Reputation: 1420

Like
1Likes
Like

Posted 08 May 2013 - 02:15 AM

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 %


current project: Roa





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS