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()
- single string: the path and name of the sound file to play.
- real positive number: relative playing speed.
speed< 1 plays slower, while
speed> 1 plays faster. (1.0 by default).
- matrix of normalized linear sound data, in [-1,1]. Each row feeds a channel.
- real positive number: sampling frequency in Hz (default value is 22050).
- positive decimal integer: number of consecutive times (iterations) that the sound must be played.
- Only used on Unix and MacOS systems. Single string giving the OS command
to use for playing sound (wav) files. The default value is
"aplay"on Linux and
"afplay"on MacOS. If
playerCmdis set to
/dev/audio, then a 8 bits mu-law raw sound file is created and send to
playsnd(filename,..) or playsnd(y,..) cancels any running sound and then starts playing a single or multi channel signal.
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
Otherwise, the sound is played
nb_iter consecutive times,
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
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:
playsnd("SCI/modules/sound/demos/chimes.wav",, 20); // Now enter CTRL-C to interrupt the repetition // Then type "resume" or "abort"
- beep — Produce a beep sound
- realtime — sets the time unit
- lin2mu — linear signal to mu-law encoding
- wavread — reads sound data or querries data info from a .wav audio file
- auread — load .au sound file
- mcisendstring — sends a command string to an MCI device (Windows only)
- winopen — Open file in appropriate application (Windows only)
|Report an issue|
|<< mu2lin||Manipulação de Arquivos de Som||savewave >>|