Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to add sound to !.42 SugarCane?

Hello again guys I was just curious how does one go about adding sound such as an mp3 file to their twine story?

Additionally, is it possible to have one track repeat throughout the length of the story and only stop when invoked to do so?
Importing an image was pretty simple to figure out but something tells me sound maybe a bit more complex.
Thanks!

Comments

  • https://www.glorioustrainwrecks.com/node/5061

    Suggestion: instead of patching Sugarcube with that script from 2013, install SugarCube. It has built-in audio functionality.
  • Thanks, do I just download that and type in the syntax with my respective file?

    About the sugarcube, I've finished writing most of the functionality into my story. Would the sugarcane 1.42 syntax such as if statements and logic comparisons transfer over to sugarcube or would I have to rewrite them?
  • Would the sugarcane 1.42 syntax such as if statements and logic comparisons transfer over to sugarcube
    Most of the core functionality (like links type, <<if>>/<<set>> macro, etc) is the same in the Twine 1.x story formats so switching to SugarCube should be fairly painless.
  • I'm trying to find help with this exact same issue. I have downloaded SugarCube but I have no idea how to actually implement it. Similar problem with the script over at Glorious Train Wrecks, I added it to my story, but it doesn't tell you how to actually then use it to add audio (do you need to host it? Title the file a certain way? Locate the sound file in a particular place?).

    I'm putting together something in Twine at the moment for a uni project and I was going to add some background audio to one of the passages, I can cut it out but it'd be a shame to do so if adding audio isn't actually that complicated.
  • Did you following the How do I install SugarCube? instructions on the Twine 1 wiki?
    The only change to those instructions I would suggest is to download SugarCube 2 instead.

    You don't need to add the Glorious Train Wrecks script to SugarCube because it has it's own Audio macros built in. (v2 docs and v1 docs)

    In regards to where to place your sound files, that depends on if you are going to host your story HTML file on a web-server or if you are going to put your story HTML file on a file download site like Google Docs or Mega.
    If you are hosting then you will need to also host your sound files on the same web-server. If you are going to use file download site then you could place your sound files in the same folder as your story HTML file and use a tool like ZIP to create an archive file containing your story html file as well as your sound files.
  • Well, I got SugarCube in but I'm not able to get much further than that. I don't need to host the story anywhere so that's not a problem but even putting the sound file in the same folder with my Twine doc doesn't seem to work.

    I put this into my StoryInit: <<cacheaudio "boom" "media/audio/explosion.mp3">> as told – switching out that info for the file I'm using and it's location but...nothing but an error message.
    I'm sure I'm missing something obvious but the truth is I'm just not that computer literate, so the things I'm being asked to do often just don't make sense to me.
  • Ok I have an ugly fudge of a fix for the moment, in that I'm just dumping the absolute path of the sound file into the cache. This gets the track to play though only if I run the story on my computer...thankfully this is for a university project so I can get away with doing exactly that this time.
  • procrasty wrote: »
    […] I don't need to host the story anywhere so that's not a problem but even putting the sound file in the same folder with my Twine doc doesn't seem to work.

    I put this into my StoryInit: <<cacheaudio "boom" "media/audio/explosion.mp3">> as told – switching out that info for the file I'm using and it's location but...nothing but an error message.
    Your relative path was probably incorrect (as evidenced by it working when you used an absolute path). To use relative paths, if you place the media files relative to the compiled HTML file, the specified paths must be relative to the compiled HTML file.

    As an example, for a relative path like the following:
    <<cacheaudio "boom" "media/audio/explosion.mp3">>
    
    Your directory structure, relative to the compiled HTML file, should look something like this:
    compiled_story.html
    media/
    	audio/
    		explosion.mp3
    
  • I try to keep file structures simple for that reason, so you might want to consider removing the media folder and just sticking the audio folder in the parent directly.

    Besides it's really annoying typing out long structures whenever you want to input a file.
Sign In or Register to comment.