How do I stop audio bleeding from one passage to another

Twine Version: Chapbook 1.2.3
[also choose a Story Format tag above]

Hello, I’ve just managed to figure out how to add audio to my chapbook story, but when I go to test run it, or publish it there seems to be a problem where the audio bleeds from one passage to another. For example if there is a sound of effect of a plane crash in one passage and the player clicks on a link to move to another passage, the current passage they are on will play its audio e.g. a bullet firing, but they can still here the explosion from the passage they just came from unless they wait for the audio to completely finish.

How can I stop this from happening?

Without seeing any of your code, I can only offer links to Chapbook audio reference material.

Essentially, you have 2 choices: stop the audio before proceeding to the next passage or stop the audio at the top of the next passage, before that passage is displayed.

The second link shows how to stop an ambient sound, but I think it should work for effects too.

2 Likes

Thanks for replying.

Here’s an example from my story:

​sound.effect.intro.url: “https://s3.ultimate-guitar.com/audio.com.audio/source/15/33/1794687388413315-1794687390808340.mp3?response-content-disposition=attachment%3B%20filename%3D"Daniel%20Intro.mp3"&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ROGQRDMARJQJJ35IUG5T%2F20240327%2Fus-west%2Fs3%2Faws4_request&X-Amz-Date=20240327T134817Z&X-Amz-SignedHeaders=host&X-Amz-Expires=518400&X-Amz-Signature=3b943c4649b26b828d14ef49106f693eac94ac5f76f4dce781bf493ecc53417b
sound.effect.intro.description: ‘Introduction’

{sound effect: ‘intro’}

and then on the next passage the code is as follows:

sound.effect.pop.url: “https://cdn.freesound.org/sounds/463/463395-c6eda054-d364-4dbb-b677-0bf12116d9f2?filename=463395__vilkas_sound__vs-pop_5.mp3
sound.effect.pop.description: ‘a pop’

{sound effect: ‘pop’}

when you say stop the audio - how exactly do I do that, I actually had a read of the github guidebook but couldn’t quite understand it. It seemed like it was saying that this problem exists, but it didn’t really offer a solution?

At the bottom of the link provided, it talks about manually controlling sound…

Basically, you set the playing property to true or false. This ability is stated to work on both ambient and effect sounds. There is a working example here for ambient sounds, but the same method should work for effects…

1 Like

i see what you mean, but it says once the effect finishes playing. What if a player has travelled a path before and so they which to skip certain passages which have a narrated voice-over, these sound effects are much longer and so if they skip ahead the sound bleeds into the other passages. How do you advise I can stop this from happening? In the twinery example you linked they had a physical button to turn the sound off, is this something i need to do for each and every passage? If so what is the code I can put in to do this, and is there a way to have a permanent button in the header or footer which toggles sound relative to the effect/ambient audio written for that specific passage?

@HAL9000 Thank you so much, i’ve finally understood the article, and that I need to define the previous passage’s effect as ‘false’ for playing in the code for the current passage to stop the bleeding - hopefully won’t run into anymore trouble.

1 Like

This is for when you start feeling more brave with Chapbook. :slight_smile:

Chapbook’s strength is simplicity, but that always comes with limitations. It does allow for extending the code, but requires you to be adventurous with programming. The following gives you the basis for making a link that can do other things, like set variables (or sound properties) while also going to a new passage…

However, Chapbook’s simplicity encourages you to go to a passage and then do something. Click to go to a passage and then do something else. Rinse and repeat.


There is a way to have a pure logic passage embedded in every passage behind the scenes by using the headers and footers in chapbook. Upon visiting a new passage, the embedded passage code will run again. This could run code to stop all effects audio from playing, in theory.

You could also use Twine’s built-in passage tags feature and “flag” passages that should do something unique, but all passages still have the same global logic passage embedded. Chapbook has ways of identifying the tags associated with a passage. It can get as crazy as you want it to get.


Anyway, I’m glad things are working now. :slight_smile:

1 Like

:sweat_smile: - think I may have already tried some of those things like a score counter in the header, I think if I have time for this project I may even trail input variables - thanks a bunch again!

1 Like