Page 1 of 1

Can't Register Audio Channel [Solved]

Posted: Sun Jan 25, 2015 5:15 pm
by Angelee
I'm using the "renpy.music.register_channel(name, mixer=None, loop=None, stop_on_mute=True, tight=False, file_prefix='', file_suffix='', buffer_queue=True)" function from the documentation. I figured that creating a separate audio channel will let me play two sound effects at the same time. But...I don't know where to put it. I put it in the scripts file and in the options file and they both gave me errors when I did that. It says that the "sound2" (which I named my channel) is not defined.

If someone could help me out I'd really appreciate it. (ಥ_ಥ)

Re: Can't Register Audio Channel

Posted: Sun Jan 25, 2015 5:50 pm
by trooper6
I'm pretty sure you can put the declarations in any file since Renpy treats all individual files as one big file.
It should however be in an init block and a python block.

This is what I have in my code:

Code: Select all

init -1 python:
    renpy.music.register_channel("TockBG", mixer= "sfx", loop=True)
    renpy.music.register_channel("ChimeBG", mixer= "sfx", loop=False, tight=True) 
    renpy.music.register_channel("Alarm", mixer= "sfx", loop=False, tight=True)  
It works for me...so what exactly did you put in your code?

Re: Can't Register Audio Channel

Posted: Sun Jan 25, 2015 7:31 pm
by Angelee
EDIT: Wait, I think I see the problem once I compare our scripts. Let me try something and I'll post the results.

EDIT: Yep, thanks a lot, trooper6! That did the trick. :D The problem was that I didn't put the channel name in quotes.

I put:

renpy.music.register_channel(sound2, mixer="sfx", loop=False, stop_on_mute=True, tight=True, buffer_queue=True)

instead of:

renpy.music.register_channel("sound2", mixer="sfx", loop=False, stop_on_mute=True, tight=True, buffer_queue=True)

Such a simple thing but I was scratching my head for hours! Maybe I'm not cut out for programming, lol. (─‿‿─)

Thanks again!

Re: Can't Register Audio Channel

Posted: Sun Jan 25, 2015 7:37 pm
by philat
Put sound2 in quotes. Yeah, I know the documentation isn't super helpful at pointing out when things should be strings or not. ;)

Re: Can't Register Audio Channel

Posted: Sun Jan 25, 2015 7:44 pm
by Angelee
philat wrote:Put sound2 in quotes. Yeah, I know the documentation isn't super helpful at pointing out when things should be strings or not. ;)
Haha, thanks! I figured it out a second ago. Now I feel so dumb. :oops:

Re: Can't Register Audio Channel

Posted: Sun Jan 25, 2015 8:11 pm
by trooper6
Glad I could help! Don't forget to edit the title of your first post to included [Solved]