[Function]
(play file {keyword value})

Plays file in a manner appropriate for the file type (extension) of file.

play supports the following keyword arguments for all file types:

:play boolean
If true, file is played otherwise it is not. The default value is true.
:verbose boolean
If true then the play command is printed to the terminal before it is executed. The default value is false.
:wait boolean
If true then play waits for the playing process to complete before returning, otherwise it does not wait. The default value is false.

Other keyword arguments may be available depending on the type of file:

audio-file (.aiff, .wav, .snd)

If CLM is loaded then play passes file directly to dac along with any of the following keyword arguments:

:start number
The time in file to start playback.
:end number
The time in file to stop playback.

If CLM is not loaded then play executes the shell command string *audio-player* to play file. CM attempts to provide a valid audio player command for each operating system:

The *audio-player* variable can be reset to a different player in a ~/.cminit.lisp initialization file.

clm-file (.clm)

Passes file to clm-load along with any keyword arguments specfied to play.

midi-file (.mid, .midi)

Executes the shell command string *midi-player* to play file. CM attempts to provide a valid MIDI player command for each operating system:

The *midi-player* variable can be reset to a different player in a ~/.cminit.lisp initialization file.

sc-file (.osc)

Executes the shell command string *scsynth* and passes it file and any keyword value supported by sc-file.

CM attempts to find a valid *scsynth* command for each operating system:

  • OS X: /Applications/SuperCollider3 or /Applications/SuperCollider_f tested for scsynth.
  • Unix, Linux, Cygwin: /usr/local/bin and /usr/bin tested for scsynth
  • Windows: \Program Files\SuperCollider3\scsynth.exe

If the SC environment variables SC_PLUGIN_PATH and SC_SYNTHDEF_PATH are not set then CM attempts to set them using the values of of *sc-synthdef-path* and *sc-plugin-path*. The *scsynth*, *sc-plugin-path* and *sc-synthdef-path* variables can be reset in a ~/.cminit.lisp initialization file.

sco-file (.sco)

Executes the shell command string *csound* and passes it file and any of the following keyword values:

:orchestra orcfile
The .orc file to use. If orcfile does not contain a directory component it defaults to the same directory as file.
:output sndfile
The sound file for Csound to write. If sndfile does not contain a directory component it defaults to the same directory as file.

Examples:

Example 1. Playing a MIDI file.

(play "test.mid")
 "test.mid"

Example 2. Playing CLM score and audio files:

(play "test.clm" :srate 44100 :output "foo.aiff" :channels 2)
 "test.clm"
(play "test.aiff" :start 4 :verbose #t)
 "test.aiff"

Example 3. Playing a Csound score file.

(play "test.sco" :orchestra "beep.orc" :output "beep.aiff")
 "test.sco"

See also: