16 #include "TTClassWrapperMax.h"
19 #include "ext_strings.h"
20 #include "commonsyms.h"
25 #define DEFAULT_F 1000
30 typedef struct _filter {
50 void*
filter_new(t_symbol *msg,
short argc, t_atom *argv);
72 void filter_dsp64(
t_filter *x, t_object *dsp64,
short *count,
double samplerate,
long maxvectorsize,
long flags);
93 t_max_err filter_setMode(
t_filter *x,
void *attr,
long argc, t_atom *argv);
97 t_class *filter_class;
107 common_symbols_init();
114 class_addmethod(c, (method)
filter_dsp,
"dsp", A_CANT, 0L);
115 class_addmethod(c, (method)filter_dsp64,
"dsp64", A_CANT, 0);
116 class_addmethod(c, (method)
filter_assist,
"assist", A_CANT, 0L);
117 class_addmethod(c, (method)object_obex_dumpout,
"dumpout", A_CANT, 0);
118 class_addmethod(c, (method)stdinletinfo,
"inletinfo", A_CANT, 0);
120 CLASS_ATTR_LONG(c,
"bypass", 0,
t_filter, attrBypass);
122 CLASS_ATTR_STYLE(c,
"bypass", 0,
"onoff");
124 CLASS_ATTR_FLOAT(c,
"frequency", 0,
t_filter, attrFrequency);
127 CLASS_ATTR_FLOAT(c,
"q", 0,
t_filter, attrQ);
130 CLASS_ATTR_SYM(c,
"type", 0,
t_filter, attrType);
133 CLASS_ATTR_SYM(c,
"mode", 0,
t_filter, attrMode);
134 CLASS_ATTR_ACCESSORS(c,
"mode", NULL, filter_setMode);
137 class_register(CLASS_BOX, c);
151 long attrstart = attr_args_offset(argc, argv);
154 x = (
t_filter *)object_alloc(filter_class);
159 x->
attrQ = DEFAULT_Q;
160 x->attrMode = _sym_nothing;
163 if (attrstart && argv)
168 object_attr_setsym(x, _sym_type, gensym(
"lowpass.butterworth.2"));
173 attr_args_process(x,argc,argv);
175 object_obex_store((
void *)x, _sym_dumpout, (
object *)outlet_new(x,NULL));
178 outlet_new((t_pxobject *)x,
"signal");
180 x->
obj.z_misc = Z_NO_INPLACE;
188 dsp_free((t_pxobject *)x);
203 strcpy(dst,
"(signal) Frequency");
205 strcpy(dst,
"(signal) Q-value");
207 strcpy(dst,
"(signal) input 1, control messages");
208 else if (arg < x->maxNumChannels)
209 snprintf(dst, 256,
"(signal) input %ld", arg+1);
214 strcpy(dst,
"dumpout");
216 snprintf(dst, 256,
"(signal) Filtered output %ld", arg+1);
232 atom_setsym(a, _sym_clear);
233 object_obex_dumpout(x, gensym(
"types"), 1, a);
234 atom_setsym(a, _sym_append);
240 atom_setsym(a+1, gensym((
char*)classname.
c_str()));
241 object_obex_dumpout(x, gensym(
"types"), 2, a);
269 x->
attrQ = atom_getfloat(argv);
281 if (x->
attrType != atom_getsym(argv)) {
302 t_max_err filter_setMode(
t_filter *x,
void *attr,
long argc, t_atom *argv)
305 x->attrMode = atom_getsym(argv);
326 if (!x->
obj.z_disabled)
331 x->
audioOut->getVector(i, vs, (t_float *)w[j+2]);
351 freq = (t_float*)w[j];
353 if (!x->
obj.z_disabled) {
361 x->
audioOut->getVector(i, vs, (t_float *)w[j+2]);
380 q = (t_float*)w[(i*2) + 2];
382 if (!x->
obj.z_disabled) {
390 x->
audioOut->getVector(i, vs, (t_float *)w[j+2]);
410 freq = (t_float*)w[(i*2) + 2];
411 q = (t_float*)w[(i*2) + 3];
413 if (!x->
obj.z_disabled) {
423 x->
audioOut->getVector(i, vs, (t_float *)w[j+2]);
432 void filter_perform64(
t_filter *x, t_object *dsp64,
double **ins,
long numins,
double **outs,
long numouts,
long sampleframes,
long flags,
void *userparam)
443 x->
audioOut->getVectorCopy(i, vs, outs[i]);
448 void filter_perform64_freq(
t_filter *x, t_object *dsp64,
double **ins,
long numins,
double **outs,
long numouts,
long sampleframes,
long flags,
void *userparam)
464 x->
audioOut->getVectorCopy(i, vs, outs[i]);
470 void filter_perform64_q(
t_filter *x, t_object *dsp64,
double **ins,
long numins,
double **outs,
long numouts,
long sampleframes,
long flags,
void *userparam)
485 x->
audioOut->getVectorCopy(i, vs, outs[i]);
489 void filter_perform64_freq_q(
t_filter *x, t_object *dsp64,
double **ins,
long numins,
double **outs,
long numouts,
long sampleframes,
long flags,
void *userparam)
509 x->
audioOut->getVectorCopy(i, vs, outs[i]);
519 void **audioVectors = NULL;
520 bool hasFreq =
false;
523 audioVectors = (
void**)sysmem_newptr(
sizeof(
void*) * ((x->
maxNumChannels * 2) + 1));
531 if (count[i] && count[j]) {
533 if (sp[i]->s_n > x->
vs)
536 audioVectors[k] = sp[i]->s_vec;
538 audioVectors[k] = sp[j]->s_vec;
572 sysmem_freeptr(audioVectors);
575 void filter_dsp64(
t_filter *x, t_object *dsp64,
short *count,
double samplerate,
long maxvectorsize,
long flags)
578 bool hasFreq =
false;
582 x->
vs = maxvectorsize;
586 if (count[i] && count[j])
607 object_method(dsp64, gensym(
"dsp_add64"), x, filter_perform64_freq_q, 0, NULL);
609 object_method(dsp64, gensym(
"dsp_add64"), x, filter_perform64_freq, 0, NULL);
611 object_method(dsp64, gensym(
"dsp_add64"), x, filter_perform64_q, 0, NULL);
613 object_method(dsp64, gensym(
"dsp_add64"), x, filter_perform64, 0, NULL);
TTErr sendMessage(const TTSymbol name)
TODO: Document this function.
t_max_err filter_setType(t_filter *x, void *attr, long argc, t_atom *argv)
Method setting the type of the filter to use.
TTUInt16 numChannels
The actual number of audio channels used.
TTUInt16 vs
The vector size (number of samples per processing block)
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
std::uint16_t TTUInt16
16 bit unsigned integer
TTAudioObjectBasePtr filter
The Jamoma DSP filter unit used.
long attrBypass
ATTRIBUTE: Bypass filtering.
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
void filter_gettypes(t_filter *x)
Spew the available filter names to the dumpout for a umenu.
TTFOUNDATION_EXPORT TTEnvironment * ttEnvironment
The environment object has one instance, which is global in scope.
TTAudioObjectBase is the base class for all audio generating and processing objects in Jamoma DSP...
t_int * filter_perform_freq_q(t_int *w)
This method is called on each audio vector: Frequency and resonance set at signal rate...
size_type size() const noexcept
Return the number of elements.
TTUInt32 sr
The sample rate.
void filter_dsp(t_filter *x, t_signal **sp, short *count)
This method is called when audio is started in order to compile the audio chain.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
double TTFloat64
64 bit floating point number
t_pxobject obj
REQUIRED: The MSP 'base class'.
TTAudioSignalPtr audioIn
The Jamoma audio signal object that is used for filter input.
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
TTErr setVector(const TTChannelCount channel, const TTUInt16 vectorSize, const TTSampleValuePtr newVector)
[doxygenAppendixC_methodExample]
t_max_err filter_setQ(t_filter *x, void *attr, long argc, t_atom *argv)
Method setting the value of the resonance (Q) attribute.
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
void filter_clear(t_filter *x)
Clear the filter in case it has blown up (NaN).
TTAudioSignalPtr audioOut
The Jamoma audio signal object that us used for filter output.
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
The TTAudioSignal class represents N vectors of audio samples for M channels.
TTErr process(TTAudioSignal &in, TTAudioSignal &out)
Process the input signal, resulting in an output signal.
t_max_err filter_setFrequency(t_filter *x, void *attr, long argc, t_atom *argv)
Method setting the value of the frequency attribute.
const char * c_str() const
Return a pointer to the internal string as a C-string.
void TTDSP_EXPORT TTDSPInit(const char *pathToBinaries=NULL)
Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
TTFloat64 attrFrequency
ATTRIBUTE: Filter cutoff or center frequency, depending on the kind of filter.
TTFloat64 attrQ
ATTRIBUTE: Filter resonance.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
TTErr TTGetRegisteredClassNamesForTags(TTValue &classNames, const TTValue &searchTags)
DEPRECATED.
t_int * filter_perform_q(t_int *w)
This method is called on each audio vector: Resonance set at signal rate.
t_symbol * attrType
ATTRIBUTE: what kind of filter to use.
std::uint32_t TTUInt32
32 bit unsigned integer
TTUInt16 maxNumChannels
The maximum number of audio channels permitted.
void filter_free(t_filter *x)
Free memory etc.
t_int * filter_perform(t_int *w)
This method is called on each audio vector: Frequency and resonance set at control rate...
void filter_assist(t_filter *x, void *b, long msg, long arg, char *dst)
Assist strings for object inlets and outlets.
t_int * filter_perform_freq(t_int *w)
This method is called on each audio vector: Frequency set at signal rate.
TTFloat64 TTSampleValue
A value representing a single audio sample.
[doxygenAppendixC_copyExample]
Data structure for the tt.filter~ object.
t_max_err filter_setBypass(t_filter *x, void *attr, long argc, t_atom *argv)
Method setting the value of the bypass attribute.
void * filter_new(t_symbol *msg, short argc, t_atom *argv)
New object create method.