How to allow sound effects to play when a defined character is speaking dialogue?

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
plulovi
Regular
Posts: 25
Joined: Sat Aug 31, 2019 9:42 pm
Projects: Hell's Phone Number
Contact:

How to allow sound effects to play when a defined character is speaking dialogue?

#1 Post by plulovi »

Hello. I've been having a bit of trouble adding sound effects.

For instance, when I have a code like this:

play sound "sound.ogg"

"Hello world"

return

Then the sound effect will work perfectly fine. However, when I have a code that looks like this:

play sound "sound.ogg"

e "Hello world"


return

The sound effect won't play at all. Is there a way to fix this? Thanks!

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: How to allow sound effects to play when a defined character is speaking dialogue?

#2 Post by isobellesophia »

Can you show the code?

For me, anything works, i did that as defined dialogue.

There might be something in your script.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
papillon
Arbiter of the Internets
Posts: 4107
Joined: Tue Aug 26, 2003 4:37 am
Completed: lots; see website!
Projects: something mysterious involving yuri, usually
Organization: Hanako Games
Tumblr: hanakogames
Contact:

Re: How to allow sound effects to play when a defined character is speaking dialogue?

#3 Post by papillon »

Sound effects normally play while characters are speaking. No special code is needed to cause that.

Usually a sound failing to play means that either you have the filename wrong OR some other sound is playing which is overriding it. (Or your sound is off.)

Do you have a typing-text sound effect set up that makes a noise while dialog appears?

User avatar
isobellesophia
Miko-Class Veteran
Posts: 979
Joined: Mon Jan 07, 2019 2:55 am
Completed: None
Projects: Maddox and Friends! (AI Teacher friend), Friendly Universities! (Soon)
Organization: Friendly Teachers series
Deviantart: SophBelle
itch: Child Creation
Location: Philippines, Mindanao
Contact:

Re: How to allow sound effects to play when a defined character is speaking dialogue?

#4 Post by isobellesophia »

I think it will obviously cause a error from the start when putting it in a wrong file, i used a sfx folder to put my sound effects there,


You should make a folder for it, and then list it like this.

Code: Select all

play sound "sfx/sound.ogg"
OR, as papillon said, you may used a file that wont play when opening that file, which is only need an mp3 or ogg file that can be played. Like a icon of blue note can be played, while the empty white file wont.

You can use Audacity, and then export it in ogg file.
I am a friendly user, please respect and have a good day.


Image

Image


User avatar
plulovi
Regular
Posts: 25
Joined: Sat Aug 31, 2019 9:42 pm
Projects: Hell's Phone Number
Contact:

Re: How to allow sound effects to play when a defined character is speaking dialogue?

#5 Post by plulovi »

Ah yeah, I figured it out. It's because I have each character with a callback sound when their dialogue is typed out. But I managed to fix the problem by defining another audio channel. I just did:
init python:
renpy.music.register_channel("sfx", True)

and when I needed to use the sound:

e "insert sentence here"

play sfx "crash_sfx.ogg" noloop


Thanks for replying though! I really appreciate it. ^_^

Post Reply

Who is online

Users browsing this forum: Exiscoming, Google [Bot]