Wed, 07/02/2014 - 05:40 by L | Sun, 09/28/2014 - 22:02 by L | ||
---|---|---|---|
< previous diff | next diff > | ||
Changes to Body | |||
Line 37 | Line 37 | ||
There's a lot that can be done to expand on this. Something I might add is a way to bind looping sounds to a specific passage tag. So, you could perhaps write <<tagsound "trees" "Howling_Monkeys.mp3">> and then give a passage a tag of "trees", and it will keep looping "Howling_Monkeys.mp3" if you're at such a passage, and stop it when you leave. Also on the list of possibilities: support for base64-encoded sounds (which no one except me will ever use). | There's a lot that can be done to expand on this. Something I might add is a way to bind looping sounds to a specific passage tag. So, you could perhaps write <<tagsound "trees" "Howling_Monkeys.mp3">> and then give a passage a tag of "trees", and it will keep looping "Howling_Monkeys.mp3" if you're at such a passage, and stop it when you leave. Also on the list of possibilities: support for base64-encoded sounds (which no one except me will ever use). | ||
+ | |||
+ | <b>License:</b> | ||
+ | |||
+ | Regard this script as <a href="http://creativecommons.org/publicdomain/zero/1.0/">public domain using CC0</a>. I don't really care for attribution - if you're using Twine, you're already running code I wrote. It's welcome if you want, but entirely optional. | ||
<b>Version history:</b> | <b>Version history:</b> | ||
[list] | [list] | ||
+ | [*]29-9-14 - Added CC0 "license". | ||
[*]29-9-13 - Fixed bug where <<stopallsound>> would crash if one of your sounds wasn't loaded correctly (+ maybe other situations). | [*]29-9-13 - Fixed bug where <<stopallsound>> would crash if one of your sounds wasn't loaded correctly (+ maybe other situations). | ||
[*]4-3-13 - Added <<fadeinsound>> and <<fadeoutsound>>. 1.1.1 edit: No longer force-restarts or force-starts music that's already looping/stopped. | [*]4-3-13 - Added <<fadeinsound>> and <<fadeoutsound>>. 1.1.1 edit: No longer force-restarts or force-starts music that's already looping/stopped. |
Here's version 1.1.1 of some Twine macros to play sound files with HTML5 audio.
http://www.glorioustrainwrecks.com/files/TwineMacros-SoundMacros-1.1.2.txt
These macros accept either strings or string variables as their first argument. I recommend you set the filenames to specific variables and then use those as arguments to the macros.
<<playsound "carolofthebells.mp3" >>
plays the file "carolofthebells.mp3" from the start.
<<loopsound $heartbeat >>
starts playing $heartbeat, over and over. Note: currently browsers are not that good at looping audio seamlessly - brief silences between loops may occur.
<<fadeinsound $heartbeat >>
is identical to loopsound, but fades in the sound over 2 seconds.
<<unloopsound $heartbeat >>
makes $heartbeat no longer repeat when it finishes.
<<stopsound "birds.ogg" >>
stops playing "birds.ogg". When <<playsound "birds.ogg" >> is used again, it will start from the beginning.
<<fadeoutsound "birds.ogg" >>
is identical to stopsound, but fades out the sound over 2 seconds.
<<pausesound "trees.ogg" >>
pauses "trees.ogg" at its current location. Use <<playsound "trees.ogg" >> to resume it.
<<stopallsound>>
stops all the sounds.
Important instructions:
MP3 | O | ? | ? | O | O |
OGG | O | O | O | X | X |
There's a lot that can be done to expand on this. Something I might add is a way to bind looping sounds to a specific passage tag. So, you could perhaps write <<tagsound "trees" "Howling_Monkeys.mp3">> and then give a passage a tag of "trees", and it will keep looping "Howling_Monkeys.mp3" if you're at such a passage, and stop it when you leave. Also on the list of possibilities: support for base64-encoded sounds (which no one except me will ever use).
License:
Regard this script as public domain using CC0. I don't really care for attribution - if you're using Twine, you're already running code I wrote. It's welcome if you want, but entirely optional.
Version history:
Attachment | Size |
---|---|
TwineMacros-SoundMacros-1.1.2.txt | 3.36 KB |