So Titanium.Media.Sound() has methods such as setTime, getTime, and play()...
I have an array of sounds (5 mp3's) which are 100kb a piece, and I am trying to play them in unison. However this proves to be a fruitless endeavor. I have attempted using the
preload: true when creating the sound, doing the
sound[i].pause() in a loop to force the sounds to preload, then using
sound[i].setTime(0), then attempting to loop through each of these sounds by simply calling
sound[i].play() causes each sound to play, but at .01 (one hundredth) of a second offset.
For instance, if I add a setTimeout that outputs
sound[i].getTime() every second that the app is running I get:
Sound 0 plays, and is at 1.05 second, sound 1 is roughly at 1.04, sound 2 is at 1.03, sound 3 is at 1.02, sound 4 is at 1.01, etc..
In fact, at 0 seconds when playing, the output of
sound.getTime() is actually a negative number.
Trying to use an event listener to listen for the complete event of the first sound and resetting the times to 0 does not help overcome the problem that gets progressively worse as all the sounds play, the loops themselves get progressively more out of sync.
Is doing this in titanium too problematic? Sound I not be using Media.Sound()?
I'm looking for any insight that could help address this, even if it is an external module.
is this happening in iOS or Android? or both? Which SDK? In device or emulator?
GOOD NEWS EVERYONE! I have found something out that seems to be (tentatively) a great way to get this to "work". The problem is type type of audio file you use. I referenced this article: here which talks about the "most optimized, fastest file format for iphone when space is not an issue"... Encode your audio files in Linear PCM and this seems to tighten everything up. If I were to hazard a guess, the phone when calling "play()" on a .mp3() file needs to decompress the file before playing it. Anyway, I'm responding to this because I hope someone else benefits from it. Cheers!
How to record audio from the linear output instead of device microphone?
Think you can help? Login to answer this question!