Csound API  6.18
Realtime Audio I/O

Functions

PUBLIC void csoundSetRTAudioModule (CSOUND *csound, const char *module)
 Sets the current RT audio module. More...
 
PUBLIC int csoundGetModule (CSOUND *csound, int number, char **name, char **type)
 retrieves a module name and type ("audio" or "midi") given a number Modules are added to list as csound loads them returns CSOUND_SUCCESS on success and CSOUND_ERROR if module number was not found More...
 
PUBLIC long csoundGetInputBufferSize (CSOUND *)
 Returns the number of samples in Csound's input buffer. More...
 
PUBLIC long csoundGetOutputBufferSize (CSOUND *)
 Returns the number of samples in Csound's output buffer. More...
 
PUBLIC MYFLT * csoundGetInputBuffer (CSOUND *)
 Returns the address of the Csound audio input buffer. More...
 
PUBLIC MYFLT * csoundGetOutputBuffer (CSOUND *)
 Returns the address of the Csound audio output buffer. More...
 
PUBLIC MYFLT * csoundGetSpin (CSOUND *)
 Returns the address of the Csound audio input working buffer (spin). More...
 
PUBLIC void csoundClearSpin (CSOUND *)
 Clears the input buffer (spin). More...
 
PUBLIC void csoundAddSpinSample (CSOUND *csound, int frame, int channel, MYFLT sample)
 Adds the indicated sample into the audio input working buffer (spin); this only ever makes sense before calling csoundPerformKsmps(). More...
 
PUBLIC void csoundSetSpinSample (CSOUND *csound, int frame, int channel, MYFLT sample)
 Sets the audio input working buffer (spin) to the indicated sample this only ever makes sense before calling csoundPerformKsmps(). More...
 
PUBLIC MYFLT * csoundGetSpout (CSOUND *csound)
 Returns the address of the Csound audio output working buffer (spout). More...
 
PUBLIC MYFLT csoundGetSpoutSample (CSOUND *csound, int frame, int channel)
 Returns the indicated sample from the Csound audio output working buffer (spout); only ever makes sense after calling csoundPerformKsmps(). More...
 
PUBLIC void ** csoundGetRtRecordUserData (CSOUND *)
 Return pointer to user data pointer for real time audio input. More...
 
PUBLIC void ** csoundGetRtPlayUserData (CSOUND *)
 Return pointer to user data pointer for real time audio output. More...
 
PUBLIC void csoundSetHostImplementedAudioIO (CSOUND *, int state, int bufSize)
 Calling this function with a non-zero 'state' value between csoundCreate() and the start of performance will disable all default handling of sound I/O by the Csound library, allowing the host application to use the spin/spout/input/output buffers directly. More...
 
PUBLIC int csoundGetAudioDevList (CSOUND *csound, CS_AUDIODEVICE *list, int isOutput)
 This function can be called to obtain a list of available input or output audio devices. More...
 
PUBLIC void csoundSetPlayopenCallback (CSOUND *, int(*playopen__)(CSOUND *, const csRtAudioParams *parm))
 Sets a function to be called by Csound for opening real-time audio playback. More...
 
PUBLIC void csoundSetRtplayCallback (CSOUND *, void(*rtplay__)(CSOUND *, const MYFLT *outBuf, int nbytes))
 Sets a function to be called by Csound for performing real-time audio playback. More...
 
PUBLIC void csoundSetRecopenCallback (CSOUND *, int(*recopen_)(CSOUND *, const csRtAudioParams *parm))
 Sets a function to be called by Csound for opening real-time audio recording. More...
 
PUBLIC void csoundSetRtrecordCallback (CSOUND *, int(*rtrecord__)(CSOUND *, MYFLT *inBuf, int nbytes))
 Sets a function to be called by Csound for performing real-time audio recording. More...
 
PUBLIC void csoundSetRtcloseCallback (CSOUND *, void(*rtclose__)(CSOUND *))
 Sets a function to be called by Csound for closing real-time audio playback and recording. More...
 
PUBLIC void csoundSetAudioDeviceListCallback (CSOUND *csound, int(*audiodevlist__)(CSOUND *, CS_AUDIODEVICE *list, int isOutput))
 Sets a function that is called to obtain a list of audio devices. More...
 

Detailed Description

Function Documentation

◆ csoundAddSpinSample()

PUBLIC void csoundAddSpinSample ( CSOUND csound,
int  frame,
int  channel,
MYFLT  sample 
)

Adds the indicated sample into the audio input working buffer (spin); this only ever makes sense before calling csoundPerformKsmps().

The frame and channel must be in bounds relative to ksmps and nchnls. NB: the spin buffer needs to be cleared at every k-cycle by calling csoundClearSpinBuffer().

◆ csoundClearSpin()

PUBLIC void csoundClearSpin ( CSOUND )

Clears the input buffer (spin).

◆ csoundGetAudioDevList()

PUBLIC int csoundGetAudioDevList ( CSOUND csound,
CS_AUDIODEVICE list,
int  isOutput 
)

This function can be called to obtain a list of available input or output audio devices.

If list is NULL, the function will only return the number of devices (isOutput=1 for out devices, 0 for in devices). If list is non-NULL, then it should contain enough memory for one CS_AUDIODEVICE structure per device. Hosts will typically call this function twice: first to obtain a number of devices, then, after allocating space for each device information structure, pass an array of CS_AUDIODEVICE structs to be filled:

int i,n = csoundGetAudioDevList(csound,NULL,1);
malloc(n*sizeof(CS_AUDIODEVICE));
csoundGetAudioDevList(csound,devs,1);
for(i=0; i < n; i++)
csound->Message(csound, " %d: %s (%s)\n",
i, devs[i].device_id, devs[i].device_name);
free(devs);

◆ csoundGetInputBuffer()

PUBLIC MYFLT* csoundGetInputBuffer ( CSOUND )

Returns the address of the Csound audio input buffer.

Enables external software to write audio into Csound before calling csoundPerformBuffer.

◆ csoundGetInputBufferSize()

PUBLIC long csoundGetInputBufferSize ( CSOUND )

Returns the number of samples in Csound's input buffer.

◆ csoundGetModule()

PUBLIC int csoundGetModule ( CSOUND csound,
int  number,
char **  name,
char **  type 
)

retrieves a module name and type ("audio" or "midi") given a number Modules are added to list as csound loads them returns CSOUND_SUCCESS on success and CSOUND_ERROR if module number was not found

char *name, *type;
int n = 0;
while(!csoundGetModule(csound, n++, &name, &type))
printf("Module %d: %s (%s) \n", n, name, type);

◆ csoundGetOutputBuffer()

PUBLIC MYFLT* csoundGetOutputBuffer ( CSOUND )

Returns the address of the Csound audio output buffer.

Enables external software to read audio from Csound after calling csoundPerformBuffer.

◆ csoundGetOutputBufferSize()

PUBLIC long csoundGetOutputBufferSize ( CSOUND )

Returns the number of samples in Csound's output buffer.

◆ csoundGetRtPlayUserData()

PUBLIC void** csoundGetRtPlayUserData ( CSOUND )

Return pointer to user data pointer for real time audio output.

◆ csoundGetRtRecordUserData()

PUBLIC void** csoundGetRtRecordUserData ( CSOUND )

Return pointer to user data pointer for real time audio input.

◆ csoundGetSpin()

PUBLIC MYFLT* csoundGetSpin ( CSOUND )

Returns the address of the Csound audio input working buffer (spin).

Enables external software to write audio into Csound before calling csoundPerformKsmps.

◆ csoundGetSpout()

PUBLIC MYFLT* csoundGetSpout ( CSOUND csound)

Returns the address of the Csound audio output working buffer (spout).

Enables external software to read audio from Csound after calling csoundPerformKsmps.

◆ csoundGetSpoutSample()

PUBLIC MYFLT csoundGetSpoutSample ( CSOUND csound,
int  frame,
int  channel 
)

Returns the indicated sample from the Csound audio output working buffer (spout); only ever makes sense after calling csoundPerformKsmps().

The frame and channel must be in bounds relative to ksmps and nchnls.

◆ csoundSetAudioDeviceListCallback()

PUBLIC void csoundSetAudioDeviceListCallback ( CSOUND csound,
int(*)(CSOUND *, CS_AUDIODEVICE *list, int isOutput)  audiodevlist__ 
)

Sets a function that is called to obtain a list of audio devices.

This should be set by rtaudio modules and should not be set by hosts. (See csoundGetAudioDevList())

◆ csoundSetHostImplementedAudioIO()

PUBLIC void csoundSetHostImplementedAudioIO ( CSOUND ,
int  state,
int  bufSize 
)

Calling this function with a non-zero 'state' value between csoundCreate() and the start of performance will disable all default handling of sound I/O by the Csound library, allowing the host application to use the spin/spout/input/output buffers directly.

For applications using spin/spout, bufSize should be set to 0. If 'bufSize' is greater than zero, the buffer size (-b) in frames will be set to the integer multiple of ksmps that is nearest to the value specified.

◆ csoundSetPlayopenCallback()

PUBLIC void csoundSetPlayopenCallback ( CSOUND ,
int(*)(CSOUND *, const csRtAudioParams *parm)  playopen__ 
)

Sets a function to be called by Csound for opening real-time audio playback.

◆ csoundSetRecopenCallback()

PUBLIC void csoundSetRecopenCallback ( CSOUND ,
int(*)(CSOUND *, const csRtAudioParams *parm)  recopen_ 
)

Sets a function to be called by Csound for opening real-time audio recording.

◆ csoundSetRTAudioModule()

PUBLIC void csoundSetRTAudioModule ( CSOUND csound,
const char *  module 
)

Sets the current RT audio module.

◆ csoundSetRtcloseCallback()

PUBLIC void csoundSetRtcloseCallback ( CSOUND ,
void(*)(CSOUND *)  rtclose__ 
)

Sets a function to be called by Csound for closing real-time audio playback and recording.

◆ csoundSetRtplayCallback()

PUBLIC void csoundSetRtplayCallback ( CSOUND ,
void(*)(CSOUND *, const MYFLT *outBuf, int nbytes)  rtplay__ 
)

Sets a function to be called by Csound for performing real-time audio playback.

◆ csoundSetRtrecordCallback()

PUBLIC void csoundSetRtrecordCallback ( CSOUND ,
int(*)(CSOUND *, MYFLT *inBuf, int nbytes)  rtrecord__ 
)

Sets a function to be called by Csound for performing real-time audio recording.

◆ csoundSetSpinSample()

PUBLIC void csoundSetSpinSample ( CSOUND csound,
int  frame,
int  channel,
MYFLT  sample 
)

Sets the audio input working buffer (spin) to the indicated sample this only ever makes sense before calling csoundPerformKsmps().

The frame and channel must be in bounds relative to ksmps and nchnls.