Slow motion effect for sound
Hello,
I’m very new to this engine. Actually I’ve interested in it because I need to implement one simple(as I think) thing – it’s slowing down music and sounds when pause menu occurs and accelerate up after it hides.
Something like here – https://vimeo.com/174327353
Is there a simple way achieve this? I tried just to set using default cocos2d-iphone engine pitch linearly, but it work very bad..
How this effect can be done with The Amazing Audio Engine?
Comments
You can utilize the varispeed filter within The Amazing Audio Engine via the AEVarispeedModule. You can even see how it's implemented in the excellent sample app project that's provided in TAAE 2 source on GitHub:
https://github.com/TheAmazingAudioEngine/TheAmazingAudioEngine2
You can see it in action in the sample app preview video at 1:52 seconds:
https://www.youtube.com/watch?v=q9dcApliV-Y#t=1m52s
The varispeed is slowing down the speed with the left hand, while the right hand is manipulating the bandpass filter. Here's the full video, if you're interested: https://www.youtube.com/watch?v=q9dcApliV-Y
This is a code snippet from TAAE 2's AEVarispeedModule.h file:
Normal playback rate is 1.0, which is its default. In your case, you may just want to change the playbackRate between 0.25-0.5 in order to slow it down for the desired effect. In order to hear the slow down in real-time, you should implement an NSTimer, so that you can hear the change happen over time, during the duration of the animation speed change. You can find this in the sample app in the following code:
Line 188:
Line: 470:
Hello,
thanks for prompt reply. I'm using Objective C only and Cocos2D, so Swift code example for me is hard to read for now..
Is this same possible with v1 engine?
Also, I'm just looking for simple demo project, that just demonstrates changing of pitch for sounds. Can you please provide such example in Objective C?
Also, I'm trying to add TheAmazingAudioEngine2 to a simple even UIKit project, following instructions http://theamazingaudioengine.com/doc/_getting-_started.html#Setup and when I try to import it : #import <TheAmazingAudioEngine/TheAmazingAudioEngine.h>
I got an error:
'TheAmazingAudioEngine/AEBufferStack.h' file not found
Here is my test project:
Pls disregard previous message. Added "$(BUILT_PRODUCTS_DIR)" to header seach path. Pls include this into documentation.
So, one question left for me: can I use old and solid version(that has some getting started guide) of engine and apply pitch?
Or I should use new one? Could someone please show simple Objective C example of doing so for v2?
I'm looking for just loading audio file and changing it pitch. This will be really helpful to me to integrate into my cocos2d-spritebuilder game code.
Hello,
I'm using this code for loading and playing audio. All seems to working fine
`
-(instancetype) init {
}
return [self.output start:error];
}
`
However, changing varispeed.playbackRate does very bad sound while it's slowing down
I'm trying to do something like here – https://vimeo.com/174327353
But how can I achieve such effect? Currently I'm just decreasing it's value:
.playbackRate -= 0.04; each 1/60 times per frame in update method.
Try modifying the varispeed.playbackCents, instead of varispeed.playbackRate. 0 to -2400 sounds pretty good. I would use an NSTimer to affect the change over time.
FYI, I'm working on an Objective-C sample project for you that will demo the following, using TAAE 1:
I'll post it on GitHub when it's ready. it should be soon.
Take care,
Mark
Hello Mark,
I've already tried to change .playbackCents also.
Here is small part of my music game theme : https://www.dropbox.com/s/0kfq0u1nscuepop/game_2.wav?dl=0
When I apply playbackCents it's sounds a little bit better but it's far far away from what I'm looking for, like in that vimeo video.
Example from TAAE 1 is interesting for me, especially with all features you describe. Because for my game I need exactly this.
@klymenko.volodymyr.m,
I checked out your game theme. Of course, your music is going to sound different when slowed down, compared to a buzzing saw with reverb. What exactly doesn't sound right to you when you implement the varispeed playbackCents solution? Are you starting and stopping the music's playback with an NSTimer? Is there any chance you could please post some code or at least an audio example of your varispeed result?
I also noticed in the Vimeo example, that the Badlands menu includes its own sound effect when it swipes up and down, as soon as the gameplay is paused or restarted.
Easily. I'm using cocos2d, but it has similar CCTimer, so yes, I'm using it. It ticks fixed 1/60.
upd.: when I created simple example with clean project, I've found some bug in my actual game code - it wasn't set correctly that value(very fast decrease) so now I have a good working example(not ideally like in Badland) and it sounds like in vimeo video. Yes, with my game music, it will sounds really different and now, I realised, that it's really depends on the music and slowing down my sample sound not really nice..
Maybe, to make it better, I should apply high pass filter after 0.1ms beginning of decreasing playbackCents value. Because I think that bass sounds, like in my music because sounds worse at low speed.. Need to find how to do that...
Thanks for your help. However, I'm still very interesting in your example with TAAE 1.
For my game, I would need these actions: play, pause, stop, mute, handle interrupt(for example when game minimized sound should correctly paused) and pan.
@klymenko.volodymyr.m,
I'm sorry for the delay with this. But, here's the Xcode Objective-C example that I promised you, that demos how to pause and play an audio file with a slow-down torque effect with the varispeed filter. In addition, it includes panning and volume control:
https://github.com/markjeschke/TAAE1-Torque
Take care,
Mark
Mark you're awesome! Thank you!
You're very welcome. It was a fun exercise to implement. Please let me know if you have further questions.