Jamoma API  0.6.0.a19
j.filter~.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationMaxExternalsDSP
4  *
5  * @brief j.filter~ : wraps the #TTFilter class as a a Jamoma external for MSP
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright © 2008 by Timothy Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 #include "TTClassWrapperMax.h"
17 #include "ext.h" // Max Header
18 #include "z_dsp.h" // MSP Header
19 #include "ext_strings.h" // String Functions
20 #include "commonsyms.h" // Common symbols used by the Max 4.5 API
21 #include "ext_obex.h" // Max Object Extensions (attributes) Header
22 
23 #include "TTDSP.h" // Jamoma Interfaces...
24 
25 #define DEFAULT_F 1000
26 #define DEFAULT_Q 18
27 
28 
29 /** Data structure for the tt.filter~ object. */
30 typedef struct _filter {
31  t_pxobject obj; ///< REQUIRED: The MSP 'base class'
32  TTAudioObjectBasePtr filter; ///< The Jamoma DSP filter unit used
33  TTAudioSignalPtr audioIn; ///< The Jamoma audio signal object that is used for filter input
34  TTAudioSignalPtr audioOut; ///< The Jamoma audio signal object that us used for filter output
35  TTUInt16 maxNumChannels; ///< The maximum number of audio channels permitted
36  TTUInt16 numChannels; ///< The actual number of audio channels used
37  TTUInt16 vs; ///< The vector size (number of samples per processing block)
38  TTUInt32 sr; ///< The sample rate
39  long attrBypass; ///< ATTRIBUTE: Bypass filtering
40  TTFloat64 attrFrequency; ///< ATTRIBUTE: Filter cutoff or center frequency, depending on the kind of filter
41  TTFloat64 attrQ; ///< ATTRIBUTE: Filter resonance
42  t_symbol *attrType; ///< ATTRIBUTE: what kind of filter to use
43  t_symbol *attrMode; // Most filters don't have this attribute...
44 } t_filter;
45 
46 
47 // Prototypes for methods: need a method for each incoming message type
48 
49 /** New object create method. */
50 void* filter_new(t_symbol *msg, short argc, t_atom *argv);
51 
52 /** Free memory etc. when an object is destroyed. */
53 void filter_free(t_filter *x);
54 
55 /** Assist strings for object inlets and outlets. */
56 void filter_assist(t_filter *x, void *b, long msg, long arg, char *dst);
57 
58 /** This method is called on each audio vector: Frequency and resonance set at control rate. */
59 t_int* filter_perform(t_int *w);
60 
61 /** This method is called on each audio vector: Frequency set at signal rate. */
62 t_int* filter_perform_freq(t_int *w);
63 
64 /** This method is called on each audio vector: Resonance set at signal rate. */
65 t_int* filter_perform_q(t_int *w);
66 
67 /** This method is called on each audio vector: Frequency and resonance set at signal rate. */
68 t_int* filter_perform_freq_q(t_int *w);
69 
70 /** This method is called when audio is started in order to compile the audio chain. */
71 void filter_dsp(t_filter *x, t_signal **sp, short *count);
72 void filter_dsp64(t_filter *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags); // DSP64 Method
73 
74 /** Clear the filter in case it has blown up (NaN). */
75 void filter_clear(t_filter *x);
76 
77 /** Method setting the value of the bypass attribute. */
78 t_max_err filter_setBypass(t_filter *x, void *attr, long argc, t_atom *argv);
79 
80 /** Method setting the value of the frequency attribute. */
81 t_max_err filter_setFrequency(t_filter *x, void *attr, long argc, t_atom *argv);
82 
83 /** Method setting the value of the resonance (Q) attribute. */
84 t_max_err filter_setQ(t_filter *x, void *attr, long argc, t_atom *argv);
85 
86 /** Method setting the type of the filter to use. */
87 t_max_err filter_setType(t_filter *x, void *attr, long argc, t_atom *argv);
88 
89 /** Spew the available filter names to the dumpout for a umenu. */
90 void filter_gettypes(t_filter *x);
91 
92 
93 t_max_err filter_setMode(t_filter *x, void *attr, long argc, t_atom *argv);
94 
95 
96 // Globals
97 t_class *filter_class; // Required. Global pointing to this class
98 
99 
100 /************************************************************************************/
101 // Main() Function
102 
103 int C74_EXPORT main(void)
104 {
105  t_class *c;
106 
107  common_symbols_init();
108  TTDSPInit();
109 
110  c = class_new("j.filter~",(method)filter_new, (method)filter_free, sizeof(t_filter), (method)0L, A_GIMME, 0);
111 
112  class_addmethod(c, (method)filter_gettypes, "getTypes", 0L);
113  class_addmethod(c, (method)filter_clear, "clear", 0L);
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);
119 
120  CLASS_ATTR_LONG(c, "bypass", 0, t_filter, attrBypass);
121  CLASS_ATTR_ACCESSORS(c, "bypass", NULL, filter_setBypass);
122  CLASS_ATTR_STYLE(c, "bypass", 0, "onoff");
123 
124  CLASS_ATTR_FLOAT(c, "frequency", 0, t_filter, attrFrequency);
125  CLASS_ATTR_ACCESSORS(c, "frequency", NULL, filter_setFrequency);
126 
127  CLASS_ATTR_FLOAT(c, "q", 0, t_filter, attrQ);
128  CLASS_ATTR_ACCESSORS(c, "q", NULL, filter_setQ);
129 
130  CLASS_ATTR_SYM(c, "type", 0, t_filter, attrType);
131  CLASS_ATTR_ACCESSORS(c, "type", NULL, filter_setType);
132 
133  CLASS_ATTR_SYM(c, "mode", 0, t_filter, attrMode);
134  CLASS_ATTR_ACCESSORS(c, "mode", NULL, filter_setMode);
135 
136  class_dspinit(c);
137  class_register(CLASS_BOX, c);
138  filter_class = c;
139 
140  return 0;
141 }
142 
143 
144 /************************************************************************************/
145 // Object Creation Method
146 
147 void* filter_new(t_symbol *msg, short argc, t_atom *argv)
148 {
149  t_filter *x;
150  TTValue sr(sys_getsr());
151  long attrstart = attr_args_offset(argc, argv); // support normal arguments
152  short i;
153 
154  x = (t_filter *)object_alloc(filter_class);
155  if (x) {
156  // Setting default attribute values
157  x->attrBypass = 0;
158  x->attrFrequency = DEFAULT_F;
159  x->attrQ = DEFAULT_Q;
160  x->attrMode = _sym_nothing;
161 
162  x->maxNumChannels = 2; // An initial argument to this object will set the maximum number of channels
163  if (attrstart && argv)
164  x->maxNumChannels = atom_getlong(argv);
165 
166  x->sr = sr;
167  ttEnvironment->setAttributeValue(kTTSym_sampleRate, sr);
168  object_attr_setsym(x, _sym_type, gensym("lowpass.butterworth.2"));
169 
170  TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioIn, x->maxNumChannels);
171  TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioOut, x->maxNumChannels);
172 
173  attr_args_process(x,argc,argv); // handle attribute args
174 
175  object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x,NULL)); // dumpout
176  dsp_setup((t_pxobject *)x, x->maxNumChannels + 2); // inlets: signals + freq + q
177  for (i=0; i < x->maxNumChannels; i++)
178  outlet_new((t_pxobject *)x, "signal"); // outlets
179 
180  x->obj.z_misc = Z_NO_INPLACE;
181  }
182  return (x); // Return the pointer
183 }
184 
185 // Memory Deallocation
187 {
188  dsp_free((t_pxobject *)x);
192 }
193 
194 
195 /************************************************************************************/
196 // Methods bound to input/inlets
197 
198 // Method for Assistance Messages
199 void filter_assist(t_filter *x, void *b, long msg, long arg, char *dst)
200 {
201  if (msg==1) { // Inlets
202  if (arg == x->maxNumChannels)
203  strcpy(dst, "(signal) Frequency");
204  else if (arg == x->maxNumChannels+1)
205  strcpy(dst, "(signal) Q-value");
206  else if (arg == 0)
207  strcpy(dst, "(signal) input 1, control messages");
208  else if (arg < x->maxNumChannels)
209  snprintf(dst, 256, "(signal) input %ld", arg+1);
210  }
211 
212  else if (msg==2) {// Outlets
213  if (arg == x->maxNumChannels)
214  strcpy(dst, "dumpout");
215  else
216  snprintf(dst, 256, "(signal) Filtered output %ld", arg+1);
217  }
218 }
219 
220 
222 {
223  x->filter->sendMessage(TT("clear"));
224 }
225 
226 
228 {
229  TTValue v;
230  t_atom a[2];
231 
232  atom_setsym(a, _sym_clear);
233  object_obex_dumpout(x, gensym("types"), 1, a);
234  atom_setsym(a, _sym_append);
235 
236  TTGetRegisteredClassNamesForTags(v, TT("filter"));
237  for (TTUInt16 i=0; i<v.size(); i++) {
238  TTSymbol classname;
239  classname = v[i];
240  atom_setsym(a+1, gensym((char*)classname.c_str()));
241  object_obex_dumpout(x, gensym("types"), 2, a);
242  }
243 }
244 
245 
246 t_max_err filter_setBypass(t_filter *x, void *attr, long argc, t_atom *argv)
247 {
248  if (argc) {
249  x->attrBypass = atom_getlong(argv);
250  x->filter->setAttributeValue(kTTSym_bypass, (TTBoolean)x->attrBypass);
251  }
252  return MAX_ERR_NONE;
253 }
254 
255 t_max_err filter_setFrequency(t_filter *x, void *attr, long argc, t_atom *argv)
256 {
257  if (argc) {
258  x->attrFrequency = atom_getfloat(argv);
259  x->filter->setAttributeValue(TT("frequency"), x->attrFrequency);
260  }
261  return MAX_ERR_NONE;
262 }
263 
264 t_max_err filter_setQ(t_filter *x, void *attr, long argc, t_atom *argv)
265 {
266  TTErr err = kTTErrNone;
267 
268  if (argc) {
269  x->attrQ = atom_getfloat(argv);
270  err = x->filter->setAttributeValue(TT("q"), x->attrQ);
271  if (err == kTTErrInvalidAttribute)
272  err = x->filter->setAttributeValue(TT("resonance"), x->attrQ);
273  }
274  return MAX_ERR_NONE;
275 }
276 
277 
278 t_max_err filter_setType(t_filter *x, void *attr, long argc, t_atom *argv)
279 {
280  if (argc) {
281  if (x->attrType != atom_getsym(argv)) { // if it hasn't changed, then jump to the end...
282  TTErr err = kTTErrNone;
283 
284  x->attrType = atom_getsym(argv);
286  if (x->filter) {
287  // Now that we have our new filter, update it with the current state of the external:
288  x->filter->setAttributeValue(TT("frequency"), x->attrFrequency);
289  err = x->filter->setAttributeValue(TT("q"), x->attrQ);
290  if (err == kTTErrInvalidAttribute)
291  err = x->filter->setAttributeValue(TT("resonance"), x->attrQ);
292  x->filter->setAttributeValue(TT("mode"), x->attrMode->s_name);
293  x->filter->setAttributeValue(kTTSym_bypass, (TTBoolean)x->attrBypass);
294  x->filter->setAttributeValue(kTTSym_sampleRate, x->sr);
295  }
296  }
297  }
298  return MAX_ERR_NONE;
299 }
300 
301 
302 t_max_err filter_setMode(t_filter *x, void *attr, long argc, t_atom *argv)
303 {
304  if (argc)
305  x->attrMode = atom_getsym(argv);
306  x->filter->setAttributeValue(TT("mode"), TT(x->attrMode->s_name));
307  return MAX_ERR_NONE;
308 }
309 
310 
311 /************************************************************************************/
312 // Audio perform methods
313 
314 // Perform (signal) Method: Frequency and q at control rate
315 t_int *filter_perform(t_int *w)
316 {
317  t_filter *x = (t_filter *)(w[1]);
318  short i, j;
319  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
320 
321  for (i=0; i<x->numChannels; i++) {
322  j = (i*2) + 1;
323  x->audioIn->setVector(i, vs, (t_float *)w[j+1]);
324  }
325 
326  if (!x->obj.z_disabled) // if we are not muted...
327  x->filter->process(x->audioIn, x->audioOut); // Actual Filter process
328 
329  for (i=0; i<x->numChannels; i++) {
330  j = (i*2) + 1;
331  x->audioOut->getVector(i, vs, (t_float *)w[j+2]);
332  }
333 
334  return w + ((x->numChannels*2)+2); // +2 = +1 for the x pointer and +1 to point to the next object
335 }
336 
337 
338 // Perform (signal) Method: Frequency at signal rate
339 t_int *filter_perform_freq(t_int *w)
340 {
341  t_filter* x = (t_filter *)(w[1]);
342  short i, j;
343  t_float* freq;
344  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
345 
346  for (i=0; i<x->numChannels; i++) {
347  j = (i*2) + 1;
348  x->audioIn->setVector(i, vs, (t_float *)w[j+1]);
349  }
350  j = (i*2) + 2;
351  freq = (t_float*)w[j];
352 
353  if (!x->obj.z_disabled) {
354  x->attrFrequency = *freq;
355  x->filter->setAttributeValue(TT("frequency"), x->attrFrequency);
356  x->filter->process(x->audioIn, x->audioOut);
357  }
358 
359  for (i=0; i<x->numChannels; i++) {
360  j = (i*2) + 1;
361  x->audioOut->getVector(i, vs, (t_float *)w[j+2]);
362  }
363 
364  return w + ((x->numChannels*2)+3); // +2 = +1 for the x pointer and +1 to point to the next object
365 }
366 
367 
368 // Perform (signal) Method: q at signal rate
369 t_int *filter_perform_q(t_int *w)
370 {
371  t_filter* x = (t_filter *)(w[1]);
372  short i, j;
373  t_float* q;
374  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
375 
376  for (i=0; i<x->numChannels; i++) {
377  j = (i*2) + 1;
378  x->audioIn->setVector(i, vs, (t_float *)w[j+1]);
379  }
380  q = (t_float*)w[(i*2) + 2];
381 
382  if (!x->obj.z_disabled) {
383  x->attrQ = *q;
384  x->filter->setAttributeValue(TT("q"), x->attrQ);
385  x->filter->process(x->audioIn, x->audioOut);
386  }
387 
388  for (i=0; i<x->numChannels; i++) {
389  j = (i*2) + 1;
390  x->audioOut->getVector(i, vs, (t_float *)w[j+2]);
391  }
392 
393  return w + ((x->numChannels*2)+3); // +2 = +1 for the x pointer and +1 to point to the next object
394 }
395 
396 
397 // Perform (signal) Method: Frequency and q at signal rate
398 t_int *filter_perform_freq_q(t_int *w)
399 {
400  t_filter* x = (t_filter *)(w[1]);
401  short i, j;
402  t_float* freq;
403  t_float* q;
404  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
405 
406  for (i=0; i<x->numChannels; i++) {
407  j = (i*2) + 1;
408  x->audioIn->setVector(i, vs, (t_float *)w[j+1]);
409  }
410  freq = (t_float*)w[(i*2) + 2];
411  q = (t_float*)w[(i*2) + 3];
412 
413  if (!x->obj.z_disabled) {
414  x->attrFrequency = *freq;
415  x->attrQ = *q;
416  x->filter->setAttributeValue(TT("frequency"), x->attrFrequency);
417  x->filter->setAttributeValue(TT("q"), x->attrQ);
418  x->filter->process(x->audioIn, x->audioOut);
419  }
420 
421  for (i=0; i<x->numChannels; i++) {
422  j = (i*2) + 1;
423  x->audioOut->getVector(i, vs, (t_float *)w[j+2]);
424  }
425 
426  return w + ((x->numChannels*2)+4); // +2 = +1 for the x pointer and +1 to point to the next object
427 }
428 /************************************************************************************/
429 // Audio perform64 methods
430 
431 // Perform (signal) Method: Frequency and q at control rate
432 void filter_perform64(t_filter *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam)
433 {
434  short i;
435  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
436 
437  for (i=0; i<x->numChannels; i++)
438  x->audioIn->setVector(i, vs, ins[i]);
439 
440  x->filter->process(x->audioIn, x->audioOut); // Actual Filter process
441 
442  for (i=0; i<x->numChannels; i++)
443  x->audioOut->getVectorCopy(i, vs, outs[i]);
444 }
445 
446 
447 // Perform (signal) Method: Frequency at signal rate
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)
449 
450 {
451  short i;
452  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
453  TTSampleValue* freq;
454 
455  for (i=0; i<x->numChannels; i++)
456  x->audioIn->setVector(i, vs, ins[i]);
457 
458  freq = ins[i];
459  x->attrFrequency = *freq;
460  x->filter->setAttributeValue(TT("frequency"), x->attrFrequency);
461  x->filter->process(x->audioIn, x->audioOut);
462 
463  for (i=0; i<x->numChannels; i++)
464  x->audioOut->getVectorCopy(i, vs, outs[i]);
465 
466 }
467 
468 
469 // Perform (signal) Method: q at signal rate
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)
471 {
472  short i;
473  TTSampleValue* q;
474  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
475 
476  for (i=0; i<x->numChannels; i++)
477  x->audioIn->setVector(i, vs, ins[i]);
478 
479  q = ins[i+1];
480  x->attrQ = *q;
481  x->filter->setAttributeValue(TT("q"), x->attrQ);
482  x->filter->process(x->audioIn, x->audioOut);
483 
484  for (i=0; i<x->numChannels; i++)
485  x->audioOut->getVectorCopy(i, vs, outs[i]);
486 }
487 
488 // Perform (signal) Method: Frequency and q at signal rate
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)
490 {
491  short i;
492  TTSampleValue* freq;
493  TTSampleValue* q;
494  TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
495 
496  for (i=0; i<x->numChannels; i++)
497  x->audioIn->setVector(i, vs, ins[i]);
498 
499  freq = ins[i];
500  q = ins[i+1];
501  x->attrFrequency = *freq;
502  x->attrQ = *q;
503  x->filter->setAttributeValue(TT("frequency"), x->attrFrequency);
504  x->filter->setAttributeValue(TT("q"), x->attrQ);
505  x->filter->process(x->audioIn, x->audioOut);
506 
507 
508  for (i=0; i<x->numChannels; i++)
509  x->audioOut->getVectorCopy(i, vs, outs[i]);
510 }
511 
512 /************************************************************************************/
513 // DSP Setup
514 
515 // DSP Method
516 void filter_dsp(t_filter *x, t_signal **sp, short *count)
517 {
518  short i, j, k=0;
519  void **audioVectors = NULL;
520  bool hasFreq = false;
521  bool hasQ = false;
522 
523  audioVectors = (void**)sysmem_newptr(sizeof(void*) * ((x->maxNumChannels * 2) + 1));
524  audioVectors[k] = x;
525  k++;
526 
527  x->numChannels = 0;
528  x->vs = 0;
529  for (i=0; i < x->maxNumChannels; i++) {
530  j = x->maxNumChannels + i + 2;
531  if (count[i] && count[j]) {
532  x->numChannels++;
533  if (sp[i]->s_n > x->vs)
534  x->vs = sp[i]->s_n;
535 
536  audioVectors[k] = sp[i]->s_vec;
537  k++;
538  audioVectors[k] = sp[j]->s_vec;
539  k++;
540  }
541  }
542  if (count[x->maxNumChannels]) { // frequency inlet
543  audioVectors[k] = sp[x->maxNumChannels]->s_vec;
544  k++;
545  hasFreq = true;
546  }
547  if (count[x->maxNumChannels+1]) { // q inlet
548  audioVectors[k] = sp[x->maxNumChannels+1]->s_vec;
549  k++;
550  hasQ = true;
551  }
552 
553  x->audioIn->setAttributeValue(kTTSym_numChannels, x->numChannels);
554  x->audioOut->setAttributeValue(kTTSym_numChannels, x->numChannels);
555  x->audioIn->setAttributeValue(kTTSym_vectorSize, x->vs);
556  x->audioOut->setAttributeValue(kTTSym_vectorSize, x->vs);
557  //audioIn will be set in the perform method
558  x->audioOut->sendMessage(kTTSym_alloc);
559 
560  x->sr = sp[0]->s_sr;
561  x->filter->setAttributeValue(kTTSym_sampleRate, sp[0]->s_sr);
562 
563  if (hasFreq && hasQ)
564  dsp_addv(filter_perform_freq_q, k, audioVectors);
565  else if (hasFreq)
566  dsp_addv(filter_perform_freq, k, audioVectors);
567  else if (hasQ)
568  dsp_addv(filter_perform_q, k, audioVectors);
569  else
570  dsp_addv(filter_perform, k, audioVectors);
571 
572  sysmem_freeptr(audioVectors);
573 }
574 
575 void filter_dsp64(t_filter *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags)
576 {
577  short i, j;
578  bool hasFreq = false;
579  bool hasQ = false;
580 
581  x->numChannels = 0;
582  x->vs = maxvectorsize;
583 
584  for (i=0; i < x->maxNumChannels; i++) {
585  j = x->maxNumChannels + i + 2;
586  if (count[i] && count[j])
587  x->numChannels++;
588  }
589 
590  if (count[x->maxNumChannels]) // frequency inlet
591  hasFreq = true;
592 
593  if (count[x->maxNumChannels+1]) // q inlet
594  hasQ = true;
595 
596  x->audioIn->setAttributeValue(kTTSym_numChannels, x->numChannels);
597  x->audioOut->setAttributeValue(kTTSym_numChannels, x->numChannels);
598  x->audioIn->setAttributeValue(kTTSym_vectorSize, x->vs);
599  x->audioOut->setAttributeValue(kTTSym_vectorSize, x->vs);
600  //audioIn will be set in the perform method
601  x->audioOut->sendMessage(kTTSym_alloc);
602 
603  x->sr = samplerate;
604  x->filter->setAttributeValue(kTTSym_sampleRate, samplerate);
605 
606  if (hasFreq && hasQ)
607  object_method(dsp64, gensym("dsp_add64"), x, filter_perform64_freq_q, 0, NULL);
608  else if (hasFreq)
609  object_method(dsp64, gensym("dsp_add64"), x, filter_perform64_freq, 0, NULL);
610  else if (hasQ)
611  object_method(dsp64, gensym("dsp_add64"), x, filter_perform64_q, 0, NULL);
612  else
613  object_method(dsp64, gensym("dsp_add64"), x, filter_perform64, 0, NULL);
614 }
615 
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.
Definition: j.filter~.cpp:278
TTUInt16 numChannels
The actual number of audio channels used.
Definition: j.filter~.cpp:36
TTUInt16 vs
The vector size (number of samples per processing block)
Definition: j.filter~.cpp:37
bool TTBoolean
Boolean flag, same as Boolean on the Mac.
Definition: TTBase.h:167
std::uint16_t TTUInt16
16 bit unsigned integer
Definition: TTBase.h:176
TTAudioObjectBasePtr filter
The Jamoma DSP filter unit used.
Definition: j.filter~.cpp:32
long attrBypass
ATTRIBUTE: Bypass filtering.
Definition: j.filter~.cpp:39
TTErr TTObjectBaseRelease(TTObjectBasePtr *anObject)
DEPRECATED.
void filter_gettypes(t_filter *x)
Spew the available filter names to the dumpout for a umenu.
Definition: j.filter~.cpp:227
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...
Definition: j.filter~.cpp:398
size_type size() const noexcept
Return the number of elements.
TTUInt32 sr
The sample rate.
Definition: j.filter~.cpp:38
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.
Definition: j.filter~.cpp:516
Jamoma DSP Library.
TTErr setAttributeValue(const TTSymbol name, TTValue &value)
Set an attribute value for an object.
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
t_pxobject obj
REQUIRED: The MSP 'base class'.
Definition: j.filter~.cpp:31
TTAudioSignalPtr audioIn
The Jamoma audio signal object that is used for filter input.
Definition: j.filter~.cpp:33
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
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.
Definition: j.filter~.cpp:264
int C74_EXPORT main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
Definition: j.filter~.cpp:103
void filter_clear(t_filter *x)
Clear the filter in case it has blown up (NaN).
Definition: j.filter~.cpp:221
TTAudioSignalPtr audioOut
The Jamoma audio signal object that us used for filter output.
Definition: j.filter~.cpp:34
The TTSymbol class is used to represent a string and efficiently pass and compare that string...
Definition: TTSymbol.h:26
TTErr TTObjectBaseInstantiate(const TTSymbol className, TTObjectBasePtr *returnedObjectPtr, const TTValue arguments)
DEPRECATED.
The TTAudioSignal class represents N vectors of audio samples for M channels.
Definition: TTAudioSignal.h:57
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.
Definition: j.filter~.cpp:255
const char * c_str() const
Return a pointer to the internal string as a C-string.
Definition: TTSymbol.h:77
void TTDSP_EXPORT TTDSPInit(const char *pathToBinaries=NULL)
Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
Definition: TTDSP.cpp:30
TTFloat64 attrFrequency
ATTRIBUTE: Filter cutoff or center frequency, depending on the kind of filter.
Definition: j.filter~.cpp:40
TTFloat64 attrQ
ATTRIBUTE: Filter resonance.
Definition: j.filter~.cpp:41
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...
Definition: TTBase.h:342
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.
Definition: j.filter~.cpp:369
t_symbol * attrType
ATTRIBUTE: what kind of filter to use.
Definition: j.filter~.cpp:42
std::uint32_t TTUInt32
32 bit unsigned integer
Definition: TTBase.h:178
No Error.
Definition: TTBase.h:343
TTUInt16 maxNumChannels
The maximum number of audio channels permitted.
Definition: j.filter~.cpp:35
void filter_free(t_filter *x)
Free memory etc.
Definition: j.filter~.cpp:186
t_int * filter_perform(t_int *w)
This method is called on each audio vector: Frequency and resonance set at control rate...
Definition: j.filter~.cpp:315
void filter_assist(t_filter *x, void *b, long msg, long arg, char *dst)
Assist strings for object inlets and outlets.
Definition: j.filter~.cpp:199
t_int * filter_perform_freq(t_int *w)
This method is called on each audio vector: Frequency set at signal rate.
Definition: j.filter~.cpp:339
TTFloat64 TTSampleValue
A value representing a single audio sample.
Definition: TTBase.h:230
[doxygenAppendixC_copyExample]
Definition: TTValue.h:34
Data structure for the tt.filter~ object.
Definition: j.filter~.cpp:30
Bad Attribute specified.
Definition: TTBase.h:348
t_max_err filter_setBypass(t_filter *x, void *attr, long argc, t_atom *argv)
Method setting the value of the bypass attribute.
Definition: j.filter~.cpp:246
void * filter_new(t_symbol *msg, short argc, t_atom *argv)
New object create method.
Definition: j.filter~.cpp:147