Tuesday, June 18, 2013

Non-blocking Playback

Non-blocking playback is now working as well. See example below.

signal1 = sin(linspace(0.0, 440.0 * 10.0 * 2.0 * pi, 441000)) * 0.2;
signal2 = sin(linspace(0.0, 442.0 * 10.0 * 2.0 * pi, 441000)) * 0.2;
signal = [signal1; signal2];
player = audioplayer(signal, 44100);
player_play(player);
sleep(5);
player_pause(player);
sleep(5);
player_resume(player);

This example will play a 440Hz sine wave in the left speaker and 442Hz sine wave in the right speaker for 5 seconds, pause, wait 5 seconds and then resume playing again. The difference between blocking and non-blocking modes is that when using non-blocking mode, after issuing the play command the control returns to the octave interpreter.

No comments:

Post a Comment