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

rtsetinput

INSTRUMENT design -- input initialization and setup function

The rtsetinput() function is used in RTcmix instrument design to set the start time to begin reading a soundfile (if the rtinput scorefile command set a soundfile in the score) or the start time for becoming active (if real-time input was specified by the rtinput command in the score).

Typically it is used in the INSTRUMENT::init() member function of an instrument. It handles all scheduling tasks for real-time input, and it can also be used to set the INSTRUMENT for reading a soundfile at the proper time.

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


Usage

    int rtsetinput(float start_time, Instrument *inst)

    start_time is the starting time for reading in seconds. Usually this is 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 rtsetinput() function).

    rtsetinput() does not use a duration. This is set in the rtsetoutput function. The rtsetinput() function returns 0 if it is successful, -1 if there is an error.

Examples

    #include <Instrument.h>
    
    int MYINSTRUMENT::init(float p[], int n_args)
    {
    
    	...
    
    	// assumes p[0] = start time for output (in seconds)
    	//	   p[1] = duration (in seconds)
    	//	   p[2] = start time for input (in seconds)
    	returnval = rtsetoutput(p[0], p[1], this);
    	if (returnval == -1) return DONT_SCHEDULE;
    	returnval = rtsetinput(p[2], this);
    	if (returnval == -1) {
    		cout << "problem setting up the input!" << endl;
    		return DONT_SCHEDULE;
    	}
    
    	...
    }
    


See Also