Sound effect while typing?
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.
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.
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Sound effect while typing?
So...I'm curious if this is possible. I know that there is this (which I'm assuming is similar to my idea) https://www.renpy.org/wiki/renpy/FAQ#Ho ... _Wright.3F
Can I have a sound playing while someone is typing into an input? And this is based off of the click-to-type sort of input like the example in my signature. But I only want it to play sound as long as the person is pressing keys..
Can I have a sound playing while someone is typing into an input? And this is based off of the click-to-type sort of input like the example in my signature. But I only want it to play sound as long as the person is pressing keys..
Re: Sound effect while typing?
namastaii wrote:So...I'm curious if this is possible. I know that there is this (which I'm assuming is similar to my idea) https://www.renpy.org/wiki/renpy/FAQ#Ho ... _Wright.3F
Can I have a sound playing while someone is typing into an input? And this is based off of the click-to-type sort of input like the example in my signature. But I only want it to play sound as long as the person is pressing keys..
Code: Select all
changed
A python function that is called with what the user has typed, when the string changes.- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: Sound effect while typing?
Uh...how exactly do I implement that though? The only way I know how to use 'changed' is to tell it to do a function in which it's already using the name change function. Do I have to create a python function to play a sound and while it do both changed actions?
Re: Sound effect while typing?
I imagine it would look something like:namastaii wrote:Uh...how exactly do I implement that though? The only way I know how to use 'changed' is to tell it to do a function in which it's already using the name change function. Do I have to create a python function to play a sound and while it do both changed actions?
In init python:
Code: Select all
def my_func():
renpy.music.play("my_type_soundbyte.oog", channel="audio")Code: Select all
input(*bla bla bla, changed=my_func)- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: Sound effect while typing?
I guess my main concern is can I have two changed's lol or do I just add the play audio to the change text function I have created? If I do that, then I'll have to do it for every function but oh well that's fine. I think I'm going to try that.
update: yes this is the best way thanks
update: yes this is the best way thanks
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: Sound effect while typing?
Sorry, one more thing if you happen to know... >.<
Is there a correct way to do something like this?
Is there a correct way to do something like this?
Code: Select all
renpy.music.play(renpy.random.choice(['sounds/writing1.mp3','sounds/writing2.mp3']), channel="audio")Re: Sound effect while typing?
I'd expect your code to just work? What goes wrong with it?
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: Sound effect while typing?
Oh...I forgot that this was something that needed to run before the game ran so once I opened it back up instead of refreshing it, it worked.
- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: Sound effect while typing?
Though I wish there was an easy solution to make an erasing sound if the person backspaces the text. I already know that's going to be far more complicated. But it'd be nice.
Re: Sound effect while typing?
This isn't something I can answer without testing, give me 10 mins...namastaii wrote:Though I wish there was an easy solution to make an erasing sound if the person backspaces the text. I already know that's going to be far more complicated. But it'd be nice.
Re: Sound effect while typing?
My apologies for supremely sh!tty code but it's very late
It should work and it should also be safe (8 is also PyGame's backspace index so it shouldn't be bound to anything else):
Bind the function to your input screen statement and see if it does anything useful... I only tested it through raising Exceptions. There is a way to make fail-safe but this should work fine. And there is prolly a cleaner way to get the same done, I just can't figure out what that is 
Code: Select all
init python:
def my_func(what):
if renpy.display.interface.last_event.__dict__.get("key", None) == 8:
# play delete sound...
else:
# play typing sound...- namastaii
- Eileen-Class Veteran
- Posts: 1350
- Joined: Mon Feb 02, 2015 8:35 pm
- Projects: Template Maker for Ren'Py, What Life
- Github: lunalucid
- Skype: Discord: lunalucid#1991
- Soundcloud: LunaLucidMusic
- itch: lunalucid
- Location: USA
- Contact:
Re: Sound effect while typing?
Oh wow. I didn't think it'd be something so specific. I was thinking you'd have to maybe set up a variable that counts the characters of input and once that variable becomes less then it plays a different sound or something haha
Thanks a lot, really:) I can't wait to try it out.
Thanks a lot, really:) I can't wait to try it out.
Re: Sound effect while typing?
Yeah, that would work too, maybe even through InputValue. But you prolly would not be able to distinguish between backspace and delete keys.namastaii wrote:I was thinking you'd have to maybe set up a variable that counts the characters of input and once that variable becomes less then it plays a different sound or something haha.
There are usually multiple ways to get something done in Ren'Py...
-
bloobeary
- Regular
- Posts: 36
- Joined: Fri Oct 04, 2019 3:02 pm
- Deviantart: bloobeary
- Soundcloud: user-212448702
- Contact:
Re: Sound effect while typing?
Sorry to drag out an old thread, but I've been attempting to implement this, and I cannot get it to work at all. The instructions given are quite vague, and trying to follow them has proven impossible. Can someone please walk me through how you set this sort of thing up?
I would like a random typing keystrike sound to play as the player types their name in at the start of the game.
I've got this bit of code in the init block before the label start:
But I have no idea where to put the...
...in the screens.rpy
"bla bla bla" isn't really that helpful for nailing down exactly where this is supposed to go.
I tried sticking it in the..
like so:
...but got nothing. Oddly, it didn't error out on me either. It just didn't provide typing noises on input.
I would like a random typing keystrike sound to play as the player types their name in at the start of the game.
I've got this bit of code in the init block before the label start:
Code: Select all
init python:
def my_func():
renpy.music.play(renpy.random.choice(['sounds/typing1.wav','sounds/typing2.wav','sounds/typing3.wav']), channel="sound")Code: Select all
input(*bla bla bla, changed=my_func)"bla bla bla" isn't really that helpful for nailing down exactly where this is supposed to go.
I tried sticking it in the..
Code: Select all
screen input(prompt):Code: Select all
screen input(prompt, changed=my_func):Who is online
Users browsing this forum: Bing [Bot], Google [Bot]
