Sound effect over music using Harlowe Audio Library?

Twine Version: 2
Harlowe: 3

Hey all! I’m using HAL to add music to my Twine game so far, but I was thinking it might also be fun to have a little ‘beep’ or something that plays when you click on certain elements.

I can’t QUITE get it to work with HAL, and I’m assuming it’s because there’s no way to play a sound ‘on top’ of the current sound without it stopping the currently-playing track?

I’m using this to transition between songs:

(unless: (track: 'theme', 'isplaying'))[
    (group: 'playing', 'stop')
    (track: 'theme', 'loop', true)
    (track: 'theme', 'play')
]

and I know there’s an “<audio src=” method to play a song when clicking a link, but would that stop my currently playing track?

Thanks so much!

I have no experience with HAL, but I did poke around the documentation. I’m surprised it doesn’t have a section about playing sounds over background audio, but nothing really leads me to believe it simply won’t play an audio file over top of another that’s already playing. It seems like you’d only want to check if a track is playing if you want to stop and replace it with another, like changing the radio station.

I take it that you have background music playing in a passage already, but the example HAL code doesn’t work for you?

{
(link-repeat: 'Honk the horn.')[
    (track: 'beep', 'play')
]
}

https://twinelab.net/harlowe-audio/#/?id=playing-sounds-with-links

I believe @Chapel is the person behind HAL. Perhaps they might shed some light on this.

Tracks are separate media elements and can be played simultaneously.

1 Like