简体   繁体   中英

How to reverse an audio samples?

How can i reverse an audio samples with iphone sdk? I'll try to make a "dj scratch" effect. I'm talking about speeding up and slowing down and reversing the audio samples in real time.

This will not be as easy as you probably think. To get a real scratch effect you'll have to model the changes in playback speed - pitch shift down to 0 Hz and then reverse the audio stream and pitch shift back up again to the normal playback speed. This is not a trivial algorithm.

In general, when you want to do heavy processing with audio, you'll have to implement it yourself or with third party libraries. Audio queues and audio units are good starting points, but you can't make your own audio units for iOS. The best thing to do is perform all your processing in the callback for your audio queue or audio unit processing graph, in which you'll be handed a buffer of AudioUnitSampleType that you can manipulate to your heart's content before passing it off. (Take a look at the callback in MixerHostAudio.m in the Mixer Host sample application.) To get this effect you'll have to write decently complicated DSP code but in terms of interaction with Apple code, working from the callback is a safe bet.

You can use FMOD but there is no "reverse" function. You can make a sound play backwards by making the channel frequency negative. (According to the documentation)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM