Jump to content
  • Advertisement
Sign in to follow this  
andy176822

Direct Sound help

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

hey guys, I need some help with Direct Sound. I have a 27 second looping sound that I am using for a vehicles engine. When the vehicle increases speed I increase the frequency of the sound effect. The problem is this, the sound frequency changes and sounds good. But the sound effect will end quicker then at the standard frequency. This would be fine but when doind an infinite loop it waits 27 seconds before restarting the sound clip. This means that there is a silence when the sound effect is played at a high frequency. code below: setup: engineSound = WDWSound::getSound(eS); engineSound->SetRepeats(DMUS_SEG_REPEAT_INFINITE); engineSound->Get3DBuffer()->SetMinDistance(10.0f,DS3D_IMMEDIATE); engineSound->Get3DBuffer()->SetMaxDistance(100.0f,DS3D_IMMEDIATE); frequency = engineSound->getFrequency(); every frame: engineSound->setFrequency(normal_frequency + (velocity*1000)); can anyone offer a solution. Thanks Andy

Share this post


Link to post
Share on other sites
Advertisement
Hello
The reason is when you are using the SetFrequency( .. ) not only the pitch(frequency) of the sound that is changed, but it also make the sound play faster (the tempo ). Therfore the sample may be shorter or longer when changeing the frequency. This is because of the nature of a wave sound. It's possible to use timestretching techniques (keeping the tempo of the sample ) to avoid this.

- BJF

Share this post


Link to post
Share on other sites
What you want to look into is Fast Fourier Transforms.

Alternatively, just increase the frequency and hence reduce the length, and instead of waiting for 27 seconds, wait for the sound to end. That'll be better for if you ever change the engine noise too. You could use GetCurrentPosition for that, and compare that to the size of the buffer. If you're streaming the sound (which you probably should be for a 27 second sample), it gets a bit more tricky, but you can keep track of how many times you fill the buffer, and work out how far through the sample you are from that.

Slightly offtopic - isn't 27 seconds a bit long for just a looping engine noise?

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!