soundinmac — Reads audio data from an audio file using native Mac OS functionality.
ifilcod -- integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought first in the current directory, then in that given by the environment variable SSDIR (if defined) then by SFDIR. See also GEN01.
Supported file formats are determined by the running version of MacOS, at the time of this writing they are:
3GP/3GPP-2
AAC ADTS
AC3
AIFF/AIFC
AMR
Apple CAF
MPEG Layer 1,2,3 & MPEG-4 Audio
NeXT/Sun
Sound Designer II
WAVE
iskptim (optional, default=0) -- time in seconds of input sound to be skipped. The default value is 0.
iwrap (optional, default=0) -- if non-zero, loops to beginning of file once end of file is reached.
a1 ... a24 -- output signals. Unlike the soundin and diskin family of opcodes, the number of output channels do not have to match the number of channels of the input file.
kpitch -- any value greater than zero. Transposition is implemented using OSX's internal samplerate converter. To reduce clicking, any change in kpitch triggers a crossfade of audio using the new transposition value with audio using the old value - which can create flange-like artifacts. As such, caution is advised when using this opcode for glissandi and other frequently changing transposition effects. kpitch is given as a pitch ratio, where:
1 = normal pitch
2 = 1 octave higher
3 = 12th higher, etc.
.5 = 1 octave lower
.25 = 2 octaves lower, etc.
-1 = normal pitch backwards
-2 = 1 octave higher backwards, etc.
![]() |
Note to Windows users |
---|---|
Windows users typically use back-slashes, “\”, when specifying the paths of their files. As an example, a Windows user might use the path “c:\music\samples\loop001.wav”. This is problematic because back-slashes are normally used to specify special characters. To correctly specify this path in Csound, one may alternately:
|
Here is an example of the soundinmac opcode. It uses the file soundinmac.csd.
Example ???. Example of the soundinmac opcode.
See the sections Real-time Audio and Command Line Flags for more information on using command line flags.
<CsoundSynthesizer> <CsOptions> -odac </CsOptions> <CsInstruments> ; Initialize the global variables. sr = 44100 ksmps = 10 nchnls = 2 ; Instrument #1 - play an audio file. instr 1 ; Play mp3 file 3 octaves higher and loop al, ar soundinmac "/Library/Frameworks/CsoundLib64.framework/Versions/5.2/Resources/Manual/examples/beats.mp3", 4, 0, 1 outs al, ar endin </CsInstruments> <CsScore> ; Play Instrument #1, the audio file, for ten seconds. i 1 0 10 e </CsScore> </CsoundSynthesizer>