Loading...
Searching...
No Matches
Realtime Audio I/O

## Functions

PUBLIC void | csoundSetRTAudioModule (CSOUND *csound, const char *module)
| Sets the current RT audio module.
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
PUBLIC long | csoundGetInputBufferSize (CSOUND *)
| Returns the number of samples in Csound's input buffer.
PUBLIC long | csoundGetOutputBufferSize (CSOUND *)
| Returns the number of samples in Csound's output buffer.
PUBLIC MYFLT * | csoundGetInputBuffer (CSOUND *)
| Returns the address of the Csound audio input buffer.
PUBLIC MYFLT * | csoundGetOutputBuffer (CSOUND *)
| Returns the address of the Csound audio output buffer.
PUBLIC MYFLT * | csoundGetSpin (CSOUND *)
| Returns the address of the Csound audio input working buffer (spin).
PUBLIC void | csoundClearSpin (CSOUND *)
| Clears the input buffer (spin).
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().
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().
PUBLIC MYFLT * | csoundGetSpout (CSOUND *csound)
| Returns the address of the Csound audio output working buffer (spout).
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().
PUBLIC void ** | csoundGetRtRecordUserData (CSOUND *)
| Return pointer to user data pointer for real time audio input.
PUBLIC void ** | csoundGetRtPlayUserData (CSOUND *)
| Return pointer to user data pointer for real time audio output.
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.
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.
PUBLIC void | csoundSetPlayopenCallback (CSOUND *, int(*playopen__)(CSOUND *, const csRtAudioParams *parm))
| Sets a function to be called by Csound for opening real-time audio playback.
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.
PUBLIC void | csoundSetRecopenCallback (CSOUND *, int(*recopen_)(CSOUND *, const csRtAudioParams *parm))
| Sets a function to be called by Csound for opening real-time audio recording.
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.
PUBLIC void | csoundSetRtcloseCallback (CSOUND *, void(*rtclose__)(CSOUND *))
| Sets a function to be called by Csound for closing real-time audio playback and recording.
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.

## 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().

References PUBLIC.

## csoundClearSpin()

PUBLIC void csoundClearSpin | ( | CSOUND * |  | ) |

Clears the input buffer (spin).

References PUBLIC.

## 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);
CS_AUDIODEVICE *devs = (CS_AUDIODEVICE *)
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);
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.
CS_AUDIODEVICE
Device information.
Definition csound.h:527

References PUBLIC.

## 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.

References PUBLIC.

## csoundGetInputBufferSize()

PUBLIC long csoundGetInputBufferSize | ( | CSOUND * |  | ) |

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

References PUBLIC.

## 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);
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 csou...

References PUBLIC.

## 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.

References PUBLIC.

## csoundGetOutputBufferSize()

PUBLIC long csoundGetOutputBufferSize | ( | CSOUND * |  | ) |

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

References PUBLIC.

## csoundGetRtPlayUserData()

PUBLIC void ** csoundGetRtPlayUserData | ( | CSOUND * |  | ) |

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

References PUBLIC.

## csoundGetRtRecordUserData()

PUBLIC void ** csoundGetRtRecordUserData | ( | CSOUND * |  | ) |

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

References PUBLIC.

## 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.

References PUBLIC.

## 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.

References PUBLIC.

## 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.

References PUBLIC.

## csoundSetAudioDeviceListCallback()

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.

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

References PUBLIC.

## 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.

References PUBLIC.

## csoundSetPlayopenCallback()

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

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

## csoundSetRecopenCallback()

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

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

References PUBLIC.

## csoundSetRTAudioModule()

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

Sets the current RT audio module.

References PUBLIC.

## csoundSetRtcloseCallback()

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

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

References PUBLIC.

## csoundSetRtplayCallback()

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.

References PUBLIC.

## csoundSetRtrecordCallback()

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.

References PUBLIC.

## 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.

References PUBLIC.