Harlowe 3.1 Ambient Sound Effects

So I’m looking to have some ambient noises playing through several passages in my twine story using Harlowe 3.1. Say, a bustling city during a few different passages and a cave during a few other ones. The code that I’m currently looking at is the one shown below used in javascript:

var audio = document.createElement(“audio”);
audio.src = “URL to audio here”;
audio.loop = true;

However, this code will just play a singular sound throughout the entirety of the story, but I’d like it to play different noises for each scene, like I said. Is there anything I should add to it?

If you want to include Audio within a Harlowe based project then I strongly suggest you consider using ChapelR’s Harlowe Audio Library add-on, you will save yourself a lot of effort and grief.

1 Like

Thanks so much! Made my life a hell of a lot easier