voice and string interpolation? [semi-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
Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

voice and string interpolation? [semi-solved]

#1 Post by Jo'ogn »

I am trying to use dynamic voice overs, ideally like:

Code: Select all

$ mood = "fine"
voice ["I_am.ogg","%(mood)s.ogg"]
Player "I am %(mood)s." 
As there are obviously no file lists for voice I tried renpy.sound.play using channel 2 as this shall be dedicated for voice (and I don't want any of the other sound channels I use to be accidently switched off).

Code: Select all

$ foo = "%(mood)s.ogg"
$ renpy.music.play(("I_am.ogg",foo),loop=False,channel=2)
I did not seem to work either. (I use SHIFT-R to reload the script)
Then I tried renpy.music.play: no. I added:

Code: Select all

$ renpy.music.set_volume(1, channel=2)
And suddenly it did work o_0;

However after placing it in a different position of my game it stopped working again. For no apparent reason I switched to channel=3 and it worked again *duh* But it does not work anymore with the string interpolation, only when i give static filenames o_0;;;

Code: Select all

    $ foo = "fine.ogg"
    $ renpy.music.set_volume(1, channel=3)
    $ renpy.music.play( ("I_am.ogg",foo),loop=False,channel=3)

does only play "I_am.ogg" and not "fine.ogg", while this works:

    $ renpy.music.set_volume(1, channel=3)
    $ renpy.music.play( ("I_am.ogg","fine.ogg"),loop=False,channel=3)
Now, I am confused. There seems to be sth. going on with the channel volumes. Does voice mute channel=2 after playing?

And should the interpolation work in that context? At one time it did seem to work - but I tried so many times in such short succession that I might confuse my results now...
Last edited by Jo'ogn on Wed Aug 20, 2008 3:23 am, edited 1 time in total.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: voice and string interpolation?

#2 Post by PyTom »

Yes, the voice mechanism stops whatever's playing on the voice channel during each interaction. This is usually the right behavior, as you want (say) a thought to stop the currently playing voice when the user clicks ahead.

You can use the voice function to play computed voice. For example, you can do:

Code: Select all

     $ voice(["I_am.ogg", mood + ".ogg"])
Note that automatic interpolation doesn't work here, only in say and menu statements.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Jo'ogn
Veteran
Posts: 398
Joined: Sat Jul 12, 2008 1:31 pm
Projects: Kassiopeia [iVN]
Location: Deutschland
Contact:

extend?

#3 Post by Jo'ogn »

voice() doesn't seem to play lists of files.
Audio Plays: [original] The White Feathers Directive - [Star Wars] Through Flame and Shadow
Ren'Py: Kassiopeia [very interactive VN] work in progress - looking for proof reader english

yummy
Miko-Class Veteran
Posts: 733
Joined: Fri Jul 07, 2006 9:58 pm
Projects: Suna to Majo
Location: France
Contact:

Re: voice and string interpolation?

#4 Post by yummy »

After reading a little the documentation about the voice() function, it seems it only applies to one file.
So, no it does not play lists of files.

Gau_Veldt
Regular
Posts: 86
Joined: Tue Jun 10, 2008 8:22 pm
Location: Prince George, BC
Contact:

Re: voice and string interpolation?

#5 Post by Gau_Veldt »

PyTom wrote:Yes, the voice mechanism stops whatever's playing on the voice channel during each interaction. This is usually the right behavior, as you want (say) a thought to stop the currently playing voice when the user clicks ahead.

You can use the voice function to play computed voice. For example, you can do:

Code: Select all

     $ voice(["I_am.ogg", mood + ".ogg"])
Note that automatic interpolation doesn't work here, only in say and menu statements.
What about Python's % operator?

Code: Select all

$ voice(["I_am.ogg", "%s.ogg" % (mood)])

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: voice and string interpolation?

#6 Post by PyTom »

The use of the python string interpolation operator is allowed anywhere python is.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot]