How to loop sound effects? [solved]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Panda_nui
Regular
Posts: 44
Joined: Mon Jul 02, 2012 10:48 am
Projects: re:_night
Location: in your closet
Contact:

How to loop sound effects? [solved]

#1 Post by Panda_nui » Wed Jun 04, 2014 3:42 am

So right now, i've succeeded in creating a decent raining effect in my game and it's time to add the sound effect.
The thing is the sound effect for the rain only lasts for a few seconds and i have a whole rain scene.

Code: Select all

 play sound "music/sfx/rain.wav" loop
This code only plays for the few seconds and I was wondering if there was any way to loop or make that sound effect continue even after that 3 seconds of sfx ended.

Thank you in advance!
Last edited by Panda_nui on Wed Jun 04, 2014 11:22 am, edited 1 time in total.

User avatar
LRH
Regular
Posts: 42
Joined: Mon May 19, 2014 10:59 am
Contact:

Re: How to loop sound effects?

#2 Post by LRH » Wed Jun 04, 2014 5:26 am

I think you have to define another sound channel that works like a music channel.

http://www.renpy.org/wiki/renpy/doc/ref ... er_channel

User avatar
Asceai
Eileen-Class Veteran
Posts: 1258
Joined: Fri Sep 21, 2007 7:13 am
Projects: a battle engine
Contact:

Re: How to loop sound effects?

#3 Post by Asceai » Wed Jun 04, 2014 5:37 am

Congratulations, you've found a bug.

You can get around it by using python instead.
$renpy.sound.play("music/sfx/rain.wav", loop=True)

User avatar
Donmai
Eileen-Class Veteran
Posts: 1867
Joined: Sun Jun 10, 2012 1:45 am
Completed: Toire No Hanako, Li'l Red [NaNoRenO 2013], The One in LOVE [NaNoRenO 2014], Running Blade [NaNoRenO 2016], The Other Question
Projects: Slumberland
Location: Brazil
Contact:

Re: How to loop sound effects?

#4 Post by Donmai » Wed Jun 04, 2014 7:56 am

LRH is right. You can define an 'ambient' sound channel with sound looping enabled, exactly like the music channel:

Code: Select all

$ renpy.music.register_channel("ambient","sfx",True,tight=True)
Then you can simultaneously use the 'music' channel to play a sad piano tune, the 'ambient' channel to play the rain noise, and the 'sound' channel to play a thunder sound from time to time. :wink:
Image
No, sorry! You must be mistaking me for someone else.
TOIRE NO HANAKO (A Story About Fear)

User avatar
Panda_nui
Regular
Posts: 44
Joined: Mon Jul 02, 2012 10:48 am
Projects: re:_night
Location: in your closet
Contact:

Re: How to loop sound effects?

#5 Post by Panda_nui » Wed Jun 04, 2014 11:23 am

jksdfas Q7Q <33
@Asceai I used the code you showed me and it worked perfectly! :DD
thank you so much for the help everyone!!

Post Reply

Who is online

Users browsing this forum: Bing [Bot], humanpencil