The SndThread class implements a processing pthread-based thread for SndObj and SndIO -derived objects. The class implements three lists of objects which are used by the processing thread to generate audio signals. Two of these lists hold pointers to SndIO-derived objects (the SNDIO_IN, for input objects and the SNDIO_OUT, for output objects). The third list holds pointers to SndObj-derived objects. Methods for adding, inserting and deleting objects to these lists are provided. Processing can be turned on or off by the ProcOn() and ProcOff() methods, respectively.
int AddObj(SndObj *obj)
int AddObj(SndIO *obj, int iolist)
int Insert(SndObj *obj, SndObj* prev)
int DeleteObj(SndObj *obj)
int DeleteObj(SndIO *obj, int iolist)
int GetStatus()
int GetSndObjNo()
int GetInputNo()
int GetOutputNo()
Constructs an empty SndThread object.
Adds a pointer to a SndObj-derived object to the top of the processing list. Returns 1 if successful and 0 if not.
int Insert(SndObj *obj, SndObj* prev)
Inserts a pointer to a SndObj-derived object to a
position in the list after the SndObj object pointed by
prev, which will have been previously added to the
list.
This is useful to insert objects in the processing
list, so that the right order of processing is obtained.
For instance, if obj1 receives input from obj2, then it
should be placed in the listafter obj2. The following
call will make sure that this is the case
sndthread.Insert(&obj1, &obj2);
provided, of course, that obj2 has already been added to the thread list. This method returns the position of the inserted object in the list, if the insertion was succesful, 0 otherwise.
Adds a pointer to a SndIO-derived object to the specified IO list (SNDIO_IN or SNDIO_OUT). For example
sndthread.AddObj(&input, SNDIO_IN);
adds a pointer to a SndIO-derived object input to the SNDIO_IN list.
int DeleteObj(SndObj *obj)
int DeleteObj(SndIO *obj, int iolist)
Delete objects from the respective lists. As in AddOBJ(...), the parameter iolist can be either SNDIO_IN or SNDIO_OUT, the input and the output lists, respectively.
int GetStatus()
int GetSndObjNo()
int GetInputNo()
int GetOutputNo()
Various methods to get properties of a SndThread object.
GetStatus()
returns the processing status (ON or OFF).
GetSndObjNo(), GetInputNo() and GetOutputNo() return the number of
objects (actually pointers to objects) held in the processing, input
and ouput lists, respectively
int ProcOn()
int ProcOff()
A simple example and an application template are provided in this distribution of the SndObj Library. They show the use of SndThread on the Windows (under cygwin and g++) platform. SndThread is only implemented on POSIX pthread compliant platforms (cygwin, Linux, Irix and other Unix ports of the SndObj library). It is not available on the Windows/MS Visual C++ version of the library. Compilation instructions are found here.
SndObj Library version 2.0
© Victor Lazzarini, 2001
Music Technology Laboratory
NUI Maynooth