Skip to content

exercise_8

bjornstahl edited this page Oct 14, 2021 · 1 revision

Exercise 8

This will take a brief look at audio playback facilities. You might have already encountered some of this during the previous exercise set if the clip you used had audio in it.

Some of these are dependent on the state of your audio stack, the presence of capture devices and so on.

1 - Sample of things to come

Get a hold of a PCM encoded WAV file and add it to a new appl. Similarly to load_image from the earlier exercises, use load_asample.

Add an input handler so that when you press a button, the sample will be played back. See play_audio

2 - Can you hear that?

Take the solution from 1 and use audio_gain to set the state of the sample playback to have a gain of 0.0. Then add a timed step from that to 1.0 and down to 0.0.

3 - Repeat yourself

Continue with the appl from 1 and modify so that when it finishes playing back, it starts anew.

4 - Mixing Things Up

Use the decode frameserver to playback a video clip with audio or a music- only file such as an MP3 track. Then combine that with the code from exercises 1 and 2 to make sure that the mp3 is audible in the background, but the audio sample is louder.

Clone this wiki locally