Adding sound to text like a typewritter

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
emanueljoab
Newbie
Posts: 5
Joined: Sat Jun 17, 2017 6:47 pm
Contact:

Adding sound to text like a typewritter

#1 Post by emanueljoab »

I'm noob, lol.
I'm trying to make a beep every time a character is show on a dialogue. So I put the code on the top of script.rpy just like shown here and here.

However, it doesn't beep while text appears...

It is a 3 seconds .mp3 file...

Can someone please help me? Thank you very much.

User avatar
papiersam
Veteran
Posts: 231
Joined: Fri Aug 12, 2016 2:24 pm
Completed: Gem Hunt Beta, 1/Probably, Animunch
Projects: The Panda Who Dreamed
Contact:

Re: Adding sound to text like a typewritter

#2 Post by papiersam »

Most likely cause is that there's a delay/silence in the beginning of the mp3 file.

...I think.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Adding sound to text like a typewritter

#3 Post by Imperf3kt »

I would not suggest .mp3 for short audio. Use .wav or .ogg instead (but really best is .wav) due to two reasons:
.mp3 is not free
.mp3 is not optimised for instantaneous playback (it is compressed and needs to be decompressed first)

.wav will not experience the lag if you use Linear PCM
.ogg is less prone to playback delay and also royalty-free

The difference between a 160kbps lame mp3 and 160kbps ogg vorbis is practically non-existent. This is called "transparent" - meaning to the human ear, both files sound identical.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

emanueljoab
Newbie
Posts: 5
Joined: Sat Jun 17, 2017 6:47 pm
Contact:

Re: Adding sound to text like a typewritter

#4 Post by emanueljoab »

Well, I make it to work because I didn't set a character to say. lol I found Renpy would set as a narrator whatever.
Imperf3kt wrote:I would not suggest .mp3 for short audio. Use .wav or .ogg instead (but really best is .wav) due to two reasons:
.mp3 is not free
.mp3 is not optimised for instantaneous playback (it is compressed and needs to be decompressed first)

.wav will not experience the lag if you use Linear PCM
.ogg is less prone to playback delay and also royalty-free

The difference between a 160kbps lame mp3 and 160kbps ogg vorbis is practically non-existent. This is called "transparent" - meaning to the human ear, both files sound identical.
I'm going to use .ogg because FL Studio seems to not have support for exporting PCM.

Thank you.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Adding sound to text like a typewritter

#5 Post by Imperf3kt »

You can export to pcm using FLstudio, infact on my version (FLstudio 10 free/demo) .ogg needs to be added and is not included by default.

To use LPCM, choose the output to WAV option.
In my copy, at least, exporting to WAV is the program's default.

In any case, .ogg is perfectly suitable and smaller than lossless 16bit LPCM WAV
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

emanueljoab
Newbie
Posts: 5
Joined: Sat Jun 17, 2017 6:47 pm
Contact:

Re: Adding sound to text like a typewritter

#6 Post by emanueljoab »

Interesting. Anyway, I have another question.

Can Renpy make a bleep for every letter entered?

User avatar
chapscher
Newbie
Posts: 11
Joined: Sun May 07, 2017 12:05 am
Tumblr: chapscher
Contact:

Re: Adding sound to text like a typewritter

#7 Post by chapscher »

Are you asking how to make a chyron or a Phoenix Wright-style beeping/chirping? I got you covered
(It drove me nuts finding out how to do it and I'm still not exactly sure how it works, but here's what I have)

Code: Select all

init python:
    def callback(event, **kwargs):
        if event == "show":
            renpy.music.play("type.wav", channel="sound", loop=True)
        elif event == "slow_done" or event == "end":
            renpy.music.stop(channel="sound")
$ loc = Character(what_font="cour.ttf", callback=callback)
Add your sound (type.wav) and, if you want to create a chyron-type thing this is how you set a different font for it (cour.ttf). I have this set up so the typing sound only occurs when the "loc" (location) 'character' speaks. If you want to apply this to more characters I'm sure this can be modified.

Post Reply

Who is online

Users browsing this forum: AWizardWithWords, Google [Bot]