Hi!
I have a problem regarding recording audio and playing it back insync with other audio. I am trying stuff for a few days already but i can't figure it out :(
I want to make an app where the user can record his own audio over a playing audioclip (looping). So when he is done, both tracks should be played simultaneously and in sync.
So what i am doing is the following:
---------------------------
Audio class (pseudocode kinda)
Update(){
if(AudioSource.timesamples < previousTimesample)
if(isRecording){
StopRecording()
} else {
StartRecording()
}
}
previousTimesample = AudioSource.timesamples
}
-------------------------------
This should start (and stop) a new recording when the current track is starting from its beginning. On the PC this is not a problem and it's pretty much insync, but on mobile devices there is a little difference (which i expected). What i expected was that in the beginning of the recorded audio a few milliseconds would miss. But to my surprise, instead of less there is more! Below is an example of the waveforms. The first waveform is the looping audio, the second one is the recorded audio. The first peak in this example (with the black line in front of it) should be insync, but as you can see it is not! :(
![alt text][1]
Summary
----------
With the code, i expect that the peak of the second waveform should be a little bit sooner then the first waveform. But it's the opposite. Does someone know why this happens?
Also, i can image it is not all very clear. Please ask for clarification if you don't get it! :)
[1]: /storage/temp/31188-untitled2.png
↧