Page 1 of 1

Simultaneous music and sounds [Solved]

Posted: Sun Feb 02, 2014 11:33 am
by NekoNutchi
Hello, i've been looking around for some posts on this; how do you make two (or more) sound files play at the same time?

I've tried putting them on different channels (music and sound respectively) and to list both of them in the play music statement like so:

Code: Select all

play music [ "file1.mp3", "file2.mp3" ]

But alas, only one file can be heard in playthrough.
Is there a way to do it using customized channels?

Re: Simultaneous music and sounds

Posted: Sun Feb 02, 2014 12:05 pm
by Crazy Li
I'm pretty sure the play statement only takes one file. This would probably work if you did two lines one right after another to play and used a different channel for each. Never tried it myself though because I haven't had a reason to yet.

Do note that the sound channel doesn't loop though so if you wanted looping sound on a channel that isn't music, you might need to create your own custom channel for it.

Re: Simultaneous music and sounds

Posted: Sun Feb 02, 2014 12:11 pm
by NekoNutchi
Well, i did try to put them on different channels like this:

Code: Select all

play sound("file1.mp3")
play music("file2.mp3")
which didn't produce the effect i wanted.
Don't need looping for this btw, so at least that won't be a problem.

Re: Simultaneous music and sounds

Posted: Sun Feb 02, 2014 12:56 pm
by Keinart
With "the effect i wanted" you mean the music one was looping and the sound played only once? You can always add noloop statement in music to fix that

Although I think you will probably need to create a new channel with renpy.music.register_channel and then give it the same properties as sound, then play them at the same time.

Re: Simultaneous music and sounds

Posted: Sun Feb 02, 2014 1:10 pm
by NekoNutchi
Keinart wrote:With "the effect i wanted" you mean the music one was looping and the sound played only once?
Yes, except i don't necessarily need the music file to be looping. Playing both the soundeffects and the music file once would be fine, as long as they play at the same time.

Re: Simultaneous music and sounds

Posted: Mon Feb 03, 2014 1:25 pm
by Keinart
Then I think it should work if you create a new channel and just call it "sound2" or something like that. Using renpy.music.register_channel in options.rpy and giving it the same properties as sound should be ok, then just use them together as you did before

Code: Select all

play sound("file1.mp3")
play sound2("file2.mp3")
I never created a new channel tho, so I don't know if there's maybe some trick or something weird to know creating one.

Re: Simultaneous music and sounds

Posted: Mon Feb 03, 2014 2:49 pm
by Crazy Li
NekoNutchi wrote:Well, i did try to put them on different channels like this:

Code: Select all

play sound("file1.mp3")
play music("file2.mp3")
which didn't produce the effect i wanted.
Don't need looping for this btw, so at least that won't be a problem.
What effect DID it produce? Did the first start before the second one?

A cheap trick around this would be to edit your first file to add in some silent space before it plays that ends up pushing it back however long it is before the second one starts. I didn't expect renpy to have that much of a processing delay between the playing of two audio files though...

If you make it more clear what you wanted and what you got instead, I can give better solutions.

Re: Simultaneous music and sounds

Posted: Wed Feb 05, 2014 1:35 pm
by NekoNutchi
Keinart wrote:Then I think it should work if you create a new channel and just call it "sound2" or something like that. Using renpy.music.register_channel in options.rpy and giving it the same properties as sound should be ok, then just use them together as you did before

Code: Select all

play sound("file1.mp3")
play sound2("file2.mp3")
I never created a new channel tho, so I don't know if there's maybe some trick or something weird to know creating one.
Creating a new channel worked! Thank you for the help.