Alex, thanks for trying. I already published my results and there is no doubt the multiple files method worked for me. I have kind of forgotten about this thread as my problem is solved for my purposes.
However, yes, there are several things I can see you are doing wrong. To help others I’ll list them a bit.
**But** I don’t want this thread to become a conversation about all the things you were doing wrong… so *please* if you would like further clarification please contact me directly. Thanks!
a) You are playing the audio and then seeking in the next line, which is the wrong order. You would seek first, then play. Right?
b) Your files are 48 kHz they should be 44.1 to match the audio system. You are creating extra work for the system by making it convert to 44.1 which is the default. You could try adding “audioPlayFrequency = 48000” to config.lua to try to tell openAL to use that sample rate, but I’d just stick to 44.1 and define audioPlayFrequency as 44100 in your config.lua as well for sake of completeness.
c) In your audio files, after the Hi Hat sound there are a lot of samples worth of trailing silence. You should trim all the silence off from the sound file so you don’t needlessly tax the audio system… although I guess there isn’t going to be mixing going on because you have the sounds playing on the same channel which will cut the currently playing sound off and start again (it won’t layer/overlap the sounds)
Also, you didn’t use my sounds… (you could have used the 16 ms of padding tick sound I had for a 1:1 comparison between my method and the seek method). It may also be that an extremely short 10ms tick sound like mine-- which doesn’t tax the audio system much in terms of having to mix overlapping sounds from different channels-- may have something to do with my success.
And, aside from using 44.1 kHz sounds you may also want to consider using mono sounds instead of stereo further efficiency.
You didn’t mention as well the method you are using to measure the performance difference. Are you recording the sound output of your app into to a sequencer?
Also, for the multiple files example, you are using 16 if then end statements to play the right file, and they aren’t even arranged as if elseif elseif end, they are all separate ifs, one after the other which is worse and might itself insert a tiny amount of time.
Instead you should have put all the audio files as elements 0 to 16 in an array called click so you can just execute one line, e.g.
audio.play(click[index])
Again, I don’t want this thread to become a discussion of what you were doing wrong, so please contact me directly, and then if you have later success post here again
I should also mention that I don’t have much time to spend on this research these days, as I am concentrating on the other logic in my app…
Cheers,
Gary
[import]uid: 106887 topic_id: 13881 reply_id: 93802[/import]