sounds play fine in corona but on device only 1 sound plays

i have 3 sounds loaded in my script for my game,one menu song, one credits page song,and the soundtrack song…all works perfect in corona but when i play it from my device only the menu music works.all in same project rate and format…only on device is an issue…i tired all of the sounds indevidualy and they work fine so its not the files…anyone have any ideas? [import]uid: 124254 topic_id: 22006 reply_id: 322006[/import]

iOS or Android? What format are sounds? [import]uid: 52491 topic_id: 22006 reply_id: 87469[/import]

playing them through the same channel maybe? Try getting a free channel for each sound you want to play. [import]uid: 8872 topic_id: 22006 reply_id: 87474[/import]

All sounds are Mp3’s project rate of 44100 mhz,i wasnt aware about “channels” in lua,how would i go about setting 3 channels for 3 songs? …sorry peach,all my apps will be on android…so android device is the answer to your question peach [import]uid: 124254 topic_id: 22006 reply_id: 87527[/import]

That a look at this page, it has examples of loading and setting the channel and then playing; http://developer.anscamobile.com/reference/index/audioplay

Sounds like Kam was spot on - give that a go and let us know :slight_smile: [import]uid: 52491 topic_id: 22006 reply_id: 87609[/import]

Yeah i found that earlier,but for some reason i cant get it to work…i tried over and over for about 2 hours. Im so new to coding with no training im afraid im missing something with it. 3 sounds 3 channels.Should be simple.Ill keep plugging away [import]uid: 124254 topic_id: 22006 reply_id: 87614[/import]

Sharing your audio code may help.

In situations like this I try making a new project as a sample, just doing the audio - then I go from there, make it work, implement it in main project.

We were all new at some point - I didn’t have any experience when I started either. Over time, with effort, it gets much easier :slight_smile: [import]uid: 52491 topic_id: 22006 reply_id: 87640[/import]

im very sorry to be in here (noobing) it up right proper.ill show a sample of what im doing here,but just need to see if channels work with media.playSound
function tweenMS:tap(e)
if(e.target.name == ‘startB’) then
media.stopSound()
–MUSIC START
media.playSound( “gamesoundtrack1.mp3”, true )

Runtime:addEventListener( “enterFrame”, move )
media.setSoundVolume( 0.4 )
– 2
– Start Game

transition.to(menuScreen, {time = 300, y = -menuScreen.height, transition = easing.outExpo, onComplete = addGameScreen})
else
media.stopSound()
media.playSound( “icebaron-master-plan.mp3”, true )
– 1

media.setSoundVolume( 0.3 )
– Call AboutScreen

aboutScreen = display.newImage(‘aboutScreen.png’)
transition.from(aboutScreen, {time = 300, x = menuScreen.contentWidth, transition = easing.outExpo})
aboutScreen:addEventListener(‘tap’, hideAbout)

– Hide Menu Buttons to disable

startB.isVisible = false;
aboutB.isVisible = false;
end
end

function hideAbout:tap(e)
transition.to(aboutScreen, {time = 300, x = aboutScreen.width*2, transition = easing.outExpo, onComplete = rmvAbout})
end

function rmvAbout()
media.stopSound()
aboutScreen:removeSelf()
media.playSound( “Grimeth Riddim.mp3”, true )
– 1

media.setSoundVolume( 0.2 )
– Enable Menu Buttons

startB.isVisible = true;
aboutB.isVisible = true;
end [import]uid: 124254 topic_id: 22006 reply_id: 87890[/import]

Hey,

As mentioned on Twitter earlier you are using the old sound stuff.

You want to load the sounds using audio.load or audio.loadStream and then play them using audio.play.

This way you can use channels and fix up the audio issues you’re currently having :slight_smile: [import]uid: 52491 topic_id: 22006 reply_id: 88002[/import]

got all 3 channels working now but when i turn them off in script to initiate another channel,it turns off as expected but when i return they wont play…i read you have to tell it which channel to shut off,i did just that,but its not working,when i try to copy paste from api section,i get script crash,ill explain.they say audio.stop( [channel] ).Witch i presume means audio.stop( [3] ) , but if i use the [] i get crash…so i take them out and use audio.stop (3) and i get nothing,audio is played on 3 and it shuts it off,but channel is not free’d up again for use ,so when script tries to reuse it,nothing,so what am i missing here…heres script piece that involves this…

gamesoundtrack1 = audio.loadStream(“gamesoundtrack1.mp3”)

gamesoundtrack1 = audio.play( gamesoundtrack1, { { channel=3, loops=-1, fadein=5000 } )

audio.stop(3) [import]uid: 124254 topic_id: 22006 reply_id: 88041[/import]

Use your assigned name.

[lua]audio.stop( gamesoundtrack1 )[/lua] [import]uid: 52491 topic_id: 22006 reply_id: 88056[/import]

I tried that before but it didnt work,perhaps i had a small error somewhere else at the time i tried that,I shall try that again now i know i have everything in proper order.

Thank you very much for your patience with me asking so many noob questions.Have no fear i log all my scripts and changes so i will learn and not ask the same things over and over.And thank you to everyone that chimed in to help me. My only hope is to one day have the knowledge to return the favor to other corona subscribers when they are in need and together we can make fun games for the whole world to enjoy. [import]uid: 124254 topic_id: 22006 reply_id: 88123[/import]

Actually I had/have the same problem. Except I was using audio.loadStream for all my audio.
When I placed my background music on channel 3 it played. It was called bkgMusic.
When I called a audio.stop(speech) it also stoppped the bkgMusic.
Which shouldn’t happen.

I solved it by using the media.playSound for my backgroundmusic and the rest is still loadStream.
Now it works flawlessly.

Any ideas why audio.stop(varName) stops other audio channels also [import]uid: 100901 topic_id: 22006 reply_id: 88129[/import]

Because audio.stop must be the channel you want to stop, not the sound handle. Please refer to the documentation. This is explained in detail.

http://developer.anscamobile.com/node/3721

[import]uid: 7563 topic_id: 22006 reply_id: 88132[/import]

This is wrong:

gamesoundtrack1 = audio.loadStream("gamesoundtrack1.mp3")  
gamesoundtrack1 = audio.play( gamesoundtrack1, { { channel=3, loops=-1, fadein=5000 } )  
audio.stop(3)  

You are overwriting the sound handle variable with the channel.

gamesoundtrack1 = audio.loadStream("gamesoundtrack1.mp3") -- gamesoundtrackchannel will be 3 since you requested channel 3 as a parameter gamesoundtrackchannel = audio.play( gamesoundtrack1, { { channel=3, loops=-1, fadein=5000 } ) -- Why are you stopping here? This will stop the audio immediately so you won't hear anything audio.stop(gamesoundtrackchannel) [import]uid: 7563 topic_id: 22006 reply_id: 88134[/import]

read up,i tried it the other way and it didnt work,not sure the issue…and thats not a stop there,thats only an exerpt from the 1100 line script,i only put the active code used for this…that stop u speak of is actually 20 lines under it in another function…it all works great in function,only the restarting of the sounds is an issue at this point…please forgive me…im very new to scripting with no classes or anything,so i just figured out syntax isnt a maxipad…lol…i will try this out again and see if i can work thru this…after that i need to make a keystore so i can load my other game i finished …2 days on that part,>.<

hhmm,a thought occurred to me,i read your words again,and i think a lightbulb just went off,i see the redundancy…brb i feel like a noob…because i am lol [import]uid: 124254 topic_id: 22006 reply_id: 88138[/import]

If you are always requesting channel 3 in audio.play, you will only get 1 sound playing because a channel can only play 1 sound at a time. (That’s the point of having multiple channels.)

Dump the channel parameter from your code and see what happens.

[import]uid: 7563 topic_id: 22006 reply_id: 88140[/import]

yeah i went the other way now sound wont play…lol

gamesoundtrack1 = audio.play( { channel=3, loops=-1, fadein=5000 } ) – play the background music on channel 1, loop infinitely, and fadein over 5 seconds [import]uid: 124254 topic_id: 22006 reply_id: 88144[/import]

nah im using 3 diffrent channels and sounds,im using 2,3,4 ,double checked to be sure… [import]uid: 124254 topic_id: 22006 reply_id: 88145[/import]

dumped it and the same,no sound at all

gamesoundtrack1 = audio.play( { gamesoundtrack1, loops=-1, fadein=5000 } ) – play the background music on channel 1, loop infinitely, and fadein over 5 seconds

.im trying to understand,but the first code i had with redundancy is the only one that will even work,hmm,im at a loss for words,anyone have a clue whats happening here.if you need to to repost code i can just let me know.or if theres something im forgetting to post so u can see better…ty all for your help. [import]uid: 124254 topic_id: 22006 reply_id: 88148[/import]