Use channel->setFrequency(value * frequency_of_your_sound), for example:
value = 0.5f => 50% slower
value = 1.08f => 8% faster
or use a negative value to play backwards
If you want to increase the tempo without affecting the pitch of the sound use the built-in pitchshift dsp.
- mylo answered 10 years ago
Thank you. I would like to know how to create a dsp with pitchshift and fmod_playsound?
I could have a small example of code :
result = FMOD_System_CreateSound(system, "sound.mp3", FMOD_CREATESTREAM, sound)
Thank you for your help
[code:qqcvjn5c]result = FMOD_System_CreateSound(system, "sound.mp3", FMOD_CREATESTREAM, &sound);
The DSP effects are applied by channel not by sound so you’re going to need a channel and a DSP unit.
// 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 part using SetParameter is setting the pitch value: 0.5 to 2.0. Default = 1.0. 0.5 = one octave down, 2.0 = one octave up. 1.0 does not change the pitch.
Hope this helps,
I don’t know why you’re getting DSP connection error. The code I wrote had the DSP_SetParameter after the DSP effect had been applied when actually it should of been set before being applied, this has been corrected. However i doubt that caused your error. I tested this (new) code and it works perfectly.
Please login first to submit.