I need to change the speed of a short wav file that is played in a loop without changing the pitch. As I understand, one has to do this by using FMOD_Channel_SetFrequency in combination with FMOD_DSP_PITCHSHIFT. The problem is, however, that I have a hard time to find out how to use the latter, as I neither find any examples in the example programs. Could anybody be so kind to show me how to do this in practice. How to set up the FMOD_DSP_PITCHSHIFT function. I am programming in C.
Thanks in advance.
- Varun asked 6 years ago
Looking more in the forum, I found the example I had been searching for. I’ve copied it in case others will be looking for the same:
// Create the DSP effect.
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_PITCHSHIFT, &myDSP);
// Then you need to set the pitch
result = FMOD_DSP_SetParameter(myDSP,0,2);
// Then play the sound in the channel
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, true, &channel);
// Then apply the DSP effect to the channel
result = FMOD_Channel_AddDSP(channel, myDSP,0);
The pitch is set to 2, which means one octave higher. The default is 1, which is no change, while 0.5 gives one octave lower etc.
I managed to make FMOD_DSP_PITCHSHIFT work with FMOD_ChannelGroup_SetPitch to change the speed of a sound sequence without changing the pitch. But the resulting sound is awful. So this was quite useless. I therefore wondered if anybody would have any suggestions how one could change the speed of a sound while keeping the same frequency, but without distorting the sound quality too much?
Please login first to submit.