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: 952
Joined: Sun Jun 27, 2010 12:54 pm
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Audio Duration Bar [solved]

#1 Post by Morhighan » Sat Oct 29, 2016 12:26 am

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
Miko-Class Veteran
Posts: 924
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Skype: KiaAzad
Contact:

Re: Audio Duration Bar

#2 Post by Kia » Sat Oct 29, 2016 1:04 am

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: 15497
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 » Thu Nov 10, 2016 8:28 pm

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
"Silly and fun things are important." - Elon Musk
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 » Tue Dec 20, 2016 9:55 am

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 » Tue Dec 20, 2016 11:27 am

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 » 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
Attachments
Music Loop.zip
(6.69 MiB) Downloaded 16 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 » Wed Dec 21, 2016 8:52 am

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 » Wed Dec 21, 2016 1:54 pm

Many thanks nyaatrap ♡

User avatar
Morhighan
Miko-Class Veteran
Posts: 952
Joined: Sun Jun 27, 2010 12:54 pm
Organization: MysteryCorgi
Tumblr: MysteryCorgi
Deviantart: MysteryCorgi
Soundcloud: MysteryCorgi
itch: MysteryCorgi
Location: USA
Contact:

Re: Audio Duration Bar

#9 Post by Morhighan » Wed Dec 28, 2016 6:34 pm

Problem solved!

Post Reply

Who is online

Users browsing this forum: hell_oh_world