Changing pitch of sound in realtime
I have an engine sound that I want to loop and also adjust the pitch of dynamically.
Any idea how I would go about doing something like this? I see the ability to pan and change volume of a AEAudioFilePlayer object, but not pitch.
Any pointers would be appreciated!
Thanks.
Comments
You'll probably want to use one of the audio units, like kAudioUnitSubType_NewTimePitch, etc. If you need pre-iOS 6 compatibility, you might wanna take a look at Dirac.
Thanks for your help Michael. I've got it working now.
kAudioUnitSubType_NewTimePitch
seems to stretch the time of the sound but keep the pitch the same.kAudioUnitSubType_Varispeed
actually does what I needed better.Here's the code I used to double the pitch.
Great!
Great!, but..
Is it possible to change the sound pitch without changing the speed?
Dmitry,
should do the trick for you.
But it changes the speed and pitch (faster) every time I record.
Can it keep the speed at original recorded tempo while only altering (higher or lower) the pitch?
?
Solved
@anatol can you please tell us how did you solved it ? It would really help us
@ricky641b - even though it's a bit late, I'll post this for people searching for the answer - I implemented the NewTimePitch approach in TheGameSample Xcode project here: https://github.com/jcypher/TheAmazingAudioEngine/blob/master/TheGameSample/GameScene.swift - code snippet (in Swift) is:
(I'm typing this on my phone, else I'd clean the code up