Page 1 of 1

Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 8:03 am
by MarkoSato
Hello,

In my project I have a background music implemented on preOpenCard which continues over 1-2 cards.
While the music is playing, i wanted to add another sound, for example if I click on a button that it makes a "click" sound effect or an animal sound effect but while the background music is still running.
I tried to implement both the same way with ' play "mySound.wav" ' which i "imported as Control" first of all, but when I click for example on the button the click sounds plays but the background music stops.

Is there a way without extension or anything like that only with raw liveCode to make 2 sounds playing at the same time possible?

(I am currently using LiveCode Community 8 (RC1) on a macbook air.

I Hope you can help me.

Kind Regards
Mark

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 10:36 am
by Klaus
Hi Mark,

if in doubt, always take a look at the dictionary!
From the docs about "play..."
....
If you start playing an audio clip when another one is playing, the first audio clip is stopped,
and a playStopped message is sent to the current card. You cannot play two sounds at the same time,
nor can you queue a sound while another sound is playing.

...
So you need to set up two player objects (or maybe only one for your bg music/sound), but these only work
with external files and you need to set their filename property.

This way you can have as many sounds as you like playing at the same time.


Best

Klaus

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 11:17 am
by MarkoSato
Hello,

Oh Ok sorry my bad i am still a newbie.
Hmm that's unfortunate because I am not allowed to use extensions in my project.
Well, can't do anything about it. Thank you anyways. :D

Best Regards
Mark

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 11:24 am
by Klaus
Hi Mark,

sorry compeltely forgot this one: Welcome to the forum! :D

What you you mean "no externsions allowed"?

QuickTime (and nowadays AVFoundation) is the underlying multimedia engine of
operation system (!) and LC is only using it, as all other audio/video apps on the Mac do!


Best

Klaus

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 2:50 pm
by MarkoSato
Hey Klaus,

I am a student at university and I have to make a project with LiveCode.
In the script the prof wrote that" we are not allowed to use external links or datas, no substacks and no externals etc".
So because of this I don't want to risk my project to be not evaluated.
(And I also don't know how to use externals etc. :oops: )

Best

Mark

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 3:07 pm
by Klaus
Ah, "...no external datas...", I see.
OK, bad luck (and a silly restriction in my opinion, internal or external sounds, what's the difference?) 8)

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Fri Apr 22, 2016 5:31 pm
by jacque
You could ask whether including an audio file on disk is considered an external resource. Or you can just work around the problem with a little trick.

Store the raw audio file in a custom property of the stack. When you need to play the audio, write the file to disk in the user's temporary folder. Assign the temp path to the player control and start playback. When the app quits, or whenever you're done with the audio, delete the temporary file.

I've done this in more than one app and it works fine. Ask if you need help with any of the steps. You'll probably need to look at the tempName entry in the dictionary.

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Sun Apr 24, 2016 6:36 pm
by theotherbassist
And if after pulling your audio from a custom prop you still don't want to use QuickTime, you can always play multiple sounds simultaneously via html and JavaScript in a browser instance.

Re: Apply two Sounds at the same time LiveCode 8 (RC1)

Posted: Sun Apr 24, 2016 6:55 pm
by MarkoSato
OK, thank you very much for the help.
I am going to see my prof next week so I will ask him there if I could do it like you suggested.

Best
Mark