an open-source digital signal processing and sound synthesis language
about · links · contact

rtsetoutput

INSTRUMENT design -- output initialization and setup function

The rtsetoutput() function is used in RTcmix instrument design to set the start time and duration of a note. Typically it is used in the INSTRUMENT::init() member function of an instrument. It handles all scheduling tasks for real-time output, and it also will set the note up for writing into a soundfile (if the rtoutput scorefile command was specified in the score) at the proper time.

It replaces the older setnote function used in disk-only cmix.


Usage

    int rtsetoutput(float start_time, float duration, Instrument *inst)

    start_time is the starting time for the note in seconds. Usually this is a p-field variable.
    duration is the duration of the note in seconds. Usually this is also a p-field variable.
    *inst is a pointer to the INSTRUMENT object being scheduled. Usually this is the token this (i.e. a pointer to the INSTRUMENT calling the rtsetoutput function).

    rtsetoutput() returns 0 if successful, -1 if it fails for any reason. A test for failure should be used to return the token DONT_SCHEDULE from an INSTRUMENT init method.

Examples

    #include <Instrument.h>
    
    int MYINSTRUMENT::init(float p[], int n_args)
    {
    
    	...
    
    	// assumes p[0] = start time (in seconds), p[1] = duration (in seconds)
    	returnval = rtsetoutput(p[0], p[1], this);
    	if (returnval == -1) return DONT_SCHEDULE;
    
    	...
    }
    


See Also