Audio Duration Bar [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
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Audio Duration Bar [solved]

#1 Post 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?
Attachments
voicebar.PNG
Last edited by Morhighan on Sun Jan 15, 2017 1:22 pm, edited 1 time in total.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Audio Duration Bar

#2 Post 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

User avatar
PyTom
Ren'Py Creator
Posts: 16093
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: Audio Duration Bar

#3 Post by PyTom »

You can probably use a bar with AudioPositionValue(channel='voice') to do this.
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

User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Re: Audio Duration Bar

#4 Post 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!

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Audio Duration Bar

#5 Post 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.

User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Re: Audio Duration Bar

#6 Post 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
Attachments
Music Loop.zip
(6.69 MiB) Downloaded 55 times

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Audio Duration Bar

#7 Post by nyaatrap »

Problem is mp3. Converting music into ogg solved problem.

User avatar
Kaen
Regular
Posts: 148
Joined: Tue Oct 16, 2012 10:49 pm
Contact:

Re: Audio Duration Bar

#8 Post by Kaen »

Many thanks nyaatrap ♡

User avatar
Morhighan
Miko-Class Veteran
Posts: 975
Joined: Sun Jun 27, 2010 12:54 pm
Completed: AIdol, When Our Journey Ends, Forgotten Not Lost
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Re: Audio Duration Bar

#9 Post by Morhighan »

Problem solved!

ojgenius
Newbie
Posts: 2
Joined: Fri Apr 29, 2022 11:30 am
Contact:

Re: Audio Duration Bar

#10 Post 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!

Post Reply

Who is online

Users browsing this forum: No registered users