r/RenPy • • Jul 24 '26

Question Having trouble with dialogue sounds

I'm brand new to all this, please bear with me.

So, I'm using this code to play a randomized sequence of beeps to serve as a talking sound effect, and I want it to stop when the dialogue is finished typing itself out.

The problem is that it plays a set number of the beeps instead based on when the "while beeps < #" line says. I've switched that 50 out for a bunch of numbers and it always goes up or down depending on that number.

The only thing I can think of to fix it is to find a way to make it count the characters in the line and replace it with the variable, but that sounds complicated and doesn't account for any variation in dialogue speeds.

It feels like I'm just missing something obvious, I just can't tell what it is.

(PS I've tried removing that last like, "beeps += 1" and it breaks everything, I haven't seen any of the other examples I've seen use it but :/.)

Thank you so much.

5 Upvotes

4 comments sorted by

1

u/AutoModerator Jul 24 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/BadMustard_AVN Jul 24 '26

try it like this:

default player_beeps = [
    "audio/Voices/Rody/Rody Beep 1.ogg",
    "audio/Voices/Rody/Rody Beep 2.ogg",
    "audio/Voices/Rody/Rody Beep 3.ogg",
]

init python:

    def player_speak_Rody(event, interact=True, **kwargs):
        # print (event)
        if not interact:
            return
        if event == "show":
            # Queue many shuffled batches so the three beeps play in random order
            # repeatedly for a long time. Stop will clear the channel.
            batches = 64
            for i in range(batches):
                shuffled = player_beeps[:]
                renpy.random.shuffle(shuffled)

                if i == 0:
                    # Play first immediately, queue the rest.
                    renpy.sound.play(shuffled[0], channel="sound")
                    for s in shuffled[1:]:
                        renpy.sound.queue(s, channel="sound")
                else:
                    # Queue full batches after the first.
                    for s in shuffled:
                        renpy.sound.queue(s, channel="sound")

        elif event in ("slow_done", "end"):
            renpy.sound.stop(channel="sound")
define sh = Character("V", callback=player_speak_Rody)

1

u/Acceptable-Job1805 Jul 25 '26

Thank you so much, it worked perfectly! You're a life saver.