Page 1 of 1

Audio Duration Bar [solved]

Posted: Sat Oct 29, 2016 12:26 am
by Morhighan
I was wondering if it would be possible/not terribly difficult to add an audio duration bar for spoken lines in one of my games, so players will know when the voice actor is done talking. Some performers add pauses to the dialogue, which is good, but it may come off as confusing. I'm not entirely sure how to program this, to be honest, so I thought I'd come to the forum for help.

Something like the attached image perhaps?

Re: Audio Duration Bar

Posted: Sat Oct 29, 2016 1:04 am
by Kia
I think you can get the info about playing audio with https://www.renpy.org/doc/html/voice.ht ... voice_info
I'm sure there are more of these _get commands for audio channels, search the documentation

Re: Audio Duration Bar

Posted: Thu Nov 10, 2016 8:28 pm
by PyTom
You can probably use a bar with AudioPositionValue(channel='voice') to do this.

Re: Audio Duration Bar

Posted: Tue Dec 20, 2016 9:55 am
by Kaen
I tried to use AudioPositionValue() but the bar gets filled in a few seconds even though the audio has more than one minute duration.

Code: Select all

bar:
    value AudioPositionValue(channel='music')    
    xsize 500
    xmaximum 500
I also tried to use renpy.music.get_pos() and renpy.music.get_duration() but then the bar is instant filled at once.

Code: Select all

bar:
    value renpy.music.get_pos(channel='music')
    range renpy.music.get_duration(channel='music')
    xsize 500
    xmaximum 500
Help please!

Re: Audio Duration Bar

Posted: Tue Dec 20, 2016 11:27 am
by nyaatrap
AudioPositionValue() works no problem for me. There's nothign wrong on your code. So problem is different: bar style or music declaration.

BTW, renpy.music.get_pos(channel='music') won't work in this case, because it's only updated at interaction, not real time.

Re: Audio Duration Bar

Posted: Tue Dec 20, 2016 1:07 pm
by Kaen
nyaatrap, would you mind checking this test project?

I'm using the new GUI, no changes on styles.

Code: Select all

screen audio_duration():
    bar:
        value AudioPositionValue(channel='music')
        xalign 0.5
        yalign 0.5
        xsize 500
        xmaximum 500

label start:
    image bg black = "#000000"
    $ bgm_test = "test.mp3"

    scene bg black
    play music bgm_test
    #play music "test.mp3"
    call screen audio_duration

    return

Re: Audio Duration Bar

Posted: Wed Dec 21, 2016 8:52 am
by nyaatrap
Problem is mp3. Converting music into ogg solved problem.

Re: Audio Duration Bar

Posted: Wed Dec 21, 2016 1:54 pm
by Kaen
Many thanks nyaatrap ♡

Re: Audio Duration Bar

Posted: Wed Dec 28, 2016 6:34 pm
by Morhighan
Problem solved!

Re: Audio Duration Bar

Posted: Fri Apr 29, 2022 11:51 am
by ojgenius
Kaen wrote: Tue Dec 20, 2016 1:07 pm nyaatrap, would you mind checking this test project?

I'm using the new GUI, no changes on styles.

Code: Select all

screen audio_duration():
    bar:
        value AudioPositionValue(channel='music')
        xalign 0.5
        yalign 0.5
        xsize 500
        xmaximum 500

label start:
    image bg black = "#000000"
    $ bgm_test = "test.mp3"

    scene bg black
    play music bgm_test
    #play music "test.mp3"
    call screen audio_duration

    return
Big big newbie here! Sorry to come back to this so late. This works great! Any idea how to make this user adjustable? So I can see its duration but also adjust it as its playing? Thanks in advance!