hover/activate_sound delayed? (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:

hover/activate_sound delayed? (solved)

#1 Post by Jo'ogn »

Getting more and more an understanding of how to customise the GUI I added style.mm_button.hover_sound and style.mm_button.activate_sound.

However the sounds are triggered delayed - I estimate by about 200 to 400ms.

Is this a general Ren'Py 6.6.2 performance issue (my PC runs XP on a Core Duo @3,2GHz), or are the triggers intentionally delayed (in case a person hovers quickly over all the buttons)?


While we are at it. When I only set a hover_sound and no(!) activate_sound, the GUI seemingly triggers a hover_sound on clicking (activating) a main menu entry e.g. "Start Game".
Last edited by Jo'ogn on Fri Jul 18, 2008 3:38 pm, 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: hover/activate_sound delayed?

#2 Post by PyTom »

Jo'ogn wrote:However the sounds are triggered delayed - I estimate by about 200 to 400ms.

Is this a general Ren'Py 6.6.2 performance issue (my PC runs XP on a Core Duo @3,2GHz), or are the triggers intentionally delayed (in case a person hovers quickly over all the buttons)?
It's probably a general performance issue, but it shouldn't be that bad. Audio delays should be more like 50-100ms. Hm... what sample rate is the sound at? For best results, it should be at 44100 hz.
While we are at it. When I only set a hover_sound and no(!) activate_sound, the GUI seemingly triggers a hover_sound on clicking (activating) a main menu entry e.g. "Start Game".
Ren'Py is behaving correctly, if counter-intuitively. The activate_* properties are taken from the hover_* properties, unless an activate_* property is set. This is almost always the correct thing to do, but not in this case. You want to set activate_sound to None manually:

Code: Select all

init python:
    style.button.hover_sound = "foo.wav"
    style.button.activate_sound = None
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:

Re: hover/activate_sound delayed?

#3 Post by Jo'ogn »

Thank you.

I am aware. I use 44,1kHz ogg. 48kHz resulted in random clicks.

Hm, I tried a shorter percussive SFX and now I get the delays you mention. (The former sound had a slower attack envelope, seemingly creating a virtually longer delay). But still, for activating a button the sound practically plays when the next screen is already there, which can give the impression that the sound does not relate to the click.


Is it possible to fine tune the behaviour of config.main_menu_music = "music.ogg" when leaving the main menu? On which channel is this music?

My game practically starts with a sound and I want the main menu music to fade out while the in-game sound starts - rather than cut off the music before the in-game sound starts.
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: hover/activate_sound delayed?

#4 Post by PyTom »

It's played on the default music channel: 7.

Your best bet is to just rely on the fact that it's playing even as the game starts. So start the game with something like:

Code: Select all

play music "mymusic.ogg" fadeout 1
or something like that.

A problem is that Ren'Py is generally faster than the sound buffer delays. I'm not sure how to fix that, without radically rewriting the sound handling code. (I could shrink the sample buffer size, but that would lead to problems for people with slower machines.)
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:

Re: hover/activate_sound delayed?

#5 Post by Jo'ogn »

My best guess was that's on channel 7. Wouldn't I have edited the wrong script file just now I would have figured that before asking =_=; So what I am doing now is fading out music on ch=7 and fading in my looped in-game sound on ch=6. Works exactly the way I want it to. Thank you.


Concerning the sound buffer, I can insert short pauses after my menus... It's a work around. Other than in VNs I have lots of user interaction, so it's quite obvious that the sounds lag behind the screen rendering.
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

Post Reply

Who is online

Users browsing this forum: Bing [Bot]