// Create void *fade_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments short i; t_fade *x = (t_fade *)object_alloc(s_fade_class); if(x){ object_obex_store((void *)x, _sym_dumpout, (object *)outlet_new(x, NULL)); // dumpout x->numChannels = 1; if(attrstart && argv){ int argument = atom_getlong(argv); x->numChannels = TTClip(argument, 1, MAX_NUM_CHANNELS); } dsp_setup((t_pxobject *)x, (x->numChannels * 2) + 1); // Create Object and N Inlets (last argument) x->x_obj.z_misc = Z_NO_INPLACE; // ESSENTIAL! for(i=0; i< (x->numChannels); i++) outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet //x->xfade = new TTCrossfade(x->numChannels); // Constructors TTObjectBaseInstantiate(TT("crossfade"), &x->xfade, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioIn1, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioIn2, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioInControl, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->audioOut, x->numChannels); x->xfade->setAttributeValue(TT("mode"), TT("lookup")); x->xfade->setAttributeValue(TT("shape"), TT("equalPower")); x->xfade->setAttributeValue(TT("position"), 0.5); attr_args_process(x, argc, argv); // handle attribute args } return (x); // Return the pointer }
// Perform (signal) Method t_int *binmod_perform(t_int *w) { t_float *in1 = (t_float *)(w[1]); // Input: t_float *in2 = (t_float *)(w[2]); // Input: t_float *in3 = (t_float *)(w[3]); // Input: index t_float *out1 = (t_float *)(w[4]); // Output t_float *out2 = (t_float *)(w[5]); // Output t_binmod *x = (t_binmod *)(w[6]); // Pointer int n = (int)(w[7]); // Vector Size (FFT size in pfft~) if(x->x_obj.z_disabled) goto out; if(x->attr_bypass){ while(n--){ *out1++ = *in1++; *out2++ = *in2++; } goto out; } // THIS IS DONE IN THE ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib ROUTINE ALREADY // n = x->tempsig->vectorsize = taptools_audio::clip(n, 0, MAX_NUM_LFOS-1); // insure that the vector isn't too big while(n--){ x->lfos[TTClip(int(*in3++), 0, MAX_NUM_LFOS-1)]->dsp_vector_calc(x->tempsig); // x->lfos[0]->dsp_vector_calc(x->tempsig); *out1++ = *in1++ * *(x->tempsig->vector); // apply the lfo to the first signal *out2++ = *in2++ * *(x->tempsig->vector); // apply the lfo to the second signal } out: return (w + 8); }
// Create void *out_new(t_symbol *s, long argc, t_atom *argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments t_out *x = (t_out *)object_alloc(out_class); short i; if(x){ x->dumpout = outlet_new(x, NULL); object_obex_store((void *)x, jps_dumpout, (object *)x->dumpout); // setup the dumpout x->numOutputs = 1; x->attr_preview = 0; x->preview_object = NULL; x->attr_bypass = 0; x->attr_mute = 0; x->attr_mix = 100; // Assume 100%, so that processed signal is passed through if @has_mix is false if(attrstart > 0){ int argument = atom_getlong(argv); x->numOutputs = TTClip(argument, 1, MAX_NUM_CHANNELS); } #ifdef JCOM_OUT_TILDE if(x->numOutputs > 0) dsp_setup((t_pxobject *)x, x->numOutputs); // Create Object and Inlets else dsp_setup((t_pxobject *)x, 1); // Create Object and Inlets x->common.ob.z_misc = Z_NO_INPLACE | Z_PUT_LAST; // Z_PUT_LAST so that thispoly~ gets it's message properly? for(i=0; i < (x->numOutputs); i++) outlet_new((t_pxobject *)x, "signal"); // Create a signal Outlet x->clock = clock_new(x, (method)update_meters); x->clock_is_set = 0; TTObjectInstantiate(kTTSym_audiosignal, &x->audioIn, x->numOutputs); TTObjectInstantiate(kTTSym_audiosignal, &x->audioOut, x->numOutputs); TTObjectInstantiate(kTTSym_audiosignal, &x->audioTemp, x->numOutputs); TTObjectInstantiate(kTTSym_audiosignal, &x->zeroSignal, x->numOutputs); TTObjectInstantiate(TT("crossfade"), &x->xfade, x->numOutputs); x->xfade->setAttributeValue(TT("position"), 1.0); TTObjectInstantiate(TT("gain"), &x->gain, x->numOutputs); TTObjectInstantiate(TT("ramp"), &x->ramp_gain, x->numOutputs); TTObjectInstantiate(TT("ramp"), &x->ramp_xfade, x->numOutputs); // out_alloc(x, sys_getblksize()); // allocates the vectors for the audio signals x->gain->setAttributeValue(TT("linearGain"), 1.0); #else for(i=x->numOutputs-1; i >= 1; i--) x->inlet[i] = proxy_new(x, i, 0L); for(i=x->numOutputs-1; i >= 0; i--) x->outlet[i] = outlet_new(x, 0L); #endif jcom_core_subscriber_new_common(&x->common, jps__jcom_out__, jps_subscribe_out); jcom_core_subscriber_setcustomsubscribe_method(&x->common, &out_subscribe); attr_args_process(x, argc, argv); // handle attribute args jcom_core_subscriber_subscribe((t_jcom_core_subscriber_common*)x); } return (x); // Return the pointer }
TTErr TTLowpassTwoPole::setResonance(const TTValue& newValue) { mResonance = TTClip(TTFloat64(newValue), 0.001, 100.0); mNegOneOverResonance = -1.0/mResonance; calculateCoefficients(); return kTTErrNone; }
void colortrack_sethuevar(t_max_jit_colortrack *x, short tracker_num, short value) { x->hue_variation[tracker_num] = TTClip(value, (short)0, (short)359); x->min[tracker_num][HUE] = TTOneWrap(x->hue[tracker_num] - x->hue_variation[tracker_num], 0L, 359L); x->max[tracker_num][HUE] = TTOneWrap(x->hue[tracker_num] + x->hue_variation[tracker_num], 0L, 359L); if(x->min[tracker_num][HUE] > x->max[tracker_num][HUE]) x->hue_check[tracker_num] = 1; else x->hue_check[tracker_num] = 0; }
void meter_dopaint_vertical(t_meter *x, t_object *view) { t_rect rect; t_jgraphics* g; double level = TTClip(x->envelope, 0.0f, 1.0f); double position; double peakPosition; t_jrgba c; if (level > 0.0) level = pow(level, kTTGainMidiPowerInv); // this is taken from the midi conversion in the Gain Dataspace g = (t_jgraphics*) patcherview_get_jgraphics(view); // obtain graphics context jbox_get_rect_for_view((t_object *)x, view, &rect); // this is the box rectangle -- but we draw relative to 0 0, and thus only care about width & height rect.x = 0; rect.y = 0; position = rect.height * level * 0.96; peakPosition = rect.height * x->peak * 0.96; if (level > x->peak) x->peak = level; // TODO: Can we export this from the kernel??? // jgraphics_image_surface_draw_fast(g, x->gradientSurface); jgraphics_image_surface_draw(g, x->gradientSurface, x->gradientRect, rect); jgraphics_set_source_jrgba(g, &x->attrBgColor); jgraphics_rectangle_fill_fast(g, 0, 0, rect.width, rect.height-position); if (x->envelope > 1.0 || x->peak > 1.0) { c.red = 1.0; c.green = c.blue = 0.0; c.alpha = 1.0; jgraphics_set_source_jrgba(g, &c); jgraphics_rectangle_fill_fast(g, 0, 0, rect.width, rect.height * .04); } else { c.red = peakPosition / x->gradientRect.height; c.green = 1.0; c.blue = 0.0; c.alpha = 1.0; jgraphics_set_source_jrgba(g, &c); // TODO: Can we export this from the kernel??? // jgraphics_line_draw_fast(g, rect.width * level * 0.96, 0, rect.width * level * 0.96, rect.height, 1.0); jgraphics_move_to(g, 0.0, rect.height - peakPosition); jgraphics_line_to(g, rect.width, rect.height - peakPosition); jgraphics_set_line_width(g, 1.0); jgraphics_stroke(g); } }
// Perform (signal) Method t_int *diff_perform(t_int *w) { t_float *in = (t_float *)(w[1]); // Input t_float *out = (t_float *)(w[2]); // Output t_diff *x = (t_diff *)(w[3]); // Pointer int n = (int)(w[4]); // Vector Size double val; if (x->x_obj.z_disabled) return (w+5); while(--n){ val = *++in; // Input val = val - x->diff_b1; // 6dB per octave highpass val = TTClip(val, -1., 1.); // Clip *++out = val; // Output x->diff_b1 = val; // Store Feedback Sample } return (w + 5); // Return a pointer to the NEXT object in the ../../../../Jamoma/Core/DSP/library/build/JamomaDSP.dylib call chain }
void diff_perform64(t_diff *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam) { double *in = ins[0]; double *out = outs[0]; int n = sampleframes; double val; if (x->x_obj.z_disabled) return; while(--n){ val = *++in; // Input val = val - x->diff_b1; // 6dB per octave highpass val = TTClip(val, -1., 1.); // Clip *++out = val; // Output x->diff_b1 = val; // Store Feedback Sample } return; }
// Create void* gain_new(t_symbol* s, long argc, t_atom* argv) { long attrstart = attr_args_offset(argc, argv); // support normal arguments short i; t_gain* x = (t_gain*)object_alloc(s_gain_class); if(x){ object_obex_store((void*)x, _sym_dumpout, (object*)outlet_new(x, NULL)); // dumpout x->numChannels = 1; if(attrstart && argv){ int argument = atom_getlong(argv); x->numChannels = TTClip(argument, 1, MAX_NUM_CHANNELS); } dsp_setup((t_pxobject*)x, x->numChannels * 2); // Create Object and Inlets x->obj.z_misc = Z_NO_INPLACE; // ESSENTIAL! for(i=0; i < x->numChannels; i++) outlet_new((t_pxobject*)x, "signal"); // Create a signal Outlet //x->xfade = new TTCrossfade(x->numChannels); // Constructors //x->gain = new TTGain(x->numChannels); TTObjectBaseInstantiate(TT("crossfade"), &x->xfade, x->numChannels); TTObjectBaseInstantiate(TT("gain"), &x->gain, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->signalTemp, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->signalOut, x->numChannels); TTObjectBaseInstantiate(kTTSym_audiosignal, &x->signalIn, x->numChannels*2); //x->signalTemp = new TTAudioSignal(x->numChannels); //x->signalOut = new TTAudioSignal(x->numChannels); //x->signalIn = new TTAudioSignal(x->numChannels*2); x->xfade->setAttributeValue(TT("position"), 1.0); // defaults x->gain->setAttributeValue(TT("linearGain"), 0.0); x->attrBypass = 0; x->attrGain = 0; attr_args_process(x, argc, argv); // handle attribute args } return (x); // Return the pointer }
void *bits_new(t_symbol *s, long argc, t_atom *argv) { t_bits *x; x = (t_bits *)object_alloc(bits_class); if(x){ x->my_outlet[1] = outlet_new(x,0L); // create an outlet (this is my outlet) and store the pointer in the struct x->my_outlet[0] = outlet_new(x,0L); // create an outlet (this is my outlet) and store the pointer in the struct object_obex_store((void *)x, _sym_dumpout, (object *)x->my_outlet[1]); // dumpout x->mode = ps_bits2ints; // Set the default before I go loading in values from the attributes x->matrix_width = 8; //no normal args, no matrices attr_args_process(x,argc,argv); //handle attribute args // Check the mode attributes to make sure they are valid (i.e. the user didn't make a typo) if((x->mode != ps_bits2ints) && (x->mode != ps_ints2bits) && (x->mode != ps_matrixctrl2ints)&& (x->mode != ps_ints2matrixctrl)) x->matrix_width = TTClip(x->matrix_width, 2L, 31L); } return (x); // return the pointer to our new instantiation }
// Set Phase t_max_err binmod_phase_set(t_binmod *x, void *attr, long argc, t_atom *argv) { float value; long index; short i; switch(argv[0].a_type){ case A_LONG: // Index, Value Pair index = atom_getlong(argv); value = atom_getfloat(argv+1); x->lfos[index]->set_attr(tt_lfo::k_phase, TTClip(value, 0.f, 1.f)); x->attr_depth[index] = value; if(index > x->attr_depth_len-1) x->attr_depth_len = index + 1; break; case A_FLOAT: // List of Values x->attr_phase_len = argc; for(i=0; i < argc; i++){ x->attr_phase[i] = atom_getfloat(argv+i); x->lfos[i]->set_attr(tt_lfo::k_phase, TTClip<double>(atom_getfloat(argv+i), 0.f, 1.f)); } break; } return MAX_ERR_NONE; }
void colortrack_setbrightnessvar(t_max_jit_colortrack *x, short tracker_num, short value) { x->brightness_variation[tracker_num] = TTClip(value, (short)0, (short)255); x->min[tracker_num][BRIGHTNESS] = TTClip(x->brightness[tracker_num] - x->brightness_variation[tracker_num], 0L, 255L); x->max[tracker_num][BRIGHTNESS] = TTClip(x->brightness[tracker_num] + x->brightness_variation[tracker_num], 0L, 255L); }
void colortrack_setsaturationvar(t_max_jit_colortrack *x, short tracker_num, short value) { x->saturation_variation[tracker_num] = TTClip(value, (short)0, (short)255); x->min[tracker_num][SATURATION] = TTClip(x->saturation[tracker_num] - x->saturation_variation[tracker_num], 0L, 255L); x->max[tracker_num][SATURATION] = TTClip(x->saturation[tracker_num] + x->saturation_variation[tracker_num], 0L, 255L); }