SunPlay


Routine

SunPlay [options] AFile1 AFileB ...

Purpose

Play audio files on the Sun audio device

Description

This program plays audio files on the Sun audio device. This program allows for the choosing the volume, stereo balance and output port for playback. The defaults for these parameters are the current settings. After playback, these parameters are restored to the values in place before this program was invoked.

The sampling rate for the playback is normally that associated with the file (usually specified in a file header). There is provision to override this default value. The audio device supports a limited set of sampling rates. For the least capable audio devices (e.g. Sun SLC / ELC), the only allowable sampling rate is 8000 Hz. For multimedia audio boards, the allowable sampling rates are 8000, 9600, 11025, 16000, 18900, 22050, 32000, 37800, 44100, and 48000 Hz. This routine tries the desired sampling rate, and if this is not an allowable value, then it uses one of the standard values if it is within 5 % of the desired sampling rate.

Playback can be in mono or stereo depending on the capabilities of the audio device. If a stereo audio file is played on a mono device, the left and right channels are combined for playback. The data in the input audio files are converted to the appropriate format (16-bit integer if the audio device supports it; 8-bit mu-law otherwise) for playback.

Options

Input file(s): AFileA [AFileB, ...]:
The environment variable AUDIOPATH specifies a list of directories to be searched for the input audio file(s). For a single input file, the input can be from standard input. Specifying "-" as the input file indicates that input is from standard input.
-V VOL, --Volume=VOL
Set the output volume (a value between 0 and 100). This volume setting affects the signal level at the output of the audio device (after D/A conversion). This option may be given more than once. Each invocation applies to the files that follow the option.
-b BAL, --balance=BAL
Set the stereo balance (a value between 0 and 100). The value 50 corresponds to equal left and right volume. For values between 0 and 50, the right channel volume is reduced. For values between 50 and 100, the left channel volume is reduced. This option may be given more than once. Each invocation applies to the files that follow the option.
-p [+-]PORTS, --port=[+-]PORTS
Choose the output ports. The ports argument is a list of ports separated by commas. A "+" indicates ports to be turned on, a "-" indicates ports to be turned off. With neither a "+" or a "-", the specified ports are turned on and others are turned off. The output ports are: "speaker", "headphones" and "line-out". This option may be given more than once. Each invocation applies to the files that follow the option.
-l L:U, --limits=L:U
Frame limits (numbered from zero) for the input audio files. A frame is a a single sample (mono) or a pair of samples (stereo). This option may be given more than once. Each invocation applies to the files that follow the option. Note that specifying limits before the beginning of the file (limits less than zero) or after the end of the file results in the playing of zero-valued samples.
-s SFREQ, --srate=SFREQ
Set the playback sampling frequency (overrides the sampling frequency associated with an audio file). This option may be given more than once. Each invocation applies to the files that follow the option. SFREQ may be given as "default" to restore the sampling rate to be that associated with the following audio files.
-r RPT, --repeat=RPT
Number of repetitions of the playback (default 1)
-u PAUSES, --pause PAUSES
Specify pauses between playback of files and repeats. The pauses are specified as a comma separated pair of times in seconds. The first value is used to insert a pause between playback of files. The second value is used to insert a pause between repeats. If the second value is not specified, it is set equal to the first value. The pause values are rounded up to an integral number of seconds. The default is zero seconds for both pauses.
-d DEV, --device=DEV
Audio device name, default from the environment variable AUDIODEV or "/dev/audio".
-w --wait
Wait for the audio device if it is busy.
-nw --nowait
Do not wait for the audio device if it is busy (default).
-g GAIN, --gain=GAIN
Set the gain factor for the input data. This gain factor is applied to the signal before it is sent to the audio device (i.e. before D/A conversion). This gain factor is in addition to the scale factor that is normally applied when reading data from the file. The default value is 1. This option may be given more than once. Each invocation applies to the files that follow the option.
-t FTYPE, --type=FTYPE
Input audio file type. In the default automatic mode, the input file type is determined from the file header. For input from a non-random access file (e.g. a pipe), the input file type can be explicitly specified to avoid the lookahead used to read the file header. This option can be specified more than once. Each invocation applies to the input files that follow the option. See the description of t he environment variable AF_FILETYPE below for a list of file types.
-P PARMS, --parameters=PARMS
Parameters to be used for headerless input files. This option may be given more than once. Each invocation applies to the input files that follow the option. See the description of the environment variable AF_NOHEADER below for the format of the parameter specification.
-h, --help
Print a list of options and exit.
-v, --version
Print the version number and exit.

Environment variables

AF_FILETYPE:
This environment variable defines the input audio file type. In the default mode, the input file type is determined from the file header.
  "auto"      - determine the input file type from the file header
  "AFsp", "Sun" or "sun" - AFsp (Sun) audio file
  "WAVE" or "wave" - RIFF WAVE file
  "AIFF" or "aiff" - AIFF or AIFF-C audio file
  "noheader"  - headerless (non-standard or no header) audio file
  "SPHERE"    - NIST SPHERE audio file
  "ESPS"      - ESPS sampled data feature file
  "IRCAM"     - IRCAM soundfile
  "SPPACK"    - SPPACK file
  "INRS"      - INRS-Telecom audio file
  "SPW"       - Comdisco SPW Signal file
  "text"      - Text audio file

AF_NOHEADER:
This environment variable defines the data format for headerless or non-standard input audio files. The string consists of a list of parameters separated by commas. The form of the list is
  "Format, Start, Sfreq, Swapb, Nchan, ScaleF"
Format: File data format
 "undefined" - Headerless files will be rejected
 "mu-law8"   - 8-bit mu-law data
 "A-law8"    - 8-bit A-law data
 "unsigned8" - offset-binary 8-bit integer data
 "integer8"  - two's-complement 8-bit integer data
 "integer16" - two's-complement 16-bit integer data
 "float32"   - 32-bit floating-point data
 "float64"   - 64-bit floating-point data
 "text"      - text data
Start: byte offset to the start of data (integer value)
Sfreq: sampling frequency in Hz (floating point number)
Swapb: Data byte swap parameter
 "native"        - no byte swapping
 "little-endian" - file data is in little-endian byte order
 "big-endian"    - file data is in big-endian byte order
 "swap"          - swap the data bytes as the data is read
Nchan: number of channels
The data consists of interleaved samples from Nchan channels
ScaleF: Scale factor
Scale factor applied to the data from the file
The default values for the audio file parameters correspond to the following string.
  "undefined, 0, 8000., native, 1, 1.0"

AUDIOPATH:
This environment variable specifies a list of directories to be searched when opening the input audio files. Directories in the list are separated by colons.

AUDIODEV:
This environment variable specifies the audio device name.

Examples

1: Play a single file at the sampling rate specified by its header.
  SunPlay xxx.au
2: Repeat playback 5 times.
  SunPlay -r 5 xxx.au
3: Play xxx.au at 8000 Hz, yyy.au at 16000 Hz.
  SunPlay -s 8000 xxx.au -s 16000 yyy.au
4: Assuming xxx.au is a headerless file, declare it to contain integer data at a sampling rate of 16000 Hz.
  SunPlay -P int -s 16000 xxx.au
5: Play samples -4000 to 19,999. Samples before time zero are assumed to be zero. For a sampling rate of 8000 Hz, this would effectively insert 0.5 seconds of silence before playback of 20000 samples of the data in the audio file. If there are fewer than 20000 samples in the audio file, the playback of the data would be followed by the appropriate amount of silence.
  SunPlay -l -8000:19999 xxx.au
6: Play with a 1 second pause between the files and a 2 second pause between repeats.
  SunPlay -t 1,2 xxx.au yyy.au

Author / revision

P. Kabal / v2r1 1999/06/14 Copyright (C) 1999


Main Index AFsp