Get different octave of one sound ?

Hi !
I’d like to know if it was possible to take one sound and modify it in a way to get a different octave of the same sound.

I guess I could:
-compute the FFT of my sound
-find the central frequency (may be hard for some sample…)
-modulate my frequency to the octave I want: sig*exp(2*i*PI*Fmod*t)

Does anyone have a more precise idea ? There must be some nice library doing this I guess…

Thanks in advance :smiley:

Firstly, how are you playing back your sound? using ofSoundStream or ofSoundPlayer?

Maybe what you want is setFrequency () on the FMOD channel. It’s not part of the ofSoundPlayer but if you read up on the FMOD api you should be able to add it fairly easily.

Using an FFT for a pitch shift, if done properly will give you a better result but is much more computationally expensive.

simply playing it at double the speed will play one octave higher, and half the speed one octave lower. Of course the duration will change too. If this is not the intended effect, and you’d like to change the pitch without changing duration you need to look into time-stretching / pitch-shifting (flip sides of the same coin).

Thank you very much for your answers !
I have not yet decided how I’ll play the sound (ofSoundStream/ofSoundPlayer/…)

I’ll try both :slight_smile:

merci beaucoup !

This is where I got all the pitchshift info I put in my book (and a place to find some C code that does a proper and fast FFT)

This is easier to do if you use ofSoundStream rather than the player, in my experience at least.

Sorry, meant to add the FMOD option is also viable, but is a little tricky to get working right as you need to hack the ofSoundPlayer a little bit.

Thank you very much !! I’ll have a look at this also !
I don’t have much time for openFrameworks recently >_<

By the way, your book arrived this saturday evening !
I only had a few minutes to go through it, it is very nice !
Thank you !!! :slight_smile:

Glad you’re enjoying the book so far. Hate to say this, you should head to the errata page for it

a few things got mangled a bit in the editorial process or got formatted weird. Luckily, I’ve had a few sharp readers pick those things up and point them out.

Ok, no problem :slight_smile:
If I find anything I’ll make sure to report those there

I quickly looked at your octaveDown function during a break.
It seems to be more a low pass filter than a function to get one octave down. :smiley:
The name may be a bit misleading !

I’ll keep on reading tonight :slight_smile:
smbPitchShift seems to be what I need