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


INSTRUMENT design -- read samples from the input device or file

The Ortgetin object fills an input array with samples from a soundfile or an input device, depending upon the parameters set in the rtinput scorefile command. It essentially wraps the rtgetin function and simplifies the necessary array allocation and sample-retrieval chores.

It is still the responsibility of the RTcmix instrument designer to properly handle differing numbers of input channels (i.e. mono vs. stereo) in the Instrument::run() method. Ortgetin will configure it's input buffers and returned sample array based upon the values of the RTBUFSAMPS parameter. Ortgetin will automatically read a new input buffer whenever the current buffer of input samples is exhausted. Note that Ortgetin assumes that the input has been properly set using the rtsetinput function.

See the instrument design tutorial for more information on how Ortgetin is used.


    Ortgetin(Instrument *inst)

    inst is a pointer to the Instrument/note using Ortgetin.

Access Methods

    int Ortgetin::next(float *inarray)

    inarray[] is the input array used for the input-channel samples of the current sample frame; i.e. inarray[0] would contain the sample for channel 0 (left) and inarray[1] would contain the sample for channel 1 (right) of a stereo file after a call to this method. This method returns the number of samples read whenever Ortgetin grabs a new buffer of samples (once at the beginning of each sample frame), otherwise it returns 0.


    #include <Ougens.h>
    Ortgetin *theIn;
    // this instrument will generate noise
    int MYINSTRUMENT::init(float p[], int n_args)
    	rtsetinput(inputskip, this);
    	theIn = new Ortgetin(this);
    int MYINSTRUMENT::run()
    	float out[2];
    	float in[2];
    	for (i = 0; i < framesToRun(); i++)
    		out[0] = in[0];
    		out[1] = in[1];