+1 vote
by (220 points)

I've yet to find any good documentation so I'm asking here.

I'm looking for a way to have:

  1. Background music that starts and doesn't stop (unless toggled to)
  2. Fades between tracks depending on the tag of the passage?
  3. Audio cues like beeping and booping depending on what choices you make

but I can't find anything, really, on how to achieve this in Harlowe, and I can't get on with Sugarcube at all. 

 

Is there a way of doing this?

1 Answer

0 votes
by (62.7k points)
edited by

Harlowe has no built in support for audio. You can: 

  1. Try to get on with SugarCube, which has built in audio support. It's not as complicated as it seems; any features you don't need or understand can safely be ignored. There's honestly little to lose here. 
  2. Attempt to use the HTML audio element to do what you want. Note that playing a looping track is fairly easy, but binding sound effects to events like clicking on links and such will require some JavaScript. Further note that the autoplay function you'll likely want to use is not supported on some devices (though this can be worked around, also with a bit of JS). Fading, volume control, playlists, etc will take some work to implement in this manner. 
  3. Use a third-party audio library like howler.js, which will require some comfort working in JavaScript, but might be easier than #2 depending on how much you need out of your audio system. If you need things like playlists, volume control, fades, etc and are going to stick with Harlowe, this is your best option. 

Without knowing how comfortable you are working with JavaScript and how concerned you are about certain features it's hard to make a specific recommendation. 

In general, I strongly recommend that if Harlowe doesn't support a feature you need, you move to a different story format. Harlowe is built in such a way as to make it extremely difficult to use custom JavaScript with, and even if SugarCube doesn't have the feature you want, at least you can build it (or we can help you do so) without having to hack it together. 

by (156k points)

RE: Point 2 & 3 @Chapel's reply

There are a number of threads on the old forum archive related to this subject, three of them being:

Is there a way to cache audio for harlowe 2.0
Playing audio in Harlowe (Twine 2.0)
Background Music in Harlowe

note: The above links are in no particular order and I suggest you fully read their contents, and of any others linked from them, before implementing a solution so that you are fully aware of what is needed and the possible restrictions in mobile devices (auto-play).

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...