Howdy, Stranger!

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

Where do I upload sound?

Using Sugarcube online.

I found this for adding audio to a passage, but the poster doesn't state if this is for Sugarcube.
<audio autoplay>
<source src="[path edited to make it shorter]thunder.mp3" type="audio/mpeg" />
</audio>

What they also don't state is where the audio needs to be uploaded. Is it just to any host or do I upload it to Twine or something?

Also, if the above is not the code for adding audio, could someone supply it, please?

TiA

Comments

  • As to where to upload your audio files, any host which allows files to be remotely accessed should do. If you plan to publish your project on a generic web host, you can probably place your audio there as well. If, on the other hand, you plan on publishing your project to one of the IF web sites, then you may need to find a different host for your audio (some IF sites allow supplemental files, some don't; I don't recall which is which).


    Don't use the <audio> element. Read the documentation for the SugarCube v1.x audio macros. They wrap the <audio> element API, smoothing over several browser compatibility issues and enabling more features.

    As a small example: (still, read the docs)
    :: StoryInit
    /*
    	Cache a single track with two sources.
    
    	Tip: Use multiple sources, if possible, for best browser compatibility.
    	When creating/choosing sources, prefer: MP3 ⇒ OGG ⇒ any other format.
    */
    <<cacheaudio "bgm_space" "media/audio/space_quest.mp3" "media/audio/space_quest.ogg">>
    
    :: Some passage in which you want to play the track "bgm_space"
    /*
    	Simply play the track, no frills.
    */
    <<audio "bgm_space" play>>
    
  • edited December 2015
    I've searched for free audio hosts, but once I've uploaded it I only get a link to the site where the file is held. I don't get a link to the mp3 itself??

    I've tried to read the audio macros, but it all makes little or no sense to me.
  • Right, I found a host that allows hotlinking, but due to heavy usage they're only catering for premium accounts at the moment.

    Anyway, by brother says he'll host it for me.

    Thanks for the code.
  • Jud_Casper wrote: »
    I've tried to read the audio macros, but it all makes little or no sense to me.
    What are you having trouble with?
  • edited December 2015
    I
    Jud_Casper wrote: »
    I've tried to read the audio macros, but it all makes little or no sense to me.
    What are you having trouble with?
    I think it's more me than the instructions. I've always had a blind spot when it comes to following instructions. I think I know what to do, once I get the audio file hosted, from your own instructions, but the ones on the macro page are a little overwhelming.

    If I was to be specific, I think the tutorials (like most tutorials) assume too much. For instance, when we are presented with blocks of code, it's not explained properly one, where this code goes, and two, what parts of the stuff in code tags is actual code or brief lines just for clarification.

    People like me need idiot sheets. Step by step instructions.

    1. Create a new passage and called it StoryInit
    2. In the main body of the passage, add this code:
    <code blah blah blah>
    
    3. Where it says "media/thunder.mp3" you need to add your own file name for your hosted audio file.

    Etc, etc, etc.

    Your own instructions, for instance, say that to play an audio file on a specific passage I use:
    <<audio "bgm_space" play>>
    
    But there's no mp3 here, so how does it call it? Or do you mean I replace "bgm_space" with my file name, which will be something like "..../media/wave.mp3"?

  • Okay, my brother has hosted the file and I stumbled my way through to get it working. It took me a while, but I eventuallyworked out from your instructions that I needed to place the file in StoryInit and then call it in a passage with "bgm_space"

    Just need to look at fading it out, etc now, but I think I can get that from the macros page.

    Ta again.
  • edited December 2015
    The clip is around 30 seconds long, which lasts for two or three passage, depending on how quickly you play through them, so I added a fade out, but the fade is so quick it only plays for about 5 seconds.

    The sound is waves on a shore (as this is where the player starts). I was hoping the fade out would simulate the player moving away from the shoreline.

    Any way to change the graduation of the fade?

    It appears not. For now I've added the file at slightly lower volumes in subsequent passages. Works quite nicely, but I think a much longer soundbite is the proper answer.
  • Five seconds is the default fade duration, yes. And no, at present, there's no way to change that. I'll put that on the TODO list.

    I'm not exactly keen on backporting that to v1, now that v2 is out, but I suppose it wouldn't hurt.
  • I'm not exactly keen on backporting that to v1, now that v2 is out, but I suppose it wouldn't hurt.
    But I'm using v2. Sugarcube v1 on Twine v2, to be precise.

  • I'm pretty sure that TheMadExile was talking about the Sugarcube version, not the Twine version.
  • edited December 2015
    Indeed. prof_yaffle is correct. I meant SugarCube v1 vs. v2.
  • edited December 2015
    Oh. I presumed it was Twine that contained all the coding gubbins. I thought the formats were just skins?
  • edited December 2015
    Just the reverse, actually. Twine is simply the IDE/compiler. The story formats themselves are the engines your project runs upon—they define the code, the macros, the markup, etc.
  • Just as an FYI. I'll probably be adding a new action, fadeoverto, which will take two arguments, the duration of the fade (in seconds) and the target volume. And I will be backporting it to SugarCube v1.x.
  • Just as an FYI. I'll probably be adding a new action, fadeoverto, which will take two arguments, the duration of the fade (in seconds) and the target volume. And I will be backporting it to SugarCube v1.x.
    Great stuff. Control of the fade out speed would be very welcome.

Sign In or Register to comment.