Hello,
I was wondering if there was anyway to sequence audio so the audio file plays not only once you get to a certain passage (which I know how to do) but also when the previous audio file is finished?
I'm trying to put music to it but i need it to gradually build over time as the player progresses.
Any ideas?
Im using sugarcube in twine 2.
Cheers
Comments
To further explain:
On the first passage, i have a song set to loop.
On the second passage(and only on the second passage), i want to change to another song, but only after the first has finished.
Same for the third and forth passages...
The reason I don't just have a bunch of songs lined up in a playlist is because I want to write the music to smoothly transition depending on how far the player is into the story, so it all feels like one piece of music synced to what the player is reading.
I could do this if there was some kind of macro that queues up the next audio file after the player has moved on to the next passage. If it where just a playlist the the next song would play no matter where the player was, and if it where multiple playlists the second would stop the first.
Hopefully that makes sense.
If this is just all impossible it would be good to know, just so i don't go ahead and write a bunch of music i can't use!
Cheers
Will your songs be gapless?
How do you want the transition to occur? Will they be able to flow from one into the next directly or will they need a very brief crossfade?
Assuming you have it ready, have you tried looping the first song (e.g. using the <<audio>> macro) to see if it loops to your satisfaction?
Do you intend for your project to be available on mobile devices?
Not the end of the world if it doesn't run on mobile, but curious as to why that's relevant.
Thanks again.
One last question. Do you want the transitions to happen on specific passages (i.e. by name) or simply by virtue of having moved forward (i.e. by turn)?
I should be able to write up a custom macro for this fairly quick—probably within a day. Since you haven't mentioned a version for SugarCube , I'm assuming that you're unfortunately using what comes bundled with Twine 2, which would be v1.
Mobile browsers are not the same as desktop browsers. They, in general, have more restrictions about what you can do with various elements and APIs.
In particular to the HTML5 media elements, they require user interaction to function and various things are disallowed (e.g. In the iOS browser core, adjusting the track volume, which is important when attempting to do a crossfade, is, bizarrely, disallowed—n.b. I'm not talking about the system/master volume).
I guess having the transitions happen on specific passages rather than by turn would allow for more control?
That would be amazing if you would, not sure how I could thank you.
Anyway, you can find the new <<audioloopto>> macro set package on SugarCube 2's site (under: Downloads > Add-ons). The name is kind of gimp, but I didn't give it much thought.
Install instructions, macro arguments, and basic usage should be covered by the package docs (read them), however, let me go over the usage a bit here.
You'll need to use the <<cacheaudio>> macro as normal to setup your tracks—StoryInit is the likely place. Once that's done you'll need to setup how you want the loop transitioning to work—you should probably do that just after your <<cacheaudio>> section. That might look something like the following: You should get the idea.
Finally, all you need to do to kick everything off is to start playback of track "A", like so: n.b. The package docs cover this, but do not pass <<audio>> the loop action. The <<audioloopto>> macro itself handles looping—it must be done programmatically in this case to be able to switch to another track.
The macros were tested in several browsers, including two mobile devices (iPhone and Kindle Fire HDX w/ Silk), and everything seems to work as intended—honestly, I was only worried about the mobile browsers.
This is great! Thank you so much for doing this.
If i could be so bold as bother you about some of the little issues i've come across just in the 30 mins i've spent with it...
It stops all other audio from playing; I had some background noise going on which actually helps cover up the transitions between the loops, is there any thing i can do to change that?
Is there a way to trigger the next track from a selection of passages. I have a junction point allowing the player to go to 4 different passages, but i want every passage to play the same loop. I tried:
<<audioloopto "A" "here" "B">>
<<audioloopto "A" "there" "B">>
<<audioloopto "A" "or maybe round the corner" "B">>
But that breaks it and keeps playing "A" whilst "B" plays.
If none if that is doable, don't worry. This is great and will deff be useful.
Thanks again!
Either you're doing something to cause the issue or something weird is going on. Just to ensure I'm not blowing smoke out my arse, I just tested your scenario and it worked as expected for me.
How are you playing the background music?
Heh. I thought of that earlier this morning and I've already updated the macro set (about 30 mins ago as I post this) to allow you to do exactly that—just grab the updated package.
A looped track may now have any number of passage triggers to other tracks—nor are you limited to using the same track. Your example is exactly how you'd do it as well. For example:
It works. Thank you.
The only last problem is the background noise stopping. I know kinda whats causing it:
I set the background audio to 'fadeover to' on the same passage that the first loop starts. For some reason this fades the background audio out completely.
It works fine if i just change the volume though.
Any ideas?
Actually,
I think it's effecting that macro throughout. Not just where both of those macros appear.
Which is annoying as it's kinda crucial that i have those fades.
Actually, Actually,
I think it's when I'm using two different audio macros in the same passage.
In an earlier passage i fade out and then fade in a track 20 seconds later.
It used to work, but isn't now. The two things that have changed is your new macros, and I also had to update from sugarcube 2.3 to 2.6 as the new macros required me too.
Sorry for the spamming.
That was the clue. The issue is not within the audio macros at all.
It seems that I broke SugarCube's clamping method when I did the ES6 (ES2015) refactor. /headdesk /headdesk /headdesk
I'll need to issue a new release to fix the bug. Should be later today.
Thanks for doing all of this. Messing around with the audio stuff was one of my main motivations for getting into twine, so I really do appreciate all the help.
Try it out and let me know if you have any further issues.
Was wondering if I could get your advice on issue to do with this macro. The looped audio will only switch to the other track whilst the player is on the passage that forces it to do so, this is fine 98% of the time. However if the player skims through that passage and clicks on to the next one before the first loop ends, the loop will carry on as before and not change to the next audio file as the player is no longer on that passage.
Does that make sense and is there anything i can do about this?
Thanks