SndBuffer


Description

This class implements buffer input/output. It reads/writes samples to a buffer, making it possible to send buffered signals from one thread or process to another. The Read() and Write() functions will block if the buffer is empty or full. This class can be used to create buffering objects when synchronisation of signals from multiple threads is necessary.

Construction

SndBuffer(short channels, int buffsize=DEF_VECSIZE, SndObj** inputlist=0, int vecsize=DEF_VECSIZE, float sr=DEF_SR)

Public Methods

virtual short Read()

virtual short Write()
virtual char* ErrorMessage()



SndBuffer( )

This method constructs an object of the SndBuffer class. Construction parameters are:

short channels: number of input/output channels
int buffsize: size of memory buffer, set by default to the same size of the DSP vector, but does not necessarily need to be of that size (but it will help if it is an integer multiple of the vector size).
SndObj** inputlist: list of input SndObj/SndObj -derived objects, one for each output channel.

int vecsize: vector size in samples. Size of the internal DSP buffer, defaults to DEF_VECSIZE, 256.
float sr: sampling rate in HZ. Defaults to DEF_SR, 44100.f.


short Read()

Reads the buffer and outputs a new signal vector to the processing chain every time it is called. Should be used in conjunction with at least one SndIn object. Calls to Read() will block if no samples are currently present in the buffer. Successive calls to Write() will fill the buffer with new samples.


short Write()

Writes a new signal vector to the buffer every time it is called. Calls to Write() will block if the buffer is full. Successive calls to Read() will empty the buffer.


SndObj Library version 2.0
© Victor Lazzarini, 2001
Music Technology Laboratory
NUI Maynooth