Audio player Isis software documentation

Audio player

The audio player object provides an easy way to play sounds is Isis on Alpha workstations in parallel with other activities. (For Linux audio support, see the ALSA audio library.) Each audio player can only play one sound at a time, but you may create as many audio players as you want to play more than one sound simultaneously. The audio is actually played by separate audio server processes which access the MME audio services on Alpha workstations. You may create audio player objects on other machines, and you may synchronize the starts and stops of audio segments with activities in your script, even if the audio is being played on a different machine.

You create an audio player by calling new-audio-player with 5 arguments: the name of the machine to play the audio on (or Null to specify your local machine), the audio format (PCM or MULAW), the number of channels, the sampling rate, and the number of bits per sample of audio. You may not create audio players that play different kinds of audio (format, bits, chans, sample rate) on the same machine. To play a different kind of audio, first close all audio players currently running on that machine and open a new audio player for the new kind of audio.

If you encounter problems creating an audio player, it may be because a different program has seized control of the audio device (such as Audiofile). The solution is to kill that program.

A file handle is returned from new-audio-player that will serve as your interface to the audio player. You write commands to the audio player using write. Commands take the form of lists. The first item in the list is an "opcode" specifying which command to execute, and the rest of the items are the arguments for that command. The commands are outlined in the quick reference below.

To synchronize the audio player's timer with another timer in your program (to play synchronized audio and video for example), pass your timer's zero system time (obtained by entering (timer 'z')) to the ap-sync command of the audio player. Be sure to also send the zero time to the audio player any time you reset your timer.

You can control the volume of the audio device separably from the gain of the audio file you are playing. Change the volume of the audio device using the (ap-control "volume" ...) command. This will affect all audio streams playing on that machine. To change only the gain of that audio player, use the (ap-gain ...) command. A gain of 1.0 means no file conversion will occur. Values above 1.0 make the sound louder, and values below make it softer, and 0.0 will make it inaudible.


Example

(load "audio-server.isis") (set aplayer (new-audio-player Null PCM 2 44100 16)) (set timer (new-timer)) # timer to control audio synchronization (write aplayer [ap-file "my_raw_stereo_44khz_sound"] [ap-sync (timer 'z')] # synchronize audio player with timer [ap-gain 1.0] # 1.0 is unit gain (no conversion) [ap-control "loop" True] [ap-play 5.0 0.0 -1.0]) # start playing after 5 seconds, # from beginning of file, to file end (sleep 60) # sleep for 1 minute while playing (write aplayer [ap-stop]) # stop


Library summary

(load "audio-server.isis") (set aplayer (new-audio-player machinename format chans sampling-rate bits)) # Null machinename means use local machine # format may be PCM or MULAW # Commands to write to aplayer: [ap-file filename] # changes sound file [ap-sync timer-zerotime] # sets the audio player zero time [ap-control "loop" True/False] # set loop mode [ap-control "volume" volume] # set DEVICE volume (0-100) [ap-gain gain] # set audio gain (normal is 1.0) [ap-play starttime startpos playlen] # play all real numbers in seconds # -1.0 for starttime means immediately # -1.0 for startpos means current file pos # -1.0 for playlen means until end of file [ap-stop] # stop sound immediately [ap-quit] # close and terminate connection to server


Requirements:
Scripts: (load "audio-server.isis")
Other: Needs MME audio services library