command-line sound player facility
playsnd(filename) playsnd(filename, speed) playsnd(filename, speed, nbiter) playsnd(filename, speed, nbiter, playerCmd) playsnd(filename, speed, playerCmd) playsnd(y) playsnd(y, rate) playsnd(y, rate, nbiter) playsnd(y, rate, nbiter, playerCmd) playsnd(y, rate, playerCmd) playsnd([])
speed
< 1 plays slower,
while speed
> 1 plays faster. (1.0 by default).
"aplay"
on Linux and "afplay"
on MacOS.
If playerCmd
is set to /dev/audio
,
then a 8 bits mu-law raw sound file is created and send to
/dev/audio
.
playsnd(filename,..) or playsnd(y,..) cancels any running sound and then starts playing a single or multi channel signal.
When nb_iter
is not used, the sound is played only once, and
playsnd(…)
behaves in a non-modal way: Scilab returns to the prompt
or to the next instruction just after starting playing, without waiting for the end of
the sound.
Otherwise, the sound is played nb_iter
consecutive times,
and playsnd(…)
becomes modal (even for
nb_iter
=1): Scilab returns to the prompt
or to the next instruction only after the end of the last time the sound is played.
![]() | The repetition is interruptible with CTRL-C or any pause or
abort callback instruction. |
playsnd([]) cancels any sound running without
nb_iter
and not through /dev/audio.
Playing a sound from its audio file:
// A two channel signal File = "SCI/modules/sound/demos/chimes.wav"; playsnd(File) // Play it once at normal speed sleep(5) playsnd(File, 2) // Play it once at speed x 2 sleep(5) playsnd(File,, 3) // Play it 3 times at normal speed sleep(5) playsnd(File, 1.5, 3) // Play it 3 times at speed x 1.5 sleep(5) playsnd(File, 0.2) // Play it once and slowly. // Note that Scilab returns as soon as the player starts. // Plays a longer sound. Interrupts it 1.0 s after it started: playsnd(File, 0.2), sleep(1,'s'), playsnd([]) | ![]() | ![]() |
Playing a sound from its data in a matrix:
y = loadwave("SCI/modules/sound/demos/chimes.wav"); playsnd(y) // Play it once at the default 22050 Hz sampling rate sleep(5) playsnd(y, 3e4) // Play it once at 30 kHz sampling rate sleep(5) playsnd(y,, 3) // Play it 3 times at the default sampling rate sleep(5) playsnd(y, 44100, 3) // Play it 3 times at 44.1 kHZ sampling rate | ![]() | ![]() |
Interrupting with CTRL + C a repeated sound:
Version | Description |
6.1.0 |
|