depending on the sound my game plays, I get a drop in the framerate when I play them quickly after each other. Let's say 5-7 sounds (shots) which are around 5 seconds long.
My question is, is there a best practise for the format of sounds I should use? I mean what bitrate, khz value. What are the best formats for less lagging?
no problem for now... (tested on android only)...
do you know how to do an infinite loop sound ?
loops =1 or 0 play loop only one time..
Which audio format did you use? Samplerate etc?
I just played more with it lower settings and on my IPod Touch 2nd gen there is no difference. Still craps the FPS.
You should use .wav files for sound effects and .mp3 for background music. Here are the advantages and disadvantages of these:
-wav files: Entire sound is loaded into memory. Has very low latency to play. Consumes little CPU while playing. Suitable for simultaneously played sound effects.
-mp3 files: Sound is played by reading small chunks therefore consumes little memory. Consumes more CPU compared to .wav files. Suitable for background music/speech. According to my tests, playing a single mp3 consumes about %20 of the CPU on iPod touch 2nd gen.
Mike, can you convert your .mp3 files to .wav and try again?
Likes: krisis, duke2017, thanhquan1512
see you never stop learning. Of course I will test. And will add this info to the guide.
Atilim, if I use 16 bit pcm, does that have an effect of the performance?
thanks for suggestions, now i'm also using 22050 wav for sfx...
but play(0, math.huge)
(math.huge is a constant. It represents +infinity.)
don't loop sound....
i'm missing something ?
Let me check it. While I'm checking it you can use a very large number (e.g. 1000000) to loop for a long time.
but why not implement in "play" function -1 to loop to infinite ?
All Timer, Sound and GTween classes use repeat counts. I'll implement a common way to specify infinite loop (it can be -1 or math.huge) with these classes.
efficent as always...
(and if I can ... I vote for -1) ;;)
Is there any way that mp3 files could also be loaded into memory if required? In Corona I used loadSound to load mp3 files into memory and loadStream to read them a bit at a time. I've converted my mp3s to wav files (using 22050 khz and 16 bit) which works fine, but the size of the app has grown enourmously and would be a lot smaller if I could use mp3 files.
I wondered if it would be possible to allow the choice of how mp3 files are handled and, if it was, if you would consider including it? There may be a good reason that I don't understand why it isn't possible!
Unfortunately no way. To implement this, I need to embed a mp3 decoder (e.g. mpg123) and this means increasing of the executable. Currently we're always using device capabilities to play mp3's. It's a tricky issue on our side.
I think you want to use low latency sounds while not increasing the application size, right? Do you encounter problems while using mp3s?
I wondered if there was a reason for it and now I see there is!
You're right that I want to use low latency sounds whilst keeping the size down. I have tried it with mp3s and have problems with that (worse on some devices than others - particularly bad on an Archos 70 tablet that a tester uses). I am often tweening things at the same time as the sound is called and have found that mp3s cause the tween movement to stutter and become very jumpy, especially when several are going at once. All becomes OK once I replace the mp3s with wav files.
Looks like I'll be having larger application size. What is the lowest quality wav file that will play? Does it have to be at 22050 khz or can it be lower? I could use lower for some of the sounds without the reduced quality mattering too much.
I understand now. You can use very low quality wav files (e.g. 11025 or 8000) without a problem. I wish I can present a solution.
That's OK - I'll reduce the ones that don't matter too much and just keep the larger ones for voiced bits and so on.
you can also use
Sets the looping state of the channel.
looping: (boolean) looping state to set
The app I'm working on requires a lot of sound tracks to be stored, but only one played at time.
I'm trying to balance file size with sound quality. Using Audacity, I narrowed the range of kbps that are acceptable from 40 to 64. (using "Bit Rate Mode" = "Constant")
Is there support for "Variable" and "Average" ?
I'm going to set up a test project to build for both Android and iOS, but if you have done tests already, then I'm interested in your findings.
but couldn't find any information about it. mp3 files are played using OS capabilities and I think there shouldn't be any limitations.