Controlling sounds in TADS

I know that you can play sounds through a sound src tag. But can you do anything more, such as stopping the sound play or looping it? My guess is that this kind of thing would be handled in a similar manner to that mentioned in my previous post… modify the interpreter and use intrinsic functions that call C++ code?

I’ve done some sound work in my WIP. You can do quite a bit with the SOUND tag without resorting to primitives. This page is a good place to start.

<sound cancel> will stop all music, while <sound cancel=background> will stop only the background layer, and so on.

This will loop background music:

<sound layer=background src='rc/music.ogg' repeat=loop>

There’s a lot of scheduling permutations, actually, as well as fade-in, fade-out, etc.

One thing I’ve not experimented with is adv3’s real-time features (because I’m using adv3Lite, which doesn’t have real-time support). There’s no notification from the sound subsystem when a track stops playing, but if you know it’s length, you could schedule a RealTimeFuse to fire about the time the track ends. You could then schedule another track, keep playing the current, even print something to the screen.

3 Likes

Thanks Jim! I wasn’t expecting a solution that simple! I’m going to go play with it now. In fact, I have used RealtimeFuse to print text after a sound bite, I just didn’t know about the other capabilities of the sound tag…

1 Like

You can also fade sounds, as well as crossfade (that is, make a sound fade-in while another is being faded-out.)

1 Like