13 typedef struct _ttclip {
25 void ttclip_tilde_setup();
28 void* ttclip_new(t_symbol *s,
long ac, t_atom *at);
29 void ttclip_free(t_ttclip *x);
30 void ttclip_setlowbound(t_ttclip *x,
float f);
31 void ttclip_sethighbound(t_ttclip *x,
float f);
32 t_int* ttclip_perform(t_int *w);
33 void ttclip_dsp(t_ttclip *x, t_signal **sp);
37 static t_class *ttclip_class;
41 void ttclip_tilde_setup(
void)
45 ttclip_class = class_new(gensym(
"ttclip~"), (t_newmethod)ttclip_new, (t_method)ttclip_free,
sizeof(t_ttclip), 0, A_GIMME, 0);
47 CLASS_MAINSIGNALIN(ttclip_class, t_ttclip, f);
48 class_addmethod(ttclip_class, (t_method)ttclip_dsp, gensym(
"dsp"), A_NULL);
49 class_addmethod(ttclip_class, (t_method)ttclip_setlowbound, gensym(
"lowbound"), A_FLOAT, 0);
50 class_addmethod(ttclip_class, (t_method)ttclip_sethighbound, gensym(
"highbound"), A_FLOAT, 0);
52 class_sethelpsymbol(ttclip_class, gensym(
"help-ttclip~.pd"));
58 void *ttclip_new(t_symbol *s,
long ac, t_atom *at)
60 t_ttclip* x = (t_ttclip*)pd_new(ttclip_class);
65 outlet_new(&x->obj, gensym(
"signal"));
67 err = TTObjectInstantiate(
TT(
"clipper"), &x->clipper, numChannels);
69 post(
"ERROR FROM TTCLIP_NEW: %ld", err);
71 TTObjectInstantiate(kTTSym_audiosignal, &x->audioIn, numChannels);
72 TTObjectInstantiate(kTTSym_audiosignal, &x->audioOut, numChannels);
78 void ttclip_free(t_ttclip *x)
80 TTObjectRelease(&x->clipper);
81 TTObjectRelease(&x->audioIn);
82 TTObjectRelease(&x->audioOut);
89 void ttclip_setlowbound(t_ttclip *x,
float f)
91 x->clipper->setAttributeValue(
TT(
"lowBound"), f);
95 void ttclip_sethighbound(t_ttclip *x,
float f)
97 x->clipper->setAttributeValue(
TT(
"highBound"), f);
102 t_int *ttclip_perform(t_int *w)
104 t_ttclip* x = (t_ttclip*)(w[1]);
105 t_float* in = (t_float*)(w[2]);
106 t_float* out = (t_float*)(w[3]);
107 TTUInt16 vs = x->audioIn->getVectorSizeAsInt();
109 x->audioIn->setVector(0, vs, (t_float*)in);
110 x->clipper->process(x->audioIn, x->audioOut);
111 x->audioOut->getVector(0, vs, (t_float*)out);
118 void ttclip_dsp(t_ttclip *x, t_signal **sp)
120 x->audioIn->setNumChannels(1);
121 x->audioOut->setNumChannels(1);
122 x->audioIn->setVectorSizeWithInt(sp[0]->s_n);
123 x->audioOut->setVectorSizeWithInt(sp[0]->s_n);
125 x->audioOut->alloc();
127 x->clipper->setAttributeValue(kTTSym_sampleRate, sp[0]->s_sr);
129 dsp_add(ttclip_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
std::uint16_t TTUInt16
16 bit unsigned integer
Wrap audio objects for convenience.
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
The TTAudioSignal class represents N vectors of audio samples for M channels.
void TTDSP_EXPORT TTDSPInit(const char *pathToBinaries=NULL)
Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
TTErr
Jamoma Error Codes Enumeration of error codes that might be returned by any of the TTBlue functions a...