Add music

How to add music in twine ?

Aside from using HTML Audio API or Web Audio API directly, which is not recommended unless you already know what you’re doing, what audio APIs are available depends on the story format.

So, story format?

1 Like

I’m sort of a Twine noob, but I’ve had great results adding music and sound effects with the built-in macros offered by Sugarcube.

1 Like

Here’s some examples of macros I’m using in Sugarcube. These are not all in the same passage, just indicative hopefully of how sound can be used:

<<cacheaudio "anger5" "media/desk6.mp3">>
<<cacheaudio "pager" "media/pager.mp3">>
<<waitforaudio>>

<<audio "waltzmoderato" volume 0 fadeto 0.70>><<audio "waltzmoderato" loop>>

<<if $ether eq false>><<audio ":playing" fadeout>><</if>>
<<if $ether neq true>><<audio "ethernight" volume 0 fadeto .3>><<set $ether = true>><</if>>

<<audio "ethernight" loop>><<audio "lobbyambience" fadeout>>\
<<audio 'ding' play>><<set $attention to true>>\

harlow 3.3.3

Then I’d recommend using the Harlowe Audio Library (HAL).

1 Like