RTcmix
INTERFACE design -- the main object for accessing RTcmix functions
within another application
The RTcmix object is used to 'imbed' RTcmix within
another application. Although it is possible to use the
RTcmix TCP/IP socket
to connect RTcmix with other applications and programming
environments, the RTcmix object allows you to
build a very direct connection, with direct access to
RTcmix execution and control.
The RTcmix object encapsulates virtually all of RTcmix,
including the scheduler. It replaces the default
Minc or user-specified perl or python interfaces that
are used with RTcmix as a standalone application (please see the
tutorials
on using these different interfaces with RTcmix).
All of the RTcmix
scorefile commands
and
instruments
can be called and accessed through the RTcmix::cmd() and
RTcmix::cmdval() methods (see below).
Constructors
RTcmix()
-
creates an RTcmix object with a default sampling rate
of 44100 samples/second, 2-channels, and a buffer size of 8192.
RTcmix(float sr, int nchans)
-
sr is the sampling rate to be used by RTcmix.
nchans is the number of channels.
RTcmix(float sr, int nchans, int bufsize)
-
sr is the sampling rate to be used by RTcmix.
nchans is the number of channels.
bufsize is the size of the RTcmix buffers to use for sample
computing.
Access Methods
Instrument* RTcmix::cmd(char *command, int nparams, double p0, double p1, double p2 ...)
-
command is a pointer to a character string (or just "COMMAND")
that is an RTcmix scorefile command or instrument.
nparams is the number of parameters (p-fields) being sent
with the command.
p0, p1, p2 ... are the double (floating-point) parameters
for the command.
This method returns an Instrument* pointer to the particular note or event
that is placed upon the scheduler. This Instrument* pointer can then be
recast to the specific Instrument type for the note (i.e. WAVETABLE* or
FIR*). The returned pointer can be used to directly access methods and
variables used in that instrument type (see the
Using RTcmix Imbedded Inside Another
Application
tutorial for more information about this). For instruments that require
a starting time parameter, the time 0.0 is considered to be the time
at which this method is used. Any future time is considered to be
measured from when the method is called, i.e. an instrument with a
start time of 3.14 will be scheduled to happen at 3.14 seconds from when
the RTcmix::cmd() method is invoked.
Instrument* RTcmix::cmd(char *command, int nparams, char *string1, char *string2, char *string3 ...)
-
command is a pointer to a character string (or just "COMMAND")
that is an RTcmix scorefile command or instrument.
nparams is the number of strings (p-fields) being sent
with the command.
string1, string2, string3 ... are pointers to character strings
(or just "string1", "string2", "string3", etc.) to be sent with command.
[note: This is the same as the previous access method, except that
it send character strings as p-fields instead of double (floating-point)
numbers.]
double RTcmix::cmd(char *command)
-
This method can be used for RTcmix commands with no parmeters. It is
equivalent to the previous RTcmix::cmd() methods with nparams
set to 0. It returns a double (floating-point) value, as many of these
RTcmix commands are used to return numeric information, and no RTcmix
instruments are constructed in this way.
double RTcmix::cmdval(char *command, int nparams, double p0, double p1, double p2 ...)
double RTcmix::cmd(char *command, int nparams, char *string1, char *string2, char *string3 ...)
-
These methods function the same as the previous RTcmix::cmd()
methods, except that they return double (floating-point) values. This is
for RTcmix scorefile commands that return numeric values but also require
parameters, like
cpspch or
pickrand.
void RTcmix::printOn()
void RTcmix::printOff()
-
Turn on/off all RTcmix printing and reporting to the terminal screen.
void RTcmix::panic()
-
This will temporarily suspend RTcmix processing and flush all events from
the RTcmix scheduler heap. Useful in those Mozartean situations when
the emperor tells you that your score has "TOO MANY NOTES"...
void RTcmix::close()
-
Stop all RTcmix processing and close any open soundfiles.
Examples
/* flutescale -- schedule and play a simple scale using the METAFLUTE
instrument (one of Perry Cook's physical models)
demonstration of the RTcmix object -- BGG, 11/2002
*/
#define MAIN
#include
#include
#include
#include "RTcmix.h"
int
main(int argc, char *argv[])
{
RTcmix *rrr;
rrr = new RTcmix();
rrr->printOn();
sleep(1); // give the thread time to initialized
rrr->cmd("load", 1, "METAFLUTE");
rrr->cmd("makegen", 7, 1.0, 24.0, 1000.0, 0.0, 1.0, 1.0, 1.0);
rrr->cmd("makegen", 11, 2.0, 24.0, 1000.0,
0.0, 0.0, 0.05, 1.0, 0.95, 1.0, 1.0, 0.0);
rrr->cmd("SFLUTE", 7, 0.0, 1.0, 0.1, 106.0, 25.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 1.0, 1.0, 0.1, 95.0, 21.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 2.0, 1.0, 0.1, 89.0, 19.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 3.0, 1.0, 0.1, 75.0, 19.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 4.0, 1.0, 0.1, 70.0, 15.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 5.0, 1.0, 0.1, 67.0, 16.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 6.0, 1.0, 0.1, 56.0, 17.0, 5000.0, 0.5);
rrr->cmd("SFLUTE", 7, 7.0, 1.0, 0.1, 53.0, 25.0, 5000.0, 0.5);
sleep(8);
}