Jump to content
  • Advertisement
Sign in to follow this  
Jiia

DirectSound sucks?

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

I probably suck, not the API. But I cannot get the volume control to work, there are pops and cracks as the sound starts, and panning seems all screwed up. I just switched from using FMod, but I'm not using 3D sound. Just calculating the pan and volume relative to the camera to do my own type of 3D effect. The problem with the volume is that 0 decibels is extremely loud and -500 decibels is much more quiet. Yet the docs say silence is at -10000? Do I need to make my own silence at a much higher level, or is it more likely that I'm doing something wrong? I've always used a percentage of volume - a float from 0 to 1 representing percentage. And that was multiplied with 255 to send FMod the value. Now I changed that to (1 - volume) * -10000 to send DirectSound the value. I can barely hear the sounds unless they play at 1.0 volume. Any advice on this? As for panning, DirectSound seems to impliment panning in a different way than FMod. Specifically, it seems to put full volume into both speakers when the sound is centered. I'm not a sound expert, but shouldn't the volume be normalized between the speakers? Is there an option for this somewhere, or do I need to modify the volume any time I mess with panning? Then the pops and cracks. I'm hoping this is a side effect from the other problems. Maybe the sound is just too loud at 100% volume in both speakers? All of the buffer formats match, and the popping is present with no panning or frequency changes. Thanks much for help edit: Does this look correct?
FLOAT pan_change = 1.0f - positive( Panning );
FLOAT vol_perc = 1.0f / sqrtf( 1.0f + (pan_change * pan_change) );
Volume *= vol_perc;
Volume is 0 to 1. Panning is -1 to +1 [Edited by - Jiia on March 26, 2005 10:17:18 PM]

Share this post


Link to post
Share on other sites
Advertisement
Read the official DirectSound API reference documentation that comes with the SDK. It explains how volume and panning work in DirectSound. (Try looking up the sound buffer interface and then getting a link from that to the SetVolume() and SetPan() methods or whatever they're called.) I haven't used FMod, but if I understand your description of how FMod handles volume and panning, then yes, DirectSound handles it very differently. Personally I don't like the way DirectSound handles it, but you can process your input for the SetVolume() and SetPan() functions so that it behaves more logically without too much trouble.

Share this post


Link to post
Share on other sites
Quote:
Original post by mumpo
Read the official DirectSound API reference documentation that comes with the SDK. It explains how volume and panning work in DirectSound.

Like I said, I'm not a sound expert. But why isn't -5000 decibals 50% volume? I would say it's more like 15% or less?

Quote:
Original post by mumpo
(Try looking up the sound buffer interface and then getting a link from that to the SetVolume() and SetPan() methods or whatever they're called.)

No offense, but isn't it obvious from my original post that I've already found these?

Quote:
Original post by mumpo
I haven't used FMod, but if I understand your description of how FMod handles volume and panning, then yes, DirectSound handles it very differently. Personally I don't like the way DirectSound handles it, but you can process your input for the SetVolume() and SetPan() functions so that it behaves more logically without too much trouble.

This is the area I need help with. Processing my input. I want volume control to be percentage of volume. The DirectSound docs say -10000 is silence, and 0 is original volume. But if this were linear changes, -5000 would be 50% volume, and it's not even close. So how do I "process my input" to calculate 50% volume?

Thanks for your help

Share this post


Link to post
Share on other sites
I just found this link on this issue. It's in VB, but still give it a try:

Quote:
DsBuffer.SetVolume 5000 '50% volume


So try just using +5000. There are also examples of values and such for panning, position, pitch, and volume. See if that helps any. Oh and you will have to go to the "DirectSound: Modifying Sounds" section of that link, I just realized it's quite large [lol].

Share this post


Link to post
Share on other sites
Huh? But that doesn't even make sense. It must be a typo.

My guess (that's if MS isn't just crazy) is that decibels have some special range of values that need translated to make them linear. Does anyone know if this is true? I'll keep searching.

Thanks again

Share this post


Link to post
Share on other sites
Did you try using a positive 5000 and seeing if it worked though? I've never worked with DS before but I have an example from a book I will look at to see how they did it. Ok I am sending you a PM [lol] this is werid - stupid VB examples...

Share this post


Link to post
Share on other sites
Yeah, I tried it, but only because I'm desperate [smile]

It played at full volume.

Share this post


Link to post
Share on other sites
This is what I did, I really haven't tested it though.


bool cSoundBuffer::SetVolume(short percent)
{
long Volume;

if(m_buffer == NULL)
return false;

if(!percent)
Volume = DSBVOLUME_MIN;
else
Volume = -20 * (100 - (percent % 101));

if(FAILED(m_buffer->SetVolume(Volume)))
return false;

return true;
};

bool cSoundBuffer::SetPan(signed long level)
{
signed long Pan;

if(m_buffer == NULL)
return false;

if(level < 0)
Pan = DSBPAN_LEFT / 100 * ((-level) % 101);
else
Pan = DSBPAN_RIGHT / 100 * (level % 101);

if(FAILED(m_buffer->SetPan(Pan)))
return false;

return true;
};


Share this post


Link to post
Share on other sites
Sound professionals measure sound in decibels (dB) and that's why DirectSound uses hundreths of decibels as the units. They are NOT linear like the method in FMOD. An attenuation of -3 dB (i.e. -300 DirectSound units) should be percieved as about half the full volume, since log 3 is approximately 1/2. The negative sign is there to indicate that the value is an attenuation and not an amplification. To the normal human, the sound will be inaudible long before the -100 dB point.

Share this post


Link to post
Share on other sites
Ahhh, this is the information I need, except in a more variable form. Any idea how to convert a percentage into decibels or vice versa?

Thanks for your time.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!