In my game I have a countdown triggered at the start to let the player know how long he has before the oxygen in his room runs out. I accompany this with a looped alarm sound called
low_air.
If the player doesn't escape in time I send them to a 'death' passage, and in there I fade the text to nothing to simulate them losing consciousness.
I also want to fade the sound of the alarm out too, so I'm using:
<<audio "low_air" volume 1 fadeoverto 15 0>>
But when this passage is triggered, the alarm fades out almost immediately, instead of over the 15 seconds I've specified in the macro.
I suspect it has something to do with the fact that the same sound clip is still being looped when this command is triggered.
I suppose in that I know how long the player has before they die, I could tell the clip to fade out over that time from the beginning, but then I would have a gradual fade instead of it only fading when they actually die.
But I can't do this anyway, thinking about it, because the clip itself isn't long enough.
Comments
It won't fade over 15 seconds because the clip itself is barely 4 seconds long.
I can be such an air-head.
Are looped fades possible?
Hopefully someone else can help out here.
It's definitely something to do with the fact that I already have the clip looping when I try to trigger the fadeout in the 'death' passage.
I know this because if I remove the one that's looping from the start, the fade one works as it should.
One thing I haven't tried is creating a file of the same sound but with different names.
I'll gave that a go now.
[edit] Mmm, not ideal. It works in a fashion, but I have to stop the first file on entering the 'death' passage which results in an ugly clip in the sound, as one stops and the other starts.
Gryph, my knowledge of JS is virtually non-existent, but maybe it's the answer.
I think so unless there's something in the Audio Macros documentation that will help with that. I'm deaf, so I can't really help out with it any more than general ideas.
I dunno. But you've probably already pored over it, since I see the fadeoverto 'action' in the first part so I'll probably stop suggesting advice on this. lol.
What browser, and version, have you tried this in?
Firefox 50.0.2 (the latest as far as I'm aware)
If it's any help, I can guarantee that removing the audio macro that's triggered to loop from the start of the game, means that the one I'm using in the 'death' passage fades as it should.
BUT if I have the track already looping, the fade takes about 2 seconds when the player enters the 'death' passage.
Here's the two passages in question.
Start passage: Death passage:
Beyond that, some unrelated observations.
In the vacuum trap start passage, I'd expect that you'd probably want to start the air warning track playing within the same <<if>> as the countdown, rather than outside of it. For example:
In the asphyxiation death passage, you probably don't really need to set the volume of "low_air" to 1 in this case, since the track is currently looping and, presumably, already at max volume. If you were going to need to adjust the volume anywhere, it would likely be on the initial play. For example: And:
Since your original track's total duration was approximately 4 seconds, its remaining duration at any point during playback was definitely less than the 15 second fade you were attempting, thus triggering the issue.
Your current approximately 20 second track may or may not trigger the issue. If the fade started before, or slightly after, 5 seconds into a playback loop, it would either not trigger the issue or not be noticeable if it did. On the other hand, if the fade started nearer to the end of a playback loop, then you should still be able to notice an abrupt fade.
I'll have a fix out soon-ish.
Technical details for the interested (skip this if you're not): There was a bit of code which sanitized the fade duration to ensure that it was not less or greater than some sane values. On the high end, the fade duration would be clamped to the remaining duration of the track, to keep the fade from ending prematurely—though that would mean it would fade faster than asked for, so whether that was a good thing is a toss-up. Unfortunately, whether or not the track had been looped was not taken into account, thus causing the issue for looped tracks whose remaining duration for the current playback loop was less than fade duration.