Problem usind Audio?

Edit: just saw the error in the title, sorry :confused: it was “using” of course.

Anyways i just realised i have another problem, it seems like when i use the audio the way is described down there, im having like 0.5 second lag or something, the audio plays with some lag compared to the simulator and the way is meant to be played, i promise my volume is up now, any solution for this little lag?

EDIT: I’m such a dumb, i had the volume all the way down lol…

SOLVED:

Hello there, i’m having a problem when i try to play an audio in Android (cant test in iOS since i dont own any iOS device), the sound works perfectly in the simulator, but once i compile it and test it it doesnt play at all, this is the code im using right now:

local bgm = audio.loadStream("backgroundmusic.ogg") local bgmchannel= audio.play(bgm,{loops=-1})

Thats for a background music, when i move to the next scene i do:

audio.stop(bgmchannel)

to stop it.

For a regular sound, like a “confirm” sound when you select an option, i do:

local okay = audio.loadStream("confirm.ogg") local okaychannel= audio.play(okay)

and i dont stop it, since its not a long sound nor a looping one.

All of this seems to work ok in the simulator, but i cant play it at all in Android, im not sure if it doesnt support ogg, or if i should play the sounds in a different way, or if i should add them to the scene (im using storyboards).

Any sugestions?


Hey.

On android for sound effects it is recommended to use the media event sound apis. They suffer from less latency on android.

Give it a whirl. Also I would use .wav for sound effects as opposed to using .ogg

Hope this helps

Hey Gremlin, i just tried using the media event, apparently i cant have multiple sounds when i use it (like a background music and a sound when i jump for example), should i leave the bacgkround music as audio (since the little delay doesnt really matter in a whole song) and the in-game sounds as media? or is there a proper way to do this? btw when i tried to do “media.soundStop()” the background music carried over to the next scene :confused:

Thanks!

Hey :slight_smile:

Yeah i would continue to use the audio.* api to play your background music, and just use the media apis to play your sound effects only.

Thanks gremlin, im on my way to try it in android since the simulator doesnt support the .ogg using the media api (also none of the devices seems to support .wav with media), i also missed the “media.event” thing, it wasnt working with just media.play but i saw media play should be used for songs with 3 or more seconds, and media.event with sounds with 1-3 seconds, im just going to try it right now and will come to comment if that worked!

Edit:

Everything worked like a charm :slight_smile: thank you again Gremlin, its really a bit messy having to mix between sound and media and different extensions to try it, but oh well! what can we do right? 

Apparently the best way to do it so you can try it on simulator and will also work in Android, is using mp3, iOS is a dif story since it only supports .cad and .aif for media, but im not sure if the audio lags when u use audio as it does in android.

Thanks again!

Hey.

On android for sound effects it is recommended to use the media event sound apis. They suffer from less latency on android.

Give it a whirl. Also I would use .wav for sound effects as opposed to using .ogg

Hope this helps

Hey Gremlin, i just tried using the media event, apparently i cant have multiple sounds when i use it (like a background music and a sound when i jump for example), should i leave the bacgkround music as audio (since the little delay doesnt really matter in a whole song) and the in-game sounds as media? or is there a proper way to do this? btw when i tried to do “media.soundStop()” the background music carried over to the next scene :confused:

Thanks!

Hey :slight_smile:

Yeah i would continue to use the audio.* api to play your background music, and just use the media apis to play your sound effects only.

Thanks gremlin, im on my way to try it in android since the simulator doesnt support the .ogg using the media api (also none of the devices seems to support .wav with media), i also missed the “media.event” thing, it wasnt working with just media.play but i saw media play should be used for songs with 3 or more seconds, and media.event with sounds with 1-3 seconds, im just going to try it right now and will come to comment if that worked!

Edit:

Everything worked like a charm :slight_smile: thank you again Gremlin, its really a bit messy having to mix between sound and media and different extensions to try it, but oh well! what can we do right? 

Apparently the best way to do it so you can try it on simulator and will also work in Android, is using mp3, iOS is a dif story since it only supports .cad and .aif for media, but im not sure if the audio lags when u use audio as it does in android.

Thanks again!