Synchronisation between sound file and animation - iphone

i have 25 images and a sound file of 2 seconds.
I am ale to play the sound and playing the animation but the synchronization is not getting between sound and the animation ...
Can any one please help me how to synchronization the animation with sound...
There are 25 frames and the sound file duration is 2 seconds...
Can any one please help me how to synchronize the both ......

Whether the animation is manual triggered by means of swiping or it s automatic ?
If it s manual like in the case of swiping you can call the sound file to play whenever the animation is (manual like swiping)done.
Post some of your code. Then we could help you.

See my answer to Animation iOS with sound file for a step by step on how to play a sound with AVAudioPlayer and then blit a specific image to the screen at exactly the right time.

Related

AVAudioRecorder setting recording start time

I am using AVAudioRecorder for recording sound in my ios app. I want that if user moves the UISlider object to 2 seconds and press Record button then after saving the recording file and playing it, user should hear the recording after a pause of 2 seconds. How can I achieve this functionality? Can anyone please help?
Best Regards
You can add 2 second silence (please consider slider value is 2) to your Audio file starting section
To do this please go through this link
The below links also may help you to achieve the goal.
avaudioplayer-append-recording-to-file
trim-audio-with-ios

Play mp3 file smoothly upon dragging a scroll using AVToolbox or openAL

I have been facing this since so many days but I have not reach to any conclusion.
My problem is : I want to play an mp3 file but not simply by clicking on a play button.
It is this way I want to play it.
*There is a slider that I can drag using finger, I want that the mp3 should play with the frequency with which I am dragging the finger (or speed with which I am dragging my finger, so that it will give an effect of fast forwarding (funny type of voice)) or if I drag slider slowyly the output will be slow *
The problem is the output of the sound is not coming out smooth. its very distorted and disturbed voice.
I want the outuput to be smoother.
Please help. Any suggestions please. Presently I am using AVAudioPlayer and passing the time value based upon slider input to play the file. (It does not seems to be feasible though).
I feel that it is possible using openAL only and no other way. Because using openAL we can modify the frequency of the sound file (pitch)
CAN SOME ONE PLEASE REFER ME A LINK TO openAL implementation for iPhone . I have never played a sound file using openAL
Help!!
You won't be able to do it with AVAudioPlayer, as it does not support pitch operations.
You can load and decode the entire track into memory for playback with OpenAL (which supports pitch), or you can do realtime loading/decoding and pitch changing using Audio Units (MUCH lower level, and more complicated, though).

AVAudioPlayer lag when calling play

I have set up an AVAudioPlayer object in viewDidLoad, as per the Apple guidelines, calling prepareToPlay as the last line in viewDidLoad (i have tried in awakeFromNib also).
When i press my play button, there is a pause, as it would appear to load the file, then it plays.
In audioPlayerDidFinishPlaying, i reload the player with a different sound, and when clicking play for a second time, the file plays instantly.
What would cause the player to lag on the first play?
Thanks.
The delay is due to AVAudioPlayer being initialised. Please see this answer.
The audio system runs on several asynchronous software processes (audio units, OS drivers, etc.) and hardware systems (DMA, DACs, audio amp power supplies, etc.) that never really all completely finish initialization until some sound is actually played all the way out the speakers or earphones.
Here's one method to do that: Create a sound file containing a half second of silence. On app start up, while your app and view controller are still loading, use AVAudioPlayer to play this file of silence. Now when your view finishes loading, AVAudioPlayer should be ready to play subsequent non-silent sounds much faster, since some audio (silence) has already already gone all the way out to the speakers.
What kind of sound are you playing? Alerts, something longer? If alerts, I did go this way and it's much better with lags ...
create system sound with AudioServicesCreateSystemSoundID
play system sound with AudioServicesPlaySystemSound
dispose system sound with AudioServicesDisposeSystemSoundID
... you only need to store SystemSoundID for each sound you would like to play.

How do I sync recorded voice to animation on the iPhone

I want to record voice and sync that up with animation on the iphone as a user touches the screen. Are there apis that will help me accomplish this? I've not done anything like this so I"m having a hard time visualizing the type of algorithm that would help me accomplish this.
I did this by saving [recorder currentTime] and then using an animation loop on playback in a different thread that polls the player and animates based on these saved times. You can poll the player using [player currentTime] as well.

Fade In and Out Audio in iPhone SDK

I am wondering if there is some way to fade in and out audio using AVAudioPlayer in CocoaTouch, with a pause command once the music finishes fading and then a play command once the fading begins. I have heard that one can use NSTimer for this purpose, but I am unsure of the easiest way to accomplish this.
Thanks for any help!
There is a good video tutorial to do this here: Playing a sound, and fading a sound using AVAudioPlayer on iPhone.