Stopping a sound played on the 'audio' channel

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
SethRiley
Regular
Posts: 35
Joined: Sat Mar 18, 2017 3:27 pm
Contact:

Stopping a sound played on the 'audio' channel

#1 Post by SethRiley »

Greetings (^_^)/

I have a sound effect, which I would like to have looped throughout a portion of the story. Since sounds on the 'sound' channel can't be looped, and I don't want to use the 'music' or 'voice' channels for this because they're in use, this sound effect is triggered with:

Code: Select all

play audio "sfx/02_3A.ogg" loop
This makes the sound effect loop seamlessly as desired.

However, how does one stop the sound afterwards? Ive tried "stop audio" as well as "stop sound", but the sound effect keeps playing.

The sound effect is affected by the 'sound' volume slider though, so Ren'Py does seem to treat it as a sound effect.

Does any one know of a way to stop a sound which is triggered that way?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
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: Stopping a sound played on the 'audio' channel

#2 Post by PyTom »

The audio channels are fire and forget. If you want something you can stop, use 'play sound' rather than 'play audio', then use 'stop audio'.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
Saltome
Veteran
Posts: 244
Joined: Sun Oct 26, 2014 1:07 pm
Deviantart: saltome
Contact:

Re: Stopping a sound played on the 'audio' channel

#3 Post by Saltome »

Hmm... Maybe you can just define your own audio channel, and play it on there.
https://www.renpy.org/doc/html/audio.ht ... er_channel
Deviant Art: Image
Discord: saltome
Itch: Phoenix Start

duck-and-wolf
Regular
Posts: 47
Joined: Thu Aug 29, 2019 6:20 pm
Completed: Head of the Class
Organization: Duck & Wolf
Contact:

Re: Stopping a sound played on the 'audio' channel

#4 Post by duck-and-wolf »

What if you want to stop the currently playing activate_sound or hover_sound?

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Stopping a sound played on the 'audio' channel

#5 Post by Remix »

You could move those sounds to another channel (maybe one you created yourself) that can be stopped by changing the config:

Code: Select all

define config.play_channel = "audio"

# The name of the audio channel used by renpy.play(), hover_sound, and activate_sound.
As mentioned though, the audio channel will complete any file played on it and as such is generally for short form sounds rather than long clips.
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Bing [Bot]