So Codea2 is out, it runs super smoothly on my ipad retina, and I’m a happy camper (thanks to everyone involved).
I’m digging a little in the new music() function: is there really only one track playing allowed at a time? Say, I want to play an mp3 file as the background music, and then, on top, some wind noise mp3, combat sound (mp3), stepping noise, etc.
Is that not possible at all?
The music() function is for playing single music track in the background and sound() can be used to play sound effects and other noises on top. You can use sound() on with mp3 files too.
oh this is fantastic… thanks!
But sound() is for the synthesizer, so you can´t have a music track in the background and have for instance a voice on top, can you? Is it possible to use the synthesizer for background music? Like making sounds on top of each other? (Haven´t had the time to try it out)
sound() can now play other types of sound effects. Just tap the sound() function to see the picker, you can play .wav and .caf files (not sure about mp3). Edit: you can also adjust the pitch and volume of sound effects.
when I put music() , this “erases” my buttons sounds
To stop playing the current music track use music.stop()
There are a few undocumented features with sound() as well, which I will put into the reference in the next update.
If you play a named sound (not a generated one) it returns a SoundSource object, which has a few properties and functions you can use to control it. You can also make sound effects loop.
source = sound(name, [volume, pitch, pan, loop])
-- whether the sound is looping or not (boolean)
-- volume of this particular sound source (number)
-- pitch of this sound, also how fast it plays (number)
-- whether this effect is paused or not (boolean)
-- whether this effect is muted or not (boolean)
-- the pan of the sound, alternates between the left and right speakers (number)
-- whether the sound is currently playing (boolean)
This is pretty useful for various effects, such as playing a repeating engine sound and modulating the pitch and volume based on the current speed, gear etc. You can also use it to fade sounds in and out, etc.
Eyh! That´s super! A world of noises just opened up.
@John, that’s great. Lots of nifty possibilities with that.
@John Screenshot + bookmark
@SkyTheCoder All of the above sound options are listed in the built in documentation under sound/music. The sound option names are the same as the music option names and work the same, so you can see information there.
@dave1707 I know, I re-read the documentation. Screenshot + bookmark anyway though, so if someone asks how to change the pan of a sound or something I can direct them to this page.