I am struggling to find answers for how I should go about storing DSP pointers in memory (C++)
Given the following scenario:
10 characters stand in a room, talking, all with different voice pitch settings. Some have low-pitched voices, others have high-pitched voices.
1.) Do I need to create a new DSP unit each time a character plays a sound, OR can I create a single DSP unit and share it among the 10 characters?
2.) With the above scenario, do I need to free DSP units after every sound finishes playing?
- SCSniper asked 7 years ago
Yes, I am currently using setFrequency() to change pitch, but I wanted to use a DSP effect instead to avoid the problem with the sample length changing as you described.
[code:1ray8cvb]pChannel->getFrequency( ¤t_frequency );
final_frequency = (current_frequency * (desired_pitch/100.0f));
pChannel->setFrequency( final_frequency );[/code:1ray8cvb]
The game allows for every character to have a unique voice pitch, so I’m somewhat forced here. Though most sounds don’t have pitch shifting, a lot of sounds in the game are pitch shifted via code. There could arise a situation where more than 10 sounds are pitch shifted at a given time.
I imagine there must be many games out there that have this scenario. In particular, Valve Software’s Half-Life uses on the effect throughout their entire code base for every sound created.
Is there anything I can do to optimize for this situation?
Most games do not use a pitchshift DSP at all, they just use setFrequency/setPitch method and do not compensate for change in legnth. The only types of games that I know of that use pitchshift DSPs are music games where it is important that the timing is accurate.
If you need a large amount of pitch variation and you don’t want the sounds to get very short or very long then you should bake the pitchshift into multiple files, for example:
Then you can still use setFrequency for minor variations in pitch, giving you a good range of pitch without having excessively short/long sounds and without having to use an expensive PitchShift DSP.
[quote:15xul3uh]1.) Do I need to create a new DSP unit each time a character plays a sound, OR can I create a single DSP unit and share it among the 10 characters?[/quote:15xul3uh]
You will need one DSP for each sound that plays at the same time. That is assuming you are using the PitchShift DSP, if you are using the setPitch property you don’t need any DSPs at all, but the speed of playback will be changed.
[quote:15xul3uh]2.) With the above scenario, do I need to free DSP units after every sound finishes playing?[/quote:15xul3uh]
You don’t have to free them, you can reuse them on other sounds if you like.
[quote:15xul3uh]10 characters stand in a room, talking, all with different voice pitch settings. Some have low-pitched voices, others have high-pitched voices.[/quote:15xul3uh]
Pitch shift is a very expensive DSP effect, running 10 at once could affect the performance of your game. If it’s possible I would reccomend baking in the pitch changes into multiple source files, then using the pitch property for minor variations rather than using a PitchShift DSP.
Please login first to submit.