Max 5 API Reference
![]() |
Data Structures | |
struct | t_pxobject |
Header for any non-ui signal processing object. More... | |
struct | t_signal |
The signal data structure. More... | |
struct | t_pxjbox |
Header for any ui signal processing object. More... | |
Modules | |
Buffers | |
Your object can access shared data stored in an MSP buffer~ object. | |
PFFT | |
When an object is instantiated, it is possible to determine if it is being created in pfft~ context in the new method. | |
Poly | |
If your object is instatiated as a voice of a poly~ object, it is possible both to determine this context and to determine information about the specific voice. | |
Defines | |
#define | Z_NO_INPLACE 1 |
flag indicating the object doesn't want signals in place | |
#define | Z_PUT_LAST 2 |
when list of ugens is resorted, put this object at end | |
#define | Z_PUT_FIRST 4 |
when list of ugens is resorted, put this object at beginning | |
#define | PI 3.14159265358979323846 |
The pi constant. | |
#define | TWOPI 6.28318530717958647692 |
Twice the pi constant. | |
#define | PIOVERTWO 1.57079632679489661923 |
Half of the pi constant. | |
#define | dsp_setup z_dsp_setup |
This is commonly used rather than directly calling z_dsp_setup() in MSP objects. | |
#define | dsp_free z_dsp_free |
This is commonly used rather than directly calling z_dsp_free() in MSP objects. | |
Typedefs | |
typedef int | t_int |
An integer. | |
typedef float | t_float |
A float. | |
typedef float | t_sample |
A sample value. | |
typedef t_int *(* | t_perfroutine )(t_int *args) |
A function pointer for the audio perform routine used by MSP objects to process blocks of samples. | |
Enumerations | |
enum | { SYS_MAXBLKSIZE = 2048, SYS_MAXSIGS = 250 } |
MSP System Properties. More... | |
Functions | |
int | sys_getmaxblksize (void) |
Query MSP for the maximum global vector (block) size. | |
int | sys_getblksize (void) |
Query MSP for the current global vector (block) size. | |
float | sys_getsr (void) |
Query MSP for the global sample rate. | |
int | sys_getdspstate (void) |
Query MSP to determine whether or not it is running. | |
int | sys_getdspobjdspstate (t_object *o) |
Query MSP to determine whether or not a given audio object is in a running dsp chain. | |
void | dsp_add (t_perfroutine f, int n,...) |
Call this function in your MSP object's dsp method. | |
void | dsp_addv (t_perfroutine f, int n, void **vector) |
Call this function in your MSP object's dsp method. | |
void | z_dsp_setup (t_pxobject *x, long nsignals) |
Call this routine after creating your object in the new instance routine with object_alloc(). | |
void | z_dsp_free (t_pxobject *x) |
This function disposes of any memory used by proxies allocated by dsp_setup(). | |
void | class_dspinit (t_class *c) |
This routine must be called in your object's initialization routine. | |
void | class_dspinitbox (t_class *c) |
This routine must be called in your object's initialization routine. | |
void | class_dspinitjbox (t_class *c) |
Configure a class to be ready for use with the MSP signal chain. |
#define PIOVERTWO 1.57079632679489661923 |
typedef t_int*(* t_perfroutine)(t_int *args) |
anonymous enum |
void class_dspinit | ( | t_class * | c | ) |
This routine must be called in your object's initialization routine.
It adds a set of methods to your object's class that are called by MSP to build the DSP call chain. These methods function entirely transparently to your object so you don't have to worry about them. However, you should avoid binding anything to their names: signal, drawline, userconnect, and enable.
This routine is for normal (non-user-interface objects). It must be called prior to calling class_register() for your class.
c | The class to make dsp-ready. |
void class_dspinitbox | ( | t_class * | c | ) |
This routine must be called in your object's initialization routine.
It adds a set of methods to your object's class that are called by MSP to build the DSP call chain. These methods function entirely transparently to your object so you don't have to worry about them. However, you should avoid binding anything to their names: signal, drawline, userconnect, and enable.
This routine is for normal user-interface objects.
c | The class to make dsp-ready. |
void class_dspinitjbox | ( | t_class * | c | ) |
Configure a class to be ready for use with the MSP signal chain.
You must call this function when your class is initialized (typically in the main() function) for an object to process audio.
c | The pointer to the class being configured. |
void dsp_add | ( | t_perfroutine | f, | |
int | n, | |||
... | ||||
) |
Call this function in your MSP object's dsp method.
This function adds your object's perform method to the DSP call chain and specifies the arguments it will be passed. argc, the number of arguments to your perform method, should be followed by argc additional arguments, all of which must be the size of a pointer or a long.
f | The perform routine to use for processing audio. | |
n | The number of arguments that will follow | |
... | The arguments that will be passed to the perform routine. |
void dsp_addv | ( | t_perfroutine | f, | |
int | n, | |||
void ** | vector | |||
) |
Call this function in your MSP object's dsp method.
Use dsp_addv() to add your object's perform routine to the DSP call chain and specify its arguments in an array rather than as arguments to a function.
f | The perform routine to use for processing audio. | |
n | The number of arguments that will follow in the vector parameter. | |
vector | The arguments that will be passed to the perform routine. |
int sys_getblksize | ( | void | ) |
Query MSP for the current global vector (block) size.
int sys_getdspobjdspstate | ( | t_object * | o | ) |
Query MSP to determine whether or not a given audio object is in a running dsp chain.
This is preferable over sys_getdspstate() since global audio can be on but an object could be in a patcher that is not running.
int sys_getdspstate | ( | void | ) |
Query MSP to determine whether or not it is running.
int sys_getmaxblksize | ( | void | ) |
Query MSP for the maximum global vector (block) size.
float sys_getsr | ( | void | ) |
Query MSP for the global sample rate.
void z_dsp_free | ( | t_pxobject * | x | ) |
This function disposes of any memory used by proxies allocated by dsp_setup().
It also notifies the signal compiler that the DSP call chain needs to be rebuilt if signal processing is active. You should be sure to call this before de-allocating any memory that might be in use by your object’s perform routine, in the event that signal processing is on when your object is freed.
x | The object to free. |
void z_dsp_setup | ( | t_pxobject * | x, | |
long | nsignals | |||
) |
Call this routine after creating your object in the new instance routine with object_alloc().
Cast your object to t_pxobject as the first argument, then specify the number of signal inputs your object will have. dsp_setup() initializes fields of the t_pxobject header and allocates any proxies needed (if num_signal_inputs is greater than 1).
Some signal objects have no inputs; you should pass 0 for num_signal_inputs in this case. After calling dsp_setup(), you can create additional non-signal inlets using intin(), floatin(), or inlet_new().
x | Your object's pointer. | |
nsignals | The number of signal/proxy inlets to create for the object. |