From 526b5580dabbfed7cfe5439dc3a90ec727f563c2 Mon Sep 17 00:00:00 2001 From: Peter D'Hoye Date: Sun, 24 May 2009 21:28:16 +0000 Subject: Cut the files in half and it might work better (note to self: check your tree is really clean before patching) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21070 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/pdbox/PDa/intern/biquad~.c | 125 ------------ apps/plugins/pdbox/PDa/intern/bp~.c | 138 ------------- apps/plugins/pdbox/PDa/intern/clip~.c | 57 ------ apps/plugins/pdbox/PDa/intern/cos_table.h | 3 - apps/plugins/pdbox/PDa/intern/cos~.c | 60 ------ apps/plugins/pdbox/PDa/intern/dbtopow~.c | 51 ----- apps/plugins/pdbox/PDa/intern/dbtorms~.c | 52 ----- apps/plugins/pdbox/PDa/intern/delay.h | 41 ---- apps/plugins/pdbox/PDa/intern/delread~.c | 99 --------- apps/plugins/pdbox/PDa/intern/delwrite~.c | 83 -------- apps/plugins/pdbox/PDa/intern/env~.c | 128 ------------ apps/plugins/pdbox/PDa/intern/ftom~.c | 43 ---- apps/plugins/pdbox/PDa/intern/hip~.c | 91 --------- apps/plugins/pdbox/PDa/intern/intern_setup.c | 46 ----- apps/plugins/pdbox/PDa/intern/line~.c | 102 ---------- apps/plugins/pdbox/PDa/intern/lop~.c | 89 --------- apps/plugins/pdbox/PDa/intern/makefile | 23 --- apps/plugins/pdbox/PDa/intern/mtof~.c | 48 ----- apps/plugins/pdbox/PDa/intern/noise~.c | 56 ------ apps/plugins/pdbox/PDa/intern/osc~.c | 88 -------- apps/plugins/pdbox/PDa/intern/phasor~.c | 69 ------- apps/plugins/pdbox/PDa/intern/powtodb~.c | 53 ----- apps/plugins/pdbox/PDa/intern/print~.c | 77 ------- apps/plugins/pdbox/PDa/intern/rmstodb~.c | 51 ----- apps/plugins/pdbox/PDa/intern/rsqrt~.c | 105 ---------- apps/plugins/pdbox/PDa/intern/samphold~.c | 74 ------- apps/plugins/pdbox/PDa/intern/sformat.h | 54 ----- apps/plugins/pdbox/PDa/intern/sfread~.c | 288 --------------------------- apps/plugins/pdbox/PDa/intern/sfwrite~.c | 239 ---------------------- apps/plugins/pdbox/PDa/intern/sig~.c | 66 ------ apps/plugins/pdbox/PDa/intern/snapshot~.c | 56 ------ apps/plugins/pdbox/PDa/intern/sqrt~.c | 77 ------- apps/plugins/pdbox/PDa/intern/tabosc4~.c | 131 ------------ apps/plugins/pdbox/PDa/intern/tabplay~.c | 131 ------------ apps/plugins/pdbox/PDa/intern/tabread.c | 51 ----- apps/plugins/pdbox/PDa/intern/tabread4~.c | 104 ---------- apps/plugins/pdbox/PDa/intern/tabread~.c | 96 --------- apps/plugins/pdbox/PDa/intern/tabreceive~.c | 61 ------ apps/plugins/pdbox/PDa/intern/tabsend~.c | 97 --------- apps/plugins/pdbox/PDa/intern/tabwrite.c | 83 -------- apps/plugins/pdbox/PDa/intern/tabwrite~.c | 131 ------------ apps/plugins/pdbox/PDa/intern/threshold~.c | 134 ------------- apps/plugins/pdbox/PDa/intern/vcf~.c | 119 ----------- apps/plugins/pdbox/PDa/intern/vd~.c | 91 --------- apps/plugins/pdbox/PDa/intern/vline~.c | 183 ----------------- apps/plugins/pdbox/PDa/intern/vsnapshot~.c | 88 -------- apps/plugins/pdbox/PDa/intern/wrap~.c | 51 ----- 47 files changed, 4183 deletions(-) (limited to 'apps/plugins/pdbox/PDa/intern') diff --git a/apps/plugins/pdbox/PDa/intern/biquad~.c b/apps/plugins/pdbox/PDa/intern/biquad~.c index c37182a..2dc6d72 100644 --- a/apps/plugins/pdbox/PDa/intern/biquad~.c +++ b/apps/plugins/pdbox/PDa/intern/biquad~.c @@ -124,129 +124,4 @@ void biquad_tilde_setup(void) class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("clear"), A_GIMME, 0); } -#include -#include - -typedef struct biquadctl -{ - t_sample c_x1; - t_sample c_x2; - t_sample c_fb1; - t_sample c_fb2; - t_sample c_ff1; - t_sample c_ff2; - t_sample c_ff3; -} t_biquadctl; - -typedef struct sigbiquad -{ - t_object x_obj; - float x_f; - t_biquadctl x_cspace; - t_biquadctl *x_ctl; -} t_sigbiquad; - -t_class *sigbiquad_class; - -static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv); -static void *sigbiquad_new(t_symbol *s, int argc, t_atom *argv) -{ - t_sigbiquad *x = (t_sigbiquad *)pd_new(sigbiquad_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_ctl = &x->x_cspace; - x->x_cspace.c_x1 = x->x_cspace.c_x2 = 0; - sigbiquad_list(x, s, argc, argv); - x->x_f = 0; - return (x); -} - -static t_int *sigbiquad_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - t_biquadctl *c = (t_biquadctl *)(w[3]); - int n = (t_int)(w[4]); - int i; - t_sample last = c->c_x1; - t_sample prev = c->c_x2; - t_sample fb1 = c->c_fb1; - t_sample fb2 = c->c_fb2; - t_sample ff1 = c->c_ff1; - t_sample ff2 = c->c_ff2; - t_sample ff3 = c->c_ff3; - for (i = 0; i < n; i++) - { - t_sample output = *in++ + mult(fb1,last) + mult(fb2,prev); - if (PD_BADFLOAT(output)) - output = 0; - *out++ = mult(ff1,output) + mult(ff2,last) + mult(ff3,prev); - prev = last; - last = output; - } - c->c_x1 = last; - c->c_x2 = prev; - return (w+5); -} - -static void sigbiquad_list(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) -{ - float fb1 = atom_getfloatarg(0, argc, argv); - float fb2 = atom_getfloatarg(1, argc, argv); - float ff1 = atom_getfloatarg(2, argc, argv); - float ff2 = atom_getfloatarg(3, argc, argv); - float ff3 = atom_getfloatarg(4, argc, argv); - float discriminant = fb1 * fb1 + 4 * fb2; - t_biquadctl *c = x->x_ctl; - if (discriminant < 0) /* imaginary roots -- resonant filter */ - { - /* they're conjugates so we just check that the product - is less than one */ - if (fb2 >= -1.0f) goto stable; - } - else /* real roots */ - { - /* check that the parabola 1 - fb1 x - fb2 x^2 has a - vertex between -1 and 1, and that it's nonnegative - at both ends, which implies both roots are in [1-,1]. */ - if (fb1 <= 2.0f && fb1 >= -2.0f && - 1.0f - fb1 -fb2 >= 0 && 1.0f + fb1 - fb2 >= 0) - goto stable; - } - /* if unstable, just bash to zero */ - fb1 = fb2 = ff1 = ff2 = ff3 = 0; -stable: - c->c_fb1 = ftofix(fb1); - c->c_fb2 = ftofix(fb2); - c->c_ff1 = ftofix(ff1); - c->c_ff2 = ftofix(ff2); - c->c_ff3 = ftofix(ff3); -} - -static void sigbiquad_set(t_sigbiquad *x, t_symbol *s, int argc, t_atom *argv) -{ - t_biquadctl *c = x->x_ctl; - c->c_x1 = atom_getfloatarg(0, argc, argv); - c->c_x2 = atom_getfloatarg(1, argc, argv); -} - -static void sigbiquad_dsp(t_sigbiquad *x, t_signal **sp) -{ - dsp_add(sigbiquad_perform, 4, - sp[0]->s_vec, sp[1]->s_vec, - x->x_ctl, sp[0]->s_n); - -} - -void biquad_tilde_setup(void) -{ - sigbiquad_class = class_new(gensym("biquad~"), (t_newmethod)sigbiquad_new, - 0, sizeof(t_sigbiquad), 0, A_GIMME, 0); - CLASS_MAINSIGNALIN(sigbiquad_class, t_sigbiquad, x_f); - class_addmethod(sigbiquad_class, (t_method)sigbiquad_dsp, gensym("dsp"), 0); - class_addlist(sigbiquad_class, sigbiquad_list); - class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("set"), - A_GIMME, 0); - class_addmethod(sigbiquad_class, (t_method)sigbiquad_set, gensym("clear"), - A_GIMME, 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/bp~.c b/apps/plugins/pdbox/PDa/intern/bp~.c index f247c1d..2c44536 100644 --- a/apps/plugins/pdbox/PDa/intern/bp~.c +++ b/apps/plugins/pdbox/PDa/intern/bp~.c @@ -136,141 +136,3 @@ void bp_tilde_setup(void) class_sethelpsymbol(sigbp_class, gensym("lop~-help.pd")); } -#include -#include - -typedef struct bpctl -{ - t_sample c_x1; - t_sample c_x2; - t_sample c_coef1; - t_sample c_coef2; - t_sample c_gain; -} t_bpctl; - -typedef struct sigbp -{ - t_object x_obj; - float x_sr; - float x_freq; - float x_q; - t_bpctl x_cspace; - t_bpctl *x_ctl; - float x_f; -} t_sigbp; - -t_class *sigbp_class; - -static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q); - -static void *sigbp_new(t_floatarg f, t_floatarg q) -{ - t_sigbp *x = (t_sigbp *)pd_new(sigbp_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft2")); - outlet_new(&x->x_obj, gensym("signal")); - x->x_sr = 44100; - x->x_ctl = &x->x_cspace; - x->x_cspace.c_x1 = 0; - x->x_cspace.c_x2 = 0; - sigbp_docoef(x, f, q); - x->x_f = 0; - return (x); -} - -static float sigbp_qcos(float f) -{ - if (f >= -(0.5f*3.14159f) && f <= 0.5f*3.14159f) - { - float g = f*f; - return (((g*g*g * (-1.0f/720.0f) + g*g*(1.0f/24.0f)) - g*0.5) + 1); - } - else return (0); -} - -static void sigbp_docoef(t_sigbp *x, t_floatarg f, t_floatarg q) -{ - float r, oneminusr, omega; - if (f < 0.001) f = 10; - if (q < 0) q = 0; - x->x_freq = f; - x->x_q = q; - omega = f * (2.0f * 3.14159f) / x->x_sr; - if (q < 0.001) oneminusr = 1.0f; - else oneminusr = omega/q; - if (oneminusr > 1.0f) oneminusr = 1.0f; - r = 1.0f - oneminusr; - x->x_ctl->c_coef1 = ftofix(2.0f * sigbp_qcos(omega) * r); - x->x_ctl->c_coef2 = ftofix(- r * r); - x->x_ctl->c_gain = ftofix(2 * oneminusr * (oneminusr + r * omega)); - /* post("r %f, omega %f, coef1 %f, coef2 %f", - r, omega, x->x_ctl->c_coef1, x->x_ctl->c_coef2); */ -} - -static void sigbp_ft1(t_sigbp *x, t_floatarg f) -{ - sigbp_docoef(x, f, x->x_q); -} - -static void sigbp_ft2(t_sigbp *x, t_floatarg q) -{ - sigbp_docoef(x, x->x_freq, q); -} - -static void sigbp_clear(t_sigbp *x, t_floatarg q) -{ - x->x_ctl->c_x1 = x->x_ctl->c_x2 = 0; -} - -static t_int *sigbp_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - t_bpctl *c = (t_bpctl *)(w[3]); - int n = (t_int)(w[4]); - int i; - t_sample last = c->c_x1; - t_sample prev = c->c_x2; - t_sample coef1 = c->c_coef1; - t_sample coef2 = c->c_coef2; - t_sample gain = c->c_gain; - for (i = 0; i < n; i++) - { - t_sample output = *in++ + mult(coef1,last) + mult(coef2,prev); - *out++ = mult(gain,output); - prev = last; - last = output; - } - if (PD_BADFLOAT(last)) - last = 0; - if (PD_BADFLOAT(prev)) - prev = 0; - c->c_x1 = last; - c->c_x2 = prev; - return (w+5); -} - -static void sigbp_dsp(t_sigbp *x, t_signal **sp) -{ - x->x_sr = sp[0]->s_sr; - sigbp_docoef(x, x->x_freq, x->x_q); - dsp_add(sigbp_perform, 4, - sp[0]->s_vec, sp[1]->s_vec, - x->x_ctl, sp[0]->s_n); - -} - -void bp_tilde_setup(void) -{ - sigbp_class = class_new(gensym("bp~"), (t_newmethod)sigbp_new, 0, - sizeof(t_sigbp), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(sigbp_class, t_sigbp, x_f); - class_addmethod(sigbp_class, (t_method)sigbp_dsp, gensym("dsp"), 0); - class_addmethod(sigbp_class, (t_method)sigbp_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(sigbp_class, (t_method)sigbp_ft2, - gensym("ft2"), A_FLOAT, 0); - class_addmethod(sigbp_class, (t_method)sigbp_clear, gensym("clear"), 0); - class_sethelpsymbol(sigbp_class, gensym("lop~-help.pd")); -} - diff --git a/apps/plugins/pdbox/PDa/intern/clip~.c b/apps/plugins/pdbox/PDa/intern/clip~.c index e2c697d..83bcc80 100644 --- a/apps/plugins/pdbox/PDa/intern/clip~.c +++ b/apps/plugins/pdbox/PDa/intern/clip~.c @@ -56,61 +56,4 @@ void clip_tilde_setup(void) CLASS_MAINSIGNALIN(clip_class, t_clip, x_f); class_addmethod(clip_class, (t_method)clip_dsp, gensym("dsp"), 0); } -#include -#include - -static t_class *clip_class; -typedef struct _clip -{ - t_object x_obj; - float x_f; - t_float x_lo; - t_float x_hi; -} t_clip; - -static void *clip_new(t_floatarg lo, t_floatarg hi) -{ - t_clip *x = (t_clip *)pd_new(clip_class); - x->x_lo = lo; - x->x_hi = hi; - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_lo); - floatinlet_new(&x->x_obj, &x->x_hi); - x->x_f = 0; - return (x); -} - -static t_int *clip_perform(t_int *w) -{ - t_clip *x = (t_clip *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - int n = (int)(w[4]); - t_sample lo; - t_sample hi; - lo = ftofix(x->x_lo); - hi = ftofix(x->x_hi); - - while (n--) - { - t_sample f = *in++; - if (f < lo) f = lo; - if (f > hi) f = hi; - *out++ = f; - } - return (w+5); -} - -static void clip_dsp(t_clip *x, t_signal **sp) -{ - dsp_add(clip_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void clip_tilde_setup(void) -{ - clip_class = class_new(gensym("clip~"), (t_newmethod)clip_new, 0, - sizeof(t_clip), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(clip_class, t_clip, x_f); - class_addmethod(clip_class, (t_method)clip_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/cos_table.h b/apps/plugins/pdbox/PDa/intern/cos_table.h index b30bb42..e8be7f5 100644 --- a/apps/plugins/pdbox/PDa/intern/cos_table.h +++ b/apps/plugins/pdbox/PDa/intern/cos_table.h @@ -1,6 +1,3 @@ #define ILOGCOSTABSIZE 15 #define ICOSTABSIZE (1< -#include -#include "cos_table.h" - -/* ------------------------ cos~ ----------------------------- */ -#define FRAC ((1<<(fix1-ILOGCOSTABSIZE))-1) - -static t_class *cos_class; - -typedef struct _cos -{ - t_object x_obj; - float x_f; -} t_cos; - -static void *cos_new(void) -{ - t_cos *x = (t_cos *)pd_new(cos_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *cos_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - int n = (int)(w[3]); - t_sample *tab = cos_table; - int off; - int frac; - unsigned int phase; - - while (n--) { - phase = *in++; - phase &= ((1<s_vec, sp[1]->s_vec, sp[0]->s_n); -} - - -void cos_tilde_setup(void) -{ - cos_class = class_new(gensym("cos~"), (t_newmethod)cos_new, 0, - sizeof(t_cos), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(cos_class, t_cos, x_f); - class_addmethod(cos_class, (t_method)cos_dsp, gensym("dsp"), 0); - class_sethelpsymbol(cos_class, gensym("osc~-help.pd")); -} diff --git a/apps/plugins/pdbox/PDa/intern/dbtopow~.c b/apps/plugins/pdbox/PDa/intern/dbtopow~.c index 92ba76d..ad4a826 100644 --- a/apps/plugins/pdbox/PDa/intern/dbtopow~.c +++ b/apps/plugins/pdbox/PDa/intern/dbtopow~.c @@ -50,55 +50,4 @@ void dbtopow_tilde_setup(void) CLASS_MAINSIGNALIN(dbtopow_tilde_class, t_dbtopow_tilde, x_f); class_addmethod(dbtopow_tilde_class, (t_method)dbtopow_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -#define LOGTEN 2.302585092994 - -typedef struct dbtopow_tilde -{ - t_object x_obj; - float x_f; -} t_dbtopow_tilde; - -t_class *dbtopow_tilde_class; - -static void *dbtopow_tilde_new(void) -{ - t_dbtopow_tilde *x = (t_dbtopow_tilde *)pd_new(dbtopow_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} -static t_int *dbtopow_tilde_perform(t_int *w) -{ - float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2); - t_int n = *(t_int *)(w+3); - for (; n--; in++, out++) - { - float f = *in; - if (f <= 0) *out = 0; - else - { - if (f > 870) - f = 870; - *out = exp((LOGTEN * 0.1) * (f-100.)); - } - } - return (w + 4); -} - -static void dbtopow_tilde_dsp(t_dbtopow_tilde *x, t_signal **sp) -{ - post("warning: %s not usable yet",__FUNCTION__); - dsp_add(dbtopow_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void dbtopow_tilde_setup(void) -{ - dbtopow_tilde_class = class_new(gensym("dbtopow~"), (t_newmethod)dbtopow_tilde_new, 0, - sizeof(t_dbtopow_tilde), 0, 0); - CLASS_MAINSIGNALIN(dbtopow_tilde_class, t_dbtopow_tilde, x_f); - class_addmethod(dbtopow_tilde_class, (t_method)dbtopow_tilde_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/dbtorms~.c b/apps/plugins/pdbox/PDa/intern/dbtorms~.c index 9d45a07..703d088 100644 --- a/apps/plugins/pdbox/PDa/intern/dbtorms~.c +++ b/apps/plugins/pdbox/PDa/intern/dbtorms~.c @@ -51,56 +51,4 @@ void dbtorms_tilde_setup(void) CLASS_MAINSIGNALIN(dbtorms_tilde_class, t_dbtorms_tilde, x_f); class_addmethod(dbtorms_tilde_class, (t_method)dbtorms_tilde_dsp, gensym("dsp"), 0); } -#include -#include - - -#define LOGTEN 2.302585092994 - -typedef struct dbtorms_tilde -{ - t_object x_obj; - float x_f; -} t_dbtorms_tilde; - -t_class *dbtorms_tilde_class; - -static void *dbtorms_tilde_new(void) -{ - t_dbtorms_tilde *x = (t_dbtorms_tilde *)pd_new(dbtorms_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *dbtorms_tilde_perform(t_int *w) -{ - float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2); - t_int n = *(t_int *)(w+3); - for (; n--; in++, out++) - { - float f = *in; - if (f <= 0) *out = 0; - else - { - if (f > 485) - f = 485; - *out = exp((LOGTEN * 0.05) * (f-100.)); - } - } - return (w + 4); -} -static void dbtorms_tilde_dsp(t_dbtorms_tilde *x, t_signal **sp) -{ - post("warning: %s not usable yet",__FUNCTION__); - dsp_add(dbtorms_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void dbtorms_tilde_setup(void) -{ - dbtorms_tilde_class = class_new(gensym("dbtorms~"), (t_newmethod)dbtorms_tilde_new, 0, - sizeof(t_dbtorms_tilde), 0, 0); - CLASS_MAINSIGNALIN(dbtorms_tilde_class, t_dbtorms_tilde, x_f); - class_addmethod(dbtorms_tilde_class, (t_method)dbtorms_tilde_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/delay.h b/apps/plugins/pdbox/PDa/intern/delay.h index 1aacd56..3b86dee 100644 --- a/apps/plugins/pdbox/PDa/intern/delay.h +++ b/apps/plugins/pdbox/PDa/intern/delay.h @@ -41,44 +41,3 @@ static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize) #endif -#ifndef __DELAY_H__ -#define __DELAY_H__ - - -extern t_class *sigdelwrite_class; - - -typedef struct delwritectl -{ - int c_n; - t_sample *c_vec; - int c_phase; -} t_delwritectl; - -typedef struct _sigdelwrite -{ - t_object x_obj; - t_symbol *x_sym; - t_delwritectl x_cspace; - int x_sortno; /* DSP sort number at which this was last put on chain */ - int x_rsortno; /* DSP sort # for first delread or write in chain */ - int x_vecsize; /* vector size for delread~ to use */ - float x_f; -} t_sigdelwrite; - -#define XTRASAMPS 4 -#define SAMPBLK 4 - - /* routine to check that all delwrites/delreads/vds have same vecsize */ -static void sigdelwrite_checkvecsize(t_sigdelwrite *x, int vecsize) -{ - if (x->x_rsortno != ugen_getsortno()) - { - x->x_vecsize = vecsize; - x->x_rsortno = ugen_getsortno(); - } - else if (vecsize != x->x_vecsize) - pd_error(x, "delread/delwrite/vd vector size mismatch"); -} - -#endif diff --git a/apps/plugins/pdbox/PDa/intern/delread~.c b/apps/plugins/pdbox/PDa/intern/delread~.c index b0a5839..ed7d2f2 100644 --- a/apps/plugins/pdbox/PDa/intern/delread~.c +++ b/apps/plugins/pdbox/PDa/intern/delread~.c @@ -98,103 +98,4 @@ void delread_tilde_setup(void) gensym("dsp"), 0); class_addfloat(sigdelread_class, (t_method)sigdelread_float); } -#include -#include -#include "delay.h" - -extern int ugen_getsortno(void); - -#define DEFDELVS 64 /* LATER get this from canvas at DSP time */ -static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */ - -static t_class *sigdelread_class; - -typedef struct _sigdelread -{ - t_object x_obj; - t_symbol *x_sym; - t_float x_deltime; /* delay in msec */ - int x_delsamps; /* delay in samples */ - t_float x_sr; /* samples per msec */ - t_float x_n; /* vector size */ - int x_zerodel; /* 0 or vecsize depending on read/write order */ -} t_sigdelread; - -static void sigdelread_float(t_sigdelread *x, t_float f); - -static void *sigdelread_new(t_symbol *s, t_floatarg f) -{ - t_sigdelread *x = (t_sigdelread *)pd_new(sigdelread_class); - x->x_sym = s; - x->x_sr = 1; - x->x_n = 1; - x->x_zerodel = 0; - sigdelread_float(x, f); - outlet_new(&x->x_obj, &s_signal); - return (x); -} -static void sigdelread_float(t_sigdelread *x, t_float f) -{ - int samps; - t_sigdelwrite *delwriter = - (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class); - x->x_deltime = f; - if (delwriter) - { - int delsize = delwriter->x_cspace.c_n; - x->x_delsamps = (int)(0.5 + x->x_sr * x->x_deltime) - + x->x_n - x->x_zerodel; - if (x->x_delsamps < x->x_n) x->x_delsamps = x->x_n; - else if (x->x_delsamps > delwriter->x_cspace.c_n - DEFDELVS) - x->x_delsamps = delwriter->x_cspace.c_n - DEFDELVS; - } -} - -static t_int *sigdelread_perform(t_int *w) -{ - t_sample *out = (t_sample *)(w[1]); - t_delwritectl *c = (t_delwritectl *)(w[2]); - int delsamps = *(int *)(w[3]); - int n = (int)(w[4]); - int phase = c->c_phase - delsamps, nsamps = c->c_n; - t_sample *vp = c->c_vec, *bp, *ep = vp + (c->c_n + XTRASAMPS); - - if (phase < 0) phase += nsamps; - bp = vp + phase; - while (n--) - { - *out++ = *bp++; - if (bp == ep) bp -= nsamps; - } - return (w+5); -} - -static void sigdelread_dsp(t_sigdelread *x, t_signal **sp) -{ - t_sigdelwrite *delwriter = - (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class); - x->x_sr = sp[0]->s_sr * 0.001; - x->x_n = sp[0]->s_n; - if (delwriter) - { - sigdelwrite_checkvecsize(delwriter, sp[0]->s_n); - x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ? - 0 : delwriter->x_vecsize); - sigdelread_float(x, x->x_deltime); - dsp_add(sigdelread_perform, 4, - sp[0]->s_vec, &delwriter->x_cspace, &x->x_delsamps, sp[0]->s_n); - } - else if (*x->x_sym->s_name) - error("delread~: %s: no such delwrite~",x->x_sym->s_name); -} - -void delread_tilde_setup(void) -{ - sigdelread_class = class_new(gensym("delread~"), - (t_newmethod)sigdelread_new, 0, - sizeof(t_sigdelread), 0, A_DEFSYM, A_DEFFLOAT, 0); - class_addmethod(sigdelread_class, (t_method)sigdelread_dsp, - gensym("dsp"), 0); - class_addfloat(sigdelread_class, (t_method)sigdelread_float); -} diff --git a/apps/plugins/pdbox/PDa/intern/delwrite~.c b/apps/plugins/pdbox/PDa/intern/delwrite~.c index 290793d..825ff23 100644 --- a/apps/plugins/pdbox/PDa/intern/delwrite~.c +++ b/apps/plugins/pdbox/PDa/intern/delwrite~.c @@ -82,87 +82,4 @@ void delwrite_tilde_setup(void) class_addmethod(sigdelwrite_class, (t_method)sigdelwrite_dsp, gensym("dsp"), 0); } -#include -#include - -extern int ugen_getsortno(void); - -#define DEFDELVS 64 /* LATER get this from canvas at DSP time */ -static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */ - -#include "delay.h" - -t_class *sigdelwrite_class; - -static void *sigdelwrite_new(t_symbol *s, t_floatarg msec) -{ - int nsamps; - t_sigdelwrite *x = (t_sigdelwrite *)pd_new(sigdelwrite_class); - if (!*s->s_name) s = gensym("delwrite~"); - pd_bind(&x->x_obj.ob_pd, s); - x->x_sym = s; - nsamps = msec * sys_getsr() * (float)(0.001f); - if (nsamps < 1) nsamps = 1; - nsamps += ((- nsamps) & (SAMPBLK - 1)); - nsamps += DEFDELVS; - x->x_cspace.c_n = nsamps; - x->x_cspace.c_vec = - (t_sample *)getbytes((nsamps + XTRASAMPS) * sizeof(float)); - x->x_cspace.c_phase = XTRASAMPS; - x->x_sortno = 0; - x->x_vecsize = 0; - x->x_f = 0; - return (x); -} -static t_int *sigdelwrite_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_delwritectl *c = (t_delwritectl *)(w[2]); - int n = (int)(w[3]); - int phase = c->c_phase, nsamps = c->c_n; - t_sample *vp = c->c_vec, *bp = vp + phase, *ep = vp + (c->c_n + XTRASAMPS); - phase += n; - while (n--) - { - t_sample f = *in++; - if (PD_BADFLOAT(f)) - f = 0; - *bp++ = f; - if (bp == ep) - { - vp[0] = ep[-4]; - vp[1] = ep[-3]; - vp[2] = ep[-2]; - vp[3] = ep[-1]; - bp = vp + XTRASAMPS; - phase -= nsamps; - } - } - c->c_phase = phase; - return (w+4); -} - -static void sigdelwrite_dsp(t_sigdelwrite *x, t_signal **sp) -{ - dsp_add(sigdelwrite_perform, 3, sp[0]->s_vec, &x->x_cspace, sp[0]->s_n); - x->x_sortno = ugen_getsortno(); - sigdelwrite_checkvecsize(x, sp[0]->s_n); -} - -static void sigdelwrite_free(t_sigdelwrite *x) -{ - pd_unbind(&x->x_obj.ob_pd, x->x_sym); - freebytes(x->x_cspace.c_vec, - (x->x_cspace.c_n + XTRASAMPS) * sizeof(float)); -} - -void delwrite_tilde_setup(void) -{ - sigdelwrite_class = class_new(gensym("delwrite~"), - (t_newmethod)sigdelwrite_new, (t_method)sigdelwrite_free, - sizeof(t_sigdelwrite), 0, A_DEFSYM, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(sigdelwrite_class, t_sigdelwrite, x_f); - class_addmethod(sigdelwrite_class, (t_method)sigdelwrite_dsp, - gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/env~.c b/apps/plugins/pdbox/PDa/intern/env~.c index a9bf699..8f42658 100644 --- a/apps/plugins/pdbox/PDa/intern/env~.c +++ b/apps/plugins/pdbox/PDa/intern/env~.c @@ -124,131 +124,3 @@ void env_tilde_setup(void ) class_addmethod(sigenv_class, (t_method)sigenv_dsp, gensym("dsp"), 0); } - - -#define FIXEDPOINT -#include -#include - - -#define MAXOVERLAP 10 -#define MAXVSTAKEN 64 - -typedef struct sigenv -{ - t_object x_obj; /* header */ - void *x_outlet; /* a "float" outlet */ - void *x_clock; /* a "clock" object */ - t_sample *x_buf; /* a Hanning window */ - int x_phase; /* number of points since last output */ - int x_period; /* requested period of output */ - int x_realperiod; /* period rounded up to vecsize multiple */ - int x_npoints; /* analysis window size in samples */ - t_float x_result; /* result to output */ - t_sample x_sumbuf[MAXOVERLAP]; /* summing buffer */ - t_float x_f; -} t_sigenv; - -t_class *sigenv_class; -static void sigenv_tick(t_sigenv *x); - -static void *sigenv_new(t_floatarg fnpoints, t_floatarg fperiod) -{ - int npoints = fnpoints; - int period = fperiod; - t_sigenv *x; - t_sample *buf; - int i; - - if (npoints < 1) npoints = 1024; - if (period < 1) period = npoints/2; - if (period < npoints / MAXOVERLAP + 1) - period = npoints / MAXOVERLAP + 1; - if (!(buf = getbytes(sizeof(t_sample) * (npoints + MAXVSTAKEN)))) - { - error("env: couldn't allocate buffer"); - return (0); - } - x = (t_sigenv *)pd_new(sigenv_class); - x->x_buf = buf; - x->x_npoints = npoints; - x->x_phase = 0; - x->x_period = period; - for (i = 0; i < MAXOVERLAP; i++) x->x_sumbuf[i] = 0; - for (i = 0; i < npoints; i++) - buf[i] = ftofix((1. - cos((2 * 3.14159 * i) / npoints))/npoints); - for (; i < npoints+MAXVSTAKEN; i++) buf[i] = 0; - x->x_clock = clock_new(x, (t_method)sigenv_tick); - x->x_outlet = outlet_new(&x->x_obj, gensym("float")); - x->x_f = 0; - return (x); -} - -static t_int *sigenv_perform(t_int *w) -{ - t_sigenv *x = (t_sigenv *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - int n = (int)(w[3]); - int count; - t_sample *sump; - in += n; - for (count = x->x_phase, sump = x->x_sumbuf; - count < x->x_npoints; count += x->x_realperiod, sump++) - { - t_sample *hp = x->x_buf + count; - t_sample *fp = in; - t_sample sum = *sump; - int i; - - for (i = 0; i < n; i++) - { - fp--; - sum += *hp++ * ((*fp * *fp)>>16)>>16; - } - *sump = sum; - } - sump[0] = 0; - x->x_phase -= n; - if (x->x_phase < 0) - { - x->x_result = x->x_sumbuf[0]; - for (count = x->x_realperiod, sump = x->x_sumbuf; - count < x->x_npoints; count += x->x_realperiod, sump++) - sump[0] = sump[1]; - sump[0] = 0; - x->x_phase = x->x_realperiod - n; - clock_delay(x->x_clock, 0L); - } - return (w+4); -} - -static void sigenv_dsp(t_sigenv *x, t_signal **sp) -{ - if (x->x_period % sp[0]->s_n) x->x_realperiod = - x->x_period + sp[0]->s_n - (x->x_period % sp[0]->s_n); - else x->x_realperiod = x->x_period; - dsp_add(sigenv_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); - if (sp[0]->s_n > MAXVSTAKEN) bug("sigenv_dsp"); -} - -static void sigenv_tick(t_sigenv *x) /* callback function for the clock */ -{ - outlet_float(x->x_outlet, powtodb(x->x_result*3.051757e-05)); -} - -static void sigenv_ff(t_sigenv *x) /* cleanup on free */ -{ - clock_free(x->x_clock); - freebytes(x->x_buf, (x->x_npoints + MAXVSTAKEN) * sizeof(float)); -} - - -void env_tilde_setup(void ) -{ - sigenv_class = class_new(gensym("env~"), (t_newmethod)sigenv_new, - (t_method)sigenv_ff, sizeof(t_sigenv), 0, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(sigenv_class, t_sigenv, x_f); - class_addmethod(sigenv_class, (t_method)sigenv_dsp, gensym("dsp"), 0); -} - - diff --git a/apps/plugins/pdbox/PDa/intern/ftom~.c b/apps/plugins/pdbox/PDa/intern/ftom~.c index 253fd7b..fb40ff6 100644 --- a/apps/plugins/pdbox/PDa/intern/ftom~.c +++ b/apps/plugins/pdbox/PDa/intern/ftom~.c @@ -42,47 +42,4 @@ void ftom_tilde_setup(void) CLASS_MAINSIGNALIN(ftom_tilde_class, t_ftom_tilde, x_f); class_addmethod(ftom_tilde_class, (t_method)ftom_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -typedef struct ftom_tilde -{ - t_object x_obj; - float x_f; -} t_ftom_tilde; - -t_class *ftom_tilde_class; - -static void *ftom_tilde_new(void) -{ - t_ftom_tilde *x = (t_ftom_tilde *)pd_new(ftom_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} -static t_int *ftom_tilde_perform(t_int *w) -{ - t_sample *in = *(t_sample **)(w+1), *out = *(t_float **)(w+2); - t_int n = *(t_int *)(w+3); - for (; n--; *in++, out++) - { - t_sample f = *in; - *out = ftofix((fixtof(f) > 0 ? 17.3123405046 * log(.12231220585 * fixtof(f)) : -1500)); - } - return (w + 4); -} - -static void ftom_tilde_dsp(t_ftom_tilde *x, t_signal **sp) -{ - post("warning: %s not usable yet",__FUNCTION__); - dsp_add(ftom_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void ftom_tilde_setup(void) -{ - ftom_tilde_class = class_new(gensym("ftom~"), (t_newmethod)ftom_tilde_new, 0, - sizeof(t_ftom_tilde), 0, 0); - CLASS_MAINSIGNALIN(ftom_tilde_class, t_ftom_tilde, x_f); - class_addmethod(ftom_tilde_class, (t_method)ftom_tilde_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/hip~.c b/apps/plugins/pdbox/PDa/intern/hip~.c index a2a8c40..6c6de41 100644 --- a/apps/plugins/pdbox/PDa/intern/hip~.c +++ b/apps/plugins/pdbox/PDa/intern/hip~.c @@ -90,95 +90,4 @@ void hip_tilde_setup(void) class_addmethod(sighip_class, (t_method)sighip_clear, gensym("clear"), 0); class_sethelpsymbol(sighip_class, gensym("lop~-help.pd")); } -#include -#include - -typedef struct hipctl -{ - t_sample c_x; - t_sample c_coef; -} t_hipctl; - -typedef struct sighip -{ - t_object x_obj; - float x_sr; - float x_hz; - t_hipctl x_cspace; - t_hipctl *x_ctl; - float x_f; -} t_sighip; - -t_class *sighip_class; -static void sighip_ft1(t_sighip *x, t_floatarg f); - -static void *sighip_new(t_floatarg f) -{ - t_sighip *x = (t_sighip *)pd_new(sighip_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); - outlet_new(&x->x_obj, gensym("signal")); - x->x_sr = 44100; - x->x_ctl = &x->x_cspace; - x->x_cspace.c_x = 0; - sighip_ft1(x, f); - x->x_f = 0; - return (x); -} -static void sighip_ft1(t_sighip *x, t_floatarg f) -{ - t_float coeff; - if (f < 0.001) f = 10; - x->x_hz = f; - coeff = 1 - f * (2 * 3.14159) / x->x_sr; - if (coeff < 0) coeff = 0; - x->x_ctl->c_coef = ftofix(coeff); -} - -static t_int *sighip_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - t_hipctl *c = (t_hipctl *)(w[3]); - int n = (t_int)(w[4]); - int i; - t_sample last = c->c_x; - t_sample coef = c->c_coef; - for (i = 0; i < n; i++) - { - t_sample new = *in++ + mult(coef,last); - *out++ = new - last; - last = new; - } - if (PD_BADFLOAT(last)) - last = 0; - c->c_x = last; - return (w+5); -} - -static void sighip_dsp(t_sighip *x, t_signal **sp) -{ - x->x_sr = sp[0]->s_sr; - sighip_ft1(x, x->x_hz); - dsp_add(sighip_perform, 4, - sp[0]->s_vec, sp[1]->s_vec, - x->x_ctl, sp[0]->s_n); - -} - -static void sighip_clear(t_sighip *x, t_floatarg q) -{ - x->x_cspace.c_x = 0; -} - -void hip_tilde_setup(void) -{ - sighip_class = class_new(gensym("hip~"), (t_newmethod)sighip_new, 0, - sizeof(t_sighip), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(sighip_class, t_sighip, x_f); - class_addmethod(sighip_class, (t_method)sighip_dsp, gensym("dsp"), 0); - class_addmethod(sighip_class, (t_method)sighip_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(sighip_class, (t_method)sighip_clear, gensym("clear"), 0); - class_sethelpsymbol(sighip_class, gensym("lop~-help.pd")); -} diff --git a/apps/plugins/pdbox/PDa/intern/intern_setup.c b/apps/plugins/pdbox/PDa/intern/intern_setup.c index aec8799..017f72a 100644 --- a/apps/plugins/pdbox/PDa/intern/intern_setup.c +++ b/apps/plugins/pdbox/PDa/intern/intern_setup.c @@ -45,50 +45,4 @@ void d_intern_setup() { vsnapshot_tilde_setup(); wrap_tilde_setup(); } -#include -void d_intern_setup() { - fprintf(stderr,"setup\n"); - biquad_tilde_setup(); - bp_tilde_setup(); - clip_tilde_setup(); - cos_tilde_setup(); - dbtopow_tilde_setup(); - dbtorms_tilde_setup(); - delread_tilde_setup(); - delwrite_tilde_setup(); - env_tilde_setup(); - ftom_tilde_setup(); - hip_tilde_setup(); - line_tilde_setup(); - lop_tilde_setup(); - mtof_tilde_setup(); - noise_tilde_setup(); - osc_tilde_setup(); - phasor_tilde_setup(); - powtodb_tilde_setup(); - print_tilde_setup(); - rmstodb_tilde_setup(); - rsqrt_tilde_setup(); - samphold_tilde_setup(); - sfread_tilde_setup(); - sfwrite_tilde_setup(); - sig_tilde_setup(); - snapshot_tilde_setup(); - sqrt_tilde_setup(); - tabosc4_tilde_setup(); - tabplay_tilde_setup(); - tabread4_tilde_setup(); - tabread_tilde_setup(); - tabread_setup(); - tabreceive_tilde_setup(); - tabsend_tilde_setup(); - tabwrite_tilde_setup(); - tabwrite_setup(); - threshold_tilde_setup(); - vcf_tilde_setup(); - vd_tilde_setup(); - vline_tilde_setup(); - vsnapshot_tilde_setup(); - wrap_tilde_setup(); -} diff --git a/apps/plugins/pdbox/PDa/intern/line~.c b/apps/plugins/pdbox/PDa/intern/line~.c index ac7af87..f37f23c 100644 --- a/apps/plugins/pdbox/PDa/intern/line~.c +++ b/apps/plugins/pdbox/PDa/intern/line~.c @@ -98,105 +98,3 @@ void line_tilde_setup(void) class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); } - -#include -#include - -static t_class *line_class; - -typedef struct _line -{ - t_object x_obj; - t_sample x_target; - t_sample x_value; - t_sample x_biginc; - t_sample x_inc; - t_sample x_1overn; - t_sample x_msectodsptick; - t_floatarg x_inletvalue; - t_floatarg x_inletwas; - int x_ticksleft; - int x_retarget; -} t_line; - -static t_int *line_perform(t_int *w) -{ - t_line *x = (t_line *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - int n = (int)(w[3]); - t_sample f = x->x_value; - - if (x->x_retarget) - { - int nticks = mult(ftofix(x->x_inletwas),x->x_msectodsptick); - if (!nticks) nticks = itofix(1); - x->x_ticksleft = fixtoi(nticks); - x->x_biginc = (x->x_target - x->x_value); - x->x_biginc = idiv(x->x_biginc,nticks); - x->x_inc = mult(x->x_1overn, x->x_biginc); - x->x_retarget = 0; - } - if (x->x_ticksleft) - { - t_sample f = x->x_value; - while (n--) *out++ = f, f += x->x_inc; - x->x_value += x->x_biginc; - x->x_ticksleft--; - } - else - { - x->x_value = x->x_target; - while (n--) *out++ = x->x_value; - } - return (w+4); -} - -static void line_float(t_line *x, t_float f) -{ - if (x->x_inletvalue <= 0) - { - x->x_target = x->x_value = ftofix(f); - x->x_ticksleft = x->x_retarget = 0; - } - else - { - x->x_target = ftofix(f); - x->x_retarget = 1; - x->x_inletwas = x->x_inletvalue; - x->x_inletvalue = 0; - } -} - -static void line_stop(t_line *x) -{ - x->x_target = x->x_value; - x->x_ticksleft = x->x_retarget = 0; -} - -static void line_dsp(t_line *x, t_signal **sp) -{ - dsp_add(line_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); - x->x_1overn = ftofix(1)/sp[0]->s_n; - x->x_msectodsptick = idiv(sp[0]->s_sr, (1000 * sp[0]->s_n)); -} - -static void *line_new(void) -{ - t_line *x = (t_line *)pd_new(line_class); - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_inletvalue); - x->x_ticksleft = x->x_retarget = 0; - x->x_value = x->x_target = x->x_inletvalue = x->x_inletwas = 0; - return (x); -} - -void line_tilde_setup(void) -{ - line_class = class_new(gensym("line~"), line_new, 0, - sizeof(t_line), 0, 0); - class_addfloat(line_class, (t_method)line_float); - class_addmethod(line_class, (t_method)line_dsp, gensym("dsp"), 0); - class_addmethod(line_class, (t_method)line_stop, gensym("stop"), 0); -} - - diff --git a/apps/plugins/pdbox/PDa/intern/lop~.c b/apps/plugins/pdbox/PDa/intern/lop~.c index 49a17a7..9d36091 100644 --- a/apps/plugins/pdbox/PDa/intern/lop~.c +++ b/apps/plugins/pdbox/PDa/intern/lop~.c @@ -88,93 +88,4 @@ void lop_tilde_setup(void) gensym("ft1"), A_FLOAT, 0); class_addmethod(siglop_class, (t_method)siglop_clear, gensym("clear"), 0); } -#include -#include - -typedef struct lopctl -{ - t_sample c_x; - t_sample c_coef; -} t_lopctl; - -typedef struct siglop -{ - t_object x_obj; - float x_sr; - float x_hz; - t_lopctl x_cspace; - t_lopctl *x_ctl; - float x_f; -} t_siglop; - -t_class *siglop_class; - -static void siglop_ft1(t_siglop *x, t_floatarg f); - -static void *siglop_new(t_floatarg f) -{ - t_siglop *x = (t_siglop *)pd_new(siglop_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); - outlet_new(&x->x_obj, gensym("signal")); - x->x_sr = 44100; - x->x_ctl = &x->x_cspace; - x->x_cspace.c_x = 0; - siglop_ft1(x, f); - x->x_f = 0; - return (x); -} - -static void siglop_ft1(t_siglop *x, t_floatarg f) -{ - t_float coeff; - if (f < 0.001) f = 10; - x->x_hz = f; - coeff = f * (2 * 3.14159) / x->x_sr; - if (coeff > 1) coeff = 1; - x->x_ctl->c_coef = ftofix(coeff); -} -static void siglop_clear(t_siglop *x, t_floatarg q) -{ - x->x_cspace.c_x = 0; -} - - -static t_int *siglop_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - t_lopctl *c = (t_lopctl *)(w[3]); - int n = (t_int)(w[4]); - int i; - t_sample last = c->c_x; - t_sample coef = c->c_coef; - t_sample feedback = ftofix(1) - coef; - for (i = 0; i < n; i++) - last = *out++ = mult(coef, *in++) + mult(feedback,last); - if (PD_BADFLOAT(last)) - last = 0; - c->c_x = last; - return (w+5); -} - -static void siglop_dsp(t_siglop *x, t_signal **sp) -{ - x->x_sr = sp[0]->s_sr; - siglop_ft1(x, x->x_hz); - dsp_add(siglop_perform, 4, - sp[0]->s_vec, sp[1]->s_vec, - x->x_ctl, sp[0]->s_n); - -} - -void lop_tilde_setup(void) -{ - siglop_class = class_new(gensym("lop~"), (t_newmethod)siglop_new, 0, - sizeof(t_siglop), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(siglop_class, t_siglop, x_f); - class_addmethod(siglop_class, (t_method)siglop_dsp, gensym("dsp"), 0); - class_addmethod(siglop_class, (t_method)siglop_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(siglop_class, (t_method)siglop_clear, gensym("clear"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/makefile b/apps/plugins/pdbox/PDa/intern/makefile index 99c508a..8873faa 100644 --- a/apps/plugins/pdbox/PDa/intern/makefile +++ b/apps/plugins/pdbox/PDa/intern/makefile @@ -23,26 +23,3 @@ install: %.$(EXT) : %.o $(CC) -o $@ $(EFLAGS) $+ - -SOURCE = $(shell ls *.c) -TARGETS = $(SOURCE:.c=.pd_linux) - -EXT= pd_linux - -CFLAGS += -O2 -I../src -DFIXEDPOINT -EFLAGS = -shared -Wl,-export-dynamic - - - -all: $(TARGETS) - -clean: - -rm $(TARGETS) - -rm *.o *~ - -install: - install -d $(DESTDIR)/$(PREFIX)/lib/pd/extra - cp $(TARGETS) $(DESTDIR)/$(PREFIX)/lib/pd/extra - -%.$(EXT) : %.o - $(CC) -o $@ $(EFLAGS) $+ diff --git a/apps/plugins/pdbox/PDa/intern/mtof~.c b/apps/plugins/pdbox/PDa/intern/mtof~.c index 1db7dc5..cf0fd66 100644 --- a/apps/plugins/pdbox/PDa/intern/mtof~.c +++ b/apps/plugins/pdbox/PDa/intern/mtof~.c @@ -47,52 +47,4 @@ void mtof_tilde_setup(void) CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f); class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -typedef struct mtof_tilde -{ - t_object x_obj; - float x_f; -} t_mtof_tilde; - -t_class *mtof_tilde_class; - -static void *mtof_tilde_new(void) -{ - t_mtof_tilde *x = (t_mtof_tilde *)pd_new(mtof_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *mtof_tilde_perform(t_int *w) -{ - t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2); - t_int n = *(t_int *)(w+3); - for (; n--; in++, out++) - { - t_sample f = *in; - if (f <= ftofix(-1500.)) *out = 0; - else - { - if (f > ftofix(1499.)) f = ftofix(1499.); - *out = ftofix(8.17579891564 * exp(.0577622650 * fixtof(f))); - } - } - return (w + 4); -} - -static void mtof_tilde_dsp(t_mtof_tilde *x, t_signal **sp) -{ - post("warning: %s not usable yet",__FUNCTION__); - dsp_add(mtof_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} -void mtof_tilde_setup(void) -{ - mtof_tilde_class = class_new(gensym("mtof~"), (t_newmethod)mtof_tilde_new, 0, - sizeof(t_mtof_tilde), 0, 0); - CLASS_MAINSIGNALIN(mtof_tilde_class, t_mtof_tilde, x_f); - class_addmethod(mtof_tilde_class, (t_method)mtof_tilde_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/noise~.c b/apps/plugins/pdbox/PDa/intern/noise~.c index 2f61b9d..1b10ae9 100644 --- a/apps/plugins/pdbox/PDa/intern/noise~.c +++ b/apps/plugins/pdbox/PDa/intern/noise~.c @@ -52,59 +52,3 @@ void noise_tilde_setup(void) class_addmethod(noise_class, (t_method)noise_dsp, gensym("dsp"), 0); } - -#include -#include - - -static t_class *noise_class; - -typedef struct _noise -{ - t_object x_obj; - int x_val; -} t_noise; - -static void *noise_new(void) -{ - t_noise *x = (t_noise *)pd_new(noise_class); - static int init = 307; - x->x_val = (init *= 1319); - outlet_new(&x->x_obj, gensym("signal")); - return (x); -} - -static t_int *noise_perform(t_int *w) -{ - t_sample *out = (t_sample *)(w[1]); - int *vp = (int *)(w[2]); - int n = (int)(w[3]); - int val = *vp; - while (n--) - { -#ifndef FIXEDPOINT - *out++ = ((t_sample)((val & 0x7fffffff) - 0x40000000)) * - (t_sample)(1.0 / 0x40000000); -#else - *out++=val>>(32-fix1); -#endif - val = val * 435898247 + 382842987; - - } - *vp = val; - return (w+4); -} - -static void noise_dsp(t_noise *x, t_signal **sp) -{ - dsp_add(noise_perform, 3, sp[0]->s_vec, &x->x_val, sp[0]->s_n); -} - -void noise_tilde_setup(void) -{ - noise_class = class_new(gensym("noise~"), (t_newmethod)noise_new, 0, - sizeof(t_noise), 0, 0); - class_addmethod(noise_class, (t_method)noise_dsp, gensym("dsp"), 0); -} - - diff --git a/apps/plugins/pdbox/PDa/intern/osc~.c b/apps/plugins/pdbox/PDa/intern/osc~.c index f8e8997..b2cc843 100644 --- a/apps/plugins/pdbox/PDa/intern/osc~.c +++ b/apps/plugins/pdbox/PDa/intern/osc~.c @@ -84,91 +84,3 @@ void osc_tilde_setup(void) class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0); } - - - -#include -#include -#include "cos_table.h" - -/* ------------------------ osc~ ----------------------------- */ - -static t_class *osc_class, *scalarosc_class; - -typedef struct _osc -{ - t_object x_obj; - unsigned int x_phase; - t_sample x_conv; - t_sample x_f; /* frequency if scalar */ -} t_osc; - -static void *osc_new(t_floatarg f) -{ - t_osc *x = (t_osc *)pd_new(osc_class); - x->x_f = ftofix(f); - outlet_new(&x->x_obj, gensym("signal")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - x->x_phase = 0; - x->x_conv = 0; - return (x); -} - - -static t_int *osc_perform(t_int *w) -{ - t_osc *x = (t_osc *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - int n = (int)(w[4]); - t_sample *tab = cos_table; - unsigned int phase = x->x_phase; - int conv = x->x_conv; - int off; - int frac; - while (n--) { - phase+= mult(conv ,(*in++)); - phase &= (itofix(1) -1); - off = fixtoi((long long)phase<x_phase = phase; - - return (w+5); -} - -static void osc_dsp(t_osc *x, t_signal **sp) -{ - post("samplerate %f",sp[0]->s_sr); - x->x_conv = ftofix(1000.)/sp[0]->s_sr; - post("conf %d",x->x_conv); - x->x_conv = mult(x->x_conv + 500,ftofix(0.001)); - post("conf %d",x->x_conv); - dsp_add(osc_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -static void osc_ft1(t_osc *x, t_float f) -{ - x->x_phase = ftofix(f); /* *2 ??? */ -} - -void osc_tilde_setup(void) -{ - osc_class = class_new(gensym("osc~"), (t_newmethod)osc_new, 0, - sizeof(t_osc), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(osc_class, t_osc, x_f); - class_addmethod(osc_class, (t_method)osc_dsp, gensym("dsp"), 0); - class_addmethod(osc_class, (t_method)osc_ft1, gensym("ft1"), A_FLOAT, 0); -} - - diff --git a/apps/plugins/pdbox/PDa/intern/phasor~.c b/apps/plugins/pdbox/PDa/intern/phasor~.c index b823286..551d7b0 100644 --- a/apps/plugins/pdbox/PDa/intern/phasor~.c +++ b/apps/plugins/pdbox/PDa/intern/phasor~.c @@ -67,72 +67,3 @@ void phasor_tilde_setup(void) class_sethelpsymbol(phasor_class, gensym("osc~-help.pd")); } - -#include -#include - -/* -------------------------- phasor~ ------------------------------ */ -static t_class *phasor_class; - -typedef struct _phasor -{ - t_object x_obj; - unsigned int x_phase; - t_sample x_conv; - t_sample x_f; /* scalar frequency */ -} t_phasor; - -static void *phasor_new(t_floatarg f) -{ - t_phasor *x = (t_phasor *)pd_new(phasor_class); - x->x_f = ftofix(f); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - x->x_phase = 0; - x->x_conv = 0; - outlet_new(&x->x_obj, gensym("signal")); - return (x); -} - -static t_int *phasor_perform(t_int *w) -{ - t_phasor *x = (t_phasor *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - int n = (int)(w[4]); - unsigned int phase = x->x_phase; - int conv = x->x_conv; - - while (n--) { - phase+= mult(conv , (*in++)); - phase &= (itofix(1) - 1); - *out++ = phase; - } - x->x_phase = phase; - - return (w+5); -} - -static void phasor_dsp(t_phasor *x, t_signal **sp) -{ - x->x_conv = ftofix(1000.)/sp[0]->s_sr; - x->x_conv = mult(x->x_conv + 500,ftofix(0.001)); - dsp_add(phasor_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - - -static void phasor_ft1(t_phasor *x, t_float f) -{ - x->x_phase = ftofix(f); -} - -void phasor_tilde_setup(void) -{ - phasor_class = class_new(gensym("phasor~"), (t_newmethod)phasor_new, 0, - sizeof(t_phasor), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(phasor_class, t_phasor, x_f); - class_addmethod(phasor_class, (t_method)phasor_dsp, gensym("dsp"), 0); - class_addmethod(phasor_class, (t_method)phasor_ft1, - gensym("ft1"), A_FLOAT, 0); - class_sethelpsymbol(phasor_class, gensym("osc~-help.pd")); -} - diff --git a/apps/plugins/pdbox/PDa/intern/powtodb~.c b/apps/plugins/pdbox/PDa/intern/powtodb~.c index 65cf6c0..5fead15 100644 --- a/apps/plugins/pdbox/PDa/intern/powtodb~.c +++ b/apps/plugins/pdbox/PDa/intern/powtodb~.c @@ -51,56 +51,3 @@ void powtodb_tilde_setup(void) class_addmethod(powtodb_tilde_class, (t_method)powtodb_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -#define LOGTEN 2.302585092994 - - -typedef struct powtodb_tilde -{ - t_object x_obj; - float x_f; -} t_powtodb_tilde; - -t_class *powtodb_tilde_class; - -static void *powtodb_tilde_new(void) -{ - t_powtodb_tilde *x = (t_powtodb_tilde *)pd_new(powtodb_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *powtodb_tilde_perform(t_int *w) -{ - t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2); - t_int n = *(t_int *)(w+3); - for (; n--; in++, out++) - { - float f = *in; - if (f <= 0) *out = 0; - else - { - float g = 100 + 10./LOGTEN * log(f); - *out = (g < 0 ? 0 : g); - } - } - return (w + 4); -} - -static void powtodb_tilde_dsp(t_powtodb_tilde *x, t_signal **sp) -{ - post("warning: %s not usable yet",__FUNCTION__); - dsp_add(powtodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void powtodb_tilde_setup(void) -{ - powtodb_tilde_class = class_new(gensym("powtodb~"), (t_newmethod)powtodb_tilde_new, 0, - sizeof(t_powtodb_tilde), 0, 0); - CLASS_MAINSIGNALIN(powtodb_tilde_class, t_powtodb_tilde, x_f); - class_addmethod(powtodb_tilde_class, (t_method)powtodb_tilde_dsp, gensym("dsp"), 0); -} - diff --git a/apps/plugins/pdbox/PDa/intern/print~.c b/apps/plugins/pdbox/PDa/intern/print~.c index 3051ca3..699555a 100644 --- a/apps/plugins/pdbox/PDa/intern/print~.c +++ b/apps/plugins/pdbox/PDa/intern/print~.c @@ -76,81 +76,4 @@ void print_tilde_setup(void) class_addbang(print_class, print_bang); class_addfloat(print_class, print_float); } -#include -#include - -static t_class *print_class; - -typedef struct _print -{ - t_object x_obj; - float x_f; - t_symbol *x_sym; - int x_count; -} t_print; -static t_int *print_perform(t_int *w) -{ - t_print *x = (t_print *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - int n = (int)(w[3]); - if (x->x_count) - { - post("%s:", x->x_sym->s_name); - if (n == 1) post("%8g", in[0]); - else if (n == 2) post("%8g %8g", in[0], in[1]); - else if (n == 4) post("%8g %8g %8g %8g", - in[0], in[1], in[2], in[3]); - else while (n > 0) - { - post("%-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g %-8.5g", - fixtof(in[0]), - fixtof(in[1]), - fixtof(in[2]), - fixtof(in[3]), - fixtof(in[4]), - fixtof(in[5]), - fixtof(in[6]), - fixtof(in[7])); - n -= 8; - in += 8; - } - x->x_count--; - } - return (w+4); -} - -static void print_dsp(t_print *x, t_signal **sp) -{ - dsp_add(print_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); -} - -static void print_float(t_print *x, t_float f) -{ - if (f < 0) f = 0; - x->x_count = f; -} - -static void print_bang(t_print *x) -{ - x->x_count = 1; -} - -static void *print_new(t_symbol *s) -{ - t_print *x = (t_print *)pd_new(print_class); - x->x_sym = (s->s_name[0]? s : gensym("print~")); - x->x_count = 0; - x->x_f = 0; - return (x); -} - -void print_tilde_setup(void) -{ - print_class = class_new(gensym("print~"), (t_newmethod)print_new, 0, - sizeof(t_print), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(print_class, t_print, x_f); - class_addmethod(print_class, (t_method)print_dsp, gensym("dsp"), 0); - class_addbang(print_class, print_bang); - class_addfloat(print_class, print_float); -} diff --git a/apps/plugins/pdbox/PDa/intern/rmstodb~.c b/apps/plugins/pdbox/PDa/intern/rmstodb~.c index e573458..ee2b2a9 100644 --- a/apps/plugins/pdbox/PDa/intern/rmstodb~.c +++ b/apps/plugins/pdbox/PDa/intern/rmstodb~.c @@ -50,55 +50,4 @@ void rmstodb_tilde_setup(void) CLASS_MAINSIGNALIN(rmstodb_tilde_class, t_rmstodb_tilde, x_f); class_addmethod(rmstodb_tilde_class, (t_method)rmstodb_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -#define LOGTEN 2.302585092994 - - -typedef struct rmstodb_tilde -{ - t_object x_obj; - float x_f; -} t_rmstodb_tilde; - -t_class *rmstodb_tilde_class; -static void *rmstodb_tilde_new(void) -{ - t_rmstodb_tilde *x = (t_rmstodb_tilde *)pd_new(rmstodb_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *rmstodb_tilde_perform(t_int *w) -{ - float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2); - t_int n = *(t_int *)(w+3); - for (; n--; in++, out++) - { - float f = *in; - if (f <= 0) *out = 0; - else - { - float g = 100 + 20./LOGTEN * log(f); - *out = (g < 0 ? 0 : g); - } - } - return (w + 4); -} - -static void rmstodb_tilde_dsp(t_rmstodb_tilde *x, t_signal **sp) -{ - post("warning: %s not usable yet",__FUNCTION__); - dsp_add(rmstodb_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void rmstodb_tilde_setup(void) -{ - rmstodb_tilde_class = class_new(gensym("rmstodb~"), (t_newmethod)rmstodb_tilde_new, 0, - sizeof(t_rmstodb_tilde), 0, 0); - CLASS_MAINSIGNALIN(rmstodb_tilde_class, t_rmstodb_tilde, x_f); - class_addmethod(rmstodb_tilde_class, (t_method)rmstodb_tilde_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/rsqrt~.c b/apps/plugins/pdbox/PDa/intern/rsqrt~.c index e33a21a..dd7e2a1 100644 --- a/apps/plugins/pdbox/PDa/intern/rsqrt~.c +++ b/apps/plugins/pdbox/PDa/intern/rsqrt~.c @@ -103,108 +103,3 @@ void rsqrt_tilde_setup(void) class_addmethod(sigrsqrt_class, (t_method)sigrsqrt_dsp, gensym("dsp"), 0); } -#include -#include - -/* sigrsqrt - reciprocal square root good to 8 mantissa bits */ - -#define DUMTAB1SIZE 256 -#define DUMTAB2SIZE 1024 - -static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE]; - -static void init_rsqrt(void) -{ - int i; - for (i = 0; i < DUMTAB1SIZE; i++) - { - float f; - long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23; - *(long *)(&f) = l; - rsqrt_exptab[i] = 1./sqrt(f); - } - for (i = 0; i < DUMTAB2SIZE; i++) - { - float f = 1 + (1./DUMTAB2SIZE) * i; - rsqrt_mantissatab[i] = 1./sqrt(f); - } -} - - /* these are used in externs like "bonk" */ - -float q8_rsqrt(float f) -{ - long l = *(long *)(&f); - if (f < 0) return (0); - else return (rsqrt_exptab[(l >> 23) & 0xff] * - rsqrt_mantissatab[(l >> 13) & 0x3ff]); -} - -float q8_sqrt(float f) -{ - long l = *(long *)(&f); - if (f < 0) return (0); - else return (f * rsqrt_exptab[(l >> 23) & 0xff] * - rsqrt_mantissatab[(l >> 13) & 0x3ff]); -} - - /* the old names are OK unless we're in IRIX N32 */ - -#ifndef N32 -float qsqrt(float f) {return (q8_sqrt(f)); } -float qrsqrt(float f) {return (q8_rsqrt(f)); } -#endif - - - -typedef struct sigrsqrt -{ - t_object x_obj; - float x_f; -} t_sigrsqrt; - -static t_class *sigrsqrt_class; - -static void *sigrsqrt_new(void) -{ - t_sigrsqrt *x = (t_sigrsqrt *)pd_new(sigrsqrt_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *sigrsqrt_perform(t_int *w) -{ - float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2); - t_int n = *(t_int *)(w+3); - while (n--) - { - float f = *in; - long l = *(long *)(in++); - if (f < 0) *out++ = 0; - else - { - float g = rsqrt_exptab[(l >> 23) & 0xff] * - rsqrt_mantissatab[(l >> 13) & 0x3ff]; - *out++ = 1.5 * g - 0.5 * g * g * g * f; - } - } - return (w + 4); -} - -static void sigrsqrt_dsp(t_sigrsqrt *x, t_signal **sp) -{ - dsp_add(sigrsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void rsqrt_tilde_setup(void) -{ - init_rsqrt(); - sigrsqrt_class = class_new(gensym("rsqrt~"), (t_newmethod)sigrsqrt_new, 0, - sizeof(t_sigrsqrt), 0, 0); - /* an old name for it: */ - class_addcreator(sigrsqrt_new, gensym("q8_rsqrt~"), 0); - CLASS_MAINSIGNALIN(sigrsqrt_class, t_sigrsqrt, x_f); - class_addmethod(sigrsqrt_class, (t_method)sigrsqrt_dsp, gensym("dsp"), 0); -} - diff --git a/apps/plugins/pdbox/PDa/intern/samphold~.c b/apps/plugins/pdbox/PDa/intern/samphold~.c index 5ccf3d9..8f0656c 100644 --- a/apps/plugins/pdbox/PDa/intern/samphold~.c +++ b/apps/plugins/pdbox/PDa/intern/samphold~.c @@ -73,78 +73,4 @@ void samphold_tilde_setup(void) class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp, gensym("dsp"), 0); } -#include -#include - -typedef struct sigsamphold -{ - t_object x_obj; - t_sample x_f; - t_sample x_lastin; - t_sample x_lastout; -} t_sigsamphold; - -t_class *sigsamphold_class; - -static void *sigsamphold_new(void) -{ - t_sigsamphold *x = (t_sigsamphold *)pd_new(sigsamphold_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - outlet_new(&x->x_obj, gensym("signal")); - x->x_lastin = 0; - x->x_lastout = 0; - x->x_f = 0; - return (x); -} - -static t_int *sigsamphold_perform(t_int *w) -{ - t_sample *in1 = (t_sample *)(w[1]); - t_sample *in2 = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - t_sigsamphold *x = (t_sigsamphold *)(w[4]); - int n = (t_int)(w[5]); - int i; - t_sample lastin = x->x_lastin; - t_sample lastout = x->x_lastout; - for (i = 0; i < n; i++, *in1++) - { - t_sample next = *in2++; - if (next < lastin) lastout = *in1; - *out++ = lastout; - lastin = next; - } - x->x_lastin = lastin; - x->x_lastout = lastout; - return (w+6); -} -static void sigsamphold_dsp(t_sigsamphold *x, t_signal **sp) -{ - dsp_add(sigsamphold_perform, 5, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, - x, sp[0]->s_n); -} - -static void sigsamphold_reset(t_sigsamphold *x) -{ - x->x_lastin = 0x7fffffff; -} - -static void sigsamphold_set(t_sigsamphold *x, t_float f) -{ - x->x_lastout = f; -} - -void samphold_tilde_setup(void) -{ - sigsamphold_class = class_new(gensym("samphold~"), - (t_newmethod)sigsamphold_new, 0, sizeof(t_sigsamphold), 0, 0); - CLASS_MAINSIGNALIN(sigsamphold_class, t_sigsamphold, x_f); - class_addmethod(sigsamphold_class, (t_method)sigsamphold_set, - gensym("set"), A_FLOAT, 0); - class_addmethod(sigsamphold_class, (t_method)sigsamphold_reset, - gensym("reset"), 0); - class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp, - gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/sformat.h b/apps/plugins/pdbox/PDa/intern/sformat.h index b75ef98..93d3537 100644 --- a/apps/plugins/pdbox/PDa/intern/sformat.h +++ b/apps/plugins/pdbox/PDa/intern/sformat.h @@ -54,57 +54,3 @@ typedef struct _wave #endif -#ifndef SFORMAT_H__ -#define SFORMAT_H__ - -typedef unsigned short uint16; -typedef unsigned long uint32; - -#define FORMAT_WAVE 0 -#define FORMAT_AIFF 1 -#define FORMAT_NEXT 2 - -/* the NeXTStep sound header structure; can be big or little endian */ - -typedef struct _nextstep -{ - char ns_fileid[4]; /* magic number '.snd' if file is big-endian */ - uint32 ns_onset; /* byte offset of first sample */ - uint32 ns_length; /* length of sound in bytes */ - uint32 ns_format; /* format; see below */ - uint32 ns_sr; /* sample rate */ - uint32 ns_nchans; /* number of channels */ - char ns_info[4]; /* comment */ -} t_nextstep; - -#define NS_FORMAT_LINEAR_16 3 -#define NS_FORMAT_LINEAR_24 4 -#define NS_FORMAT_FLOAT 6 -#define SCALE (1./(1024. * 1024. * 1024. * 2.)) - -/* the WAVE header. All Wave files are little endian. We assume - the "fmt" chunk comes first which is usually the case but perhaps not - always; same for AIFF and the "COMM" chunk. */ - -typedef unsigned word; -typedef unsigned long dword; - -typedef struct _wave -{ - char w_fileid[4]; /* chunk id 'RIFF' */ - uint32 w_chunksize; /* chunk size */ - char w_waveid[4]; /* wave chunk id 'WAVE' */ - char w_fmtid[4]; /* format chunk id 'fmt ' */ - uint32 w_fmtchunksize; /* format chunk size */ - uint16 w_fmttag; /* format tag, 1 for PCM */ - uint16 w_nchannels; /* number of channels */ - uint32 w_samplespersec; /* sample rate in hz */ - uint32 w_navgbytespersec; /* average bytes per second */ - uint16 w_nblockalign; /* number of bytes per sample */ - uint16 w_nbitspersample; /* number of bits in a sample */ - char w_datachunkid[4]; /* data chunk id 'data' */ - uint32 w_datachunksize; /* length of data chunk */ -} t_wave; - - -#endif diff --git a/apps/plugins/pdbox/PDa/intern/sfread~.c b/apps/plugins/pdbox/PDa/intern/sfread~.c index 0980583..3882777 100644 --- a/apps/plugins/pdbox/PDa/intern/sfread~.c +++ b/apps/plugins/pdbox/PDa/intern/sfread~.c @@ -286,291 +286,3 @@ void sfread_tilde_setup(void) } -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "g_canvas.h" - -/* ------------------------ sfread~ ----------------------------- */ - -#include "sformat.h" - -static t_class *sfread_class; - - -typedef struct _sfread -{ - t_object x_obj; - void* x_mapaddr; - int x_fd; - - int x_play; - int x_channels; - long long x_size; - int x_loop; - t_time x_pos; - - t_sample x_skip; - t_sample x_speed; - - t_glist * x_glist; - t_outlet *x_bangout; -} t_sfread; - - -void sfread_open(t_sfread *x,t_symbol *filename) -{ - struct stat fstate; - char fname[MAXPDSTRING]; - - if (filename == &s_) { - post("sfread: open without filename"); - return; - } - - canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name, - fname, MAXPDSTRING); - - - /* close the old file */ - - if (x->x_mapaddr) munmap(x->x_mapaddr,x->x_size); - if (x->x_fd >= 0) close(x->x_fd); - - if ((x->x_fd = open(fname,O_RDONLY)) < 0) - { - error("can't open %s",fname); - x->x_play = 0; - x->x_mapaddr = NULL; - return; - } - - /* get the size */ - - fstat(x->x_fd,&fstate); - x->x_size = fstate.st_size; - - /* map the file into memory */ - - if (!(x->x_mapaddr = mmap(NULL,x->x_size,PROT_READ,MAP_PRIVATE,x->x_fd,0))) - { - error("can't mmap %s",fname); - return; - } -} - -#define MAX_CHANS 4 - -static t_int *sfread_perform(t_int *w) -{ - t_sfread* x = (t_sfread*)(w[1]); - short* buf = x->x_mapaddr; - t_time tmp; - int c = x->x_channels; - t_time pos = x->x_pos; - t_sample speed = x->x_speed; - t_time end = itofix(x->x_size/sizeof(short)/c); - int i,n; - t_sample* out[MAX_CHANS]; - - for (i=0;i end) - pos = end; - - if (pos + n*speed >= end) { // playing forward end - if (!x->x_loop) { - x->x_play=0; - } - pos = x->x_skip; - } - tmp = n*speed; - - if (pos + n*speed <= 0) { // playing backwards end - if (!x->x_loop) { - x->x_play=0; - } - pos = end; - - } - if (x->x_play && x->x_mapaddr) { - t_time aoff = fixtoi(pos)*c; - while (n--) { - long frac = (long long)((1< end) { - if (x->x_loop) pos = x->x_skip; - else break; - } - if (aoff < x->x_skip) { - if (x->x_loop) pos = end; - else break; - } - } - /* Fill with zero in case of end */ - n++; - while (n--) - for (i=0;ix_pos = pos; - return (w+c+4); -} - - -static void sfread_float(t_sfread *x, t_floatarg f) -{ - int t = f; - if (t && x->x_mapaddr) { - x->x_play=1; - } - else { - x->x_play=0; - } - -} - -static void sfread_loop(t_sfread *x, t_floatarg f) -{ - x->x_loop = f; -} - - - -static void sfread_size(t_sfread* x) -{ - t_atom a; - - SETFLOAT(&a,x->x_size*0.5/x->x_channels); - outlet_list(x->x_bangout, gensym("size"),1,&a); -} - -static void sfread_state(t_sfread* x) -{ - t_atom a; - - SETFLOAT(&a,x->x_play); - outlet_list(x->x_bangout, gensym("state"),1,&a); -} - - - - -static void sfread_bang(t_sfread* x) -{ - x->x_pos = x->x_skip; - sfread_float(x,1.0); -} - - -static void sfread_dsp(t_sfread *x, t_signal **sp) -{ -/* post("sfread: dsp"); */ - switch (x->x_channels) { - case 1: - dsp_add(sfread_perform, 4, x, sp[0]->s_vec, - sp[1]->s_vec, sp[0]->s_n); - break; - case 2: - dsp_add(sfread_perform, 5, x, sp[0]->s_vec, - sp[1]->s_vec,sp[2]->s_vec, sp[0]->s_n); - break; - case 4: - dsp_add(sfread_perform, 6, x, sp[0]->s_vec, - sp[1]->s_vec,sp[2]->s_vec, - sp[3]->s_vec,sp[4]->s_vec, - sp[0]->s_n); - break; - } -} - - -static void sfread_speed(t_sfread* x, t_floatarg f) -{ - x->x_speed = ftofix(f); -} - -static void sfread_offset(t_sfread* x, t_floatarg f) -{ - x->x_pos = (int)f; -} - -static void *sfread_new(t_floatarg chan,t_floatarg skip) -{ - t_sfread *x = (t_sfread *)pd_new(sfread_class); - t_int c = chan; - - x->x_glist = (t_glist*) canvas_getcurrent(); - - if (c<1 || c > MAX_CHANS) c = 1; - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft2")); - - - x->x_fd = -1; - x->x_mapaddr = NULL; - - x->x_size = 0; - x->x_loop = 0; - x->x_channels = c; - x->x_mapaddr=NULL; - x->x_pos = 0; - x->x_skip = 0; - x->x_speed = ftofix(1.0); - x->x_play = 0; - - while (c--) { - outlet_new(&x->x_obj, gensym("signal")); - } - - x->x_bangout = outlet_new(&x->x_obj, &s_float); - - return (x); -} - -void sfread_tilde_setup(void) -{ - /* sfread */ - - sfread_class = class_new(gensym("sfread~"), (t_newmethod)sfread_new, 0, - sizeof(t_sfread), 0,A_DEFFLOAT,A_DEFFLOAT,0); - class_addmethod(sfread_class, nullfn, gensym("signal"), 0); - class_addmethod(sfread_class, (t_method) sfread_dsp, gensym("dsp"), 0); - class_addmethod(sfread_class, (t_method) sfread_open, gensym("open"), A_SYMBOL,A_NULL); - class_addmethod(sfread_class, (t_method) sfread_size, gensym("size"), 0); - class_addmethod(sfread_class, (t_method) sfread_offset, gensym("ft1"), A_FLOAT, A_NULL); - class_addmethod(sfread_class, (t_method) sfread_speed, gensym("ft2"), A_FLOAT, A_NULL); - class_addmethod(sfread_class, (t_method) sfread_state, gensym("state"), 0); - class_addfloat(sfread_class, sfread_float); - class_addbang(sfread_class,sfread_bang); - class_addmethod(sfread_class,(t_method)sfread_loop,gensym("loop"),A_FLOAT,A_NULL); - -} - diff --git a/apps/plugins/pdbox/PDa/intern/sfwrite~.c b/apps/plugins/pdbox/PDa/intern/sfwrite~.c index dd3bfc4..6b054f1 100644 --- a/apps/plugins/pdbox/PDa/intern/sfwrite~.c +++ b/apps/plugins/pdbox/PDa/intern/sfwrite~.c @@ -239,242 +239,3 @@ void sfwrite_tilde_setup(void) class_addfloat(sfwrite_class, sfwrite_float); } -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include "g_canvas.h" - - -#define BLOCKTIME 10 - -#define MAX_CHANS 4 - -#include "sformat.h" - -static t_class *sfwrite_class; - -typedef struct _sfwrite -{ - t_object x_obj; - t_symbol* filename; - int x_file; - - t_int rec; - t_int x_channels; - uint32 size; - t_glist * x_glist; - t_int x_blocked; - t_int x_blockwarn; -} t_sfwrite; - - -static void sfwrite_wave_setup(t_sfwrite* x,t_wave* w) -{ - - strncpy(w->w_fileid,"RIFF",4); /* chunk id 'RIFF' */ - w->w_chunksize = x->size + sizeof(t_wave) -8; /* chunk size */ - strncpy(w->w_waveid,"WAVE",4); /* wave chunk id 'WAVE' */ - strncpy(w->w_fmtid,"fmt ",4); /* format chunk id 'fmt '*/ - w->w_fmtchunksize = 16; /* format chunk size */ - w->w_fmttag = 1; /* format tag, 1 for PCM */ - w->w_nchannels = x->x_channels; /* number of channels */ - w->w_samplespersec = 44100; /* sample rate in hz */ - w->w_navgbytespersec = 44100*x->x_channels*2; /* average bytes per second */ - w->w_nblockalign = 4; /* number of bytes per sample */ - w->w_nbitspersample = 16; /* number of bits in a sample */ - strncpy(w->w_datachunkid,"data",4); /* data chunk id 'data'*/ - w->w_datachunksize = x->size; /* length of data chunk */ -} - - - -static void sfwrite_close(t_sfwrite *x) -{ - if (x->x_file > 0) { - t_wave w; - sfwrite_wave_setup(x,&w); - lseek(x->x_file,0,SEEK_SET); - write(x->x_file,&w,sizeof(w)); - close(x->x_file); - } - x->x_file = -1; -} - - -static void sfwrite_open(t_sfwrite *x,t_symbol *filename) -{ - char fname[MAXPDSTRING]; - - if (filename == &s_) { - post("sfwrite: open without filename"); - return; - } - - canvas_makefilename(glist_getcanvas(x->x_glist), filename->s_name, - fname, MAXPDSTRING); - - x->x_blocked = 0; - x->filename = filename; - post("sfwrite: filename = %s",x->filename->s_name); - - sfwrite_close(x); - - if ((x->x_file = open(fname,O_RDWR | O_CREAT,0664)) < 0) - { - error("can't create %s",fname); - return; - } - - /* skip the header */ - - lseek(x->x_file,sizeof(t_wave),SEEK_SET); - x->size = 0; - - -} - -static void sfwrite_block(t_sfwrite *x, t_floatarg f) -{ - x->x_blockwarn = f; -} - - -static void sfwrite_float(t_sfwrite *x, t_floatarg f) -{ - int t = f; - if (t) { - post("sfwrite: start", f); - x->rec=1; - } - else { - post("sfwrite: stop", f); - x->rec=0; - } - -} - - -static short out[4*64]; - -static t_int *sfwrite_perform(t_int *w) -{ - t_sfwrite* x = (t_sfwrite*)(w[1]); - t_sample * in[4]; - int c = x->x_channels; - int i,num,n; - short* tout = out; - int ret; - int timebefore,timeafter; - double late; - - for (i=0;i < c;i++) { - in[i] = (t_sample *)(w[2+i]); - } - - n = num = (int)(w[2+c]); - - /* loop */ - - if (x->rec && x->x_file) { - - while (n--) { - for (i=0;i>(fix1-16); - } - } - - timebefore = sys_getrealtime(); - if ((ret =write(x->x_file,out,sizeof(short)*num*c)) < (signed int)sizeof(short)*num*c) { - post("sfwrite: short write %d",ret); - - } - timeafter = sys_getrealtime(); - late = timeafter - timebefore; - -#if 0 - /* OK, we let only 10 ms block here */ - if (late > BLOCKTIME && x->x_blockwarn) { - post("sfwrite blocked %f ms",late*1000); - x->x_blocked++; - if (x->x_blocked > x->x_blockwarn) { - x->rec = 0; - post("maximum blockcount %d reached, recording stopped (set blockcount with \"block \"",x->x_blockwarn); - } - } -#endif - x->size +=64*x->x_channels*sizeof(short) ; - } - - return (w+3+c); -} - - - -static void sfwrite_dsp(t_sfwrite *x, t_signal **sp) -{ - switch (x->x_channels) { - case 1: - dsp_add(sfwrite_perform, 3, x, sp[0]->s_vec, - sp[0]->s_n); - break; - case 2: - dsp_add(sfwrite_perform, 4, x, sp[0]->s_vec, - sp[1]->s_vec, sp[0]->s_n); - break; - case 4: - dsp_add(sfwrite_perform, 6, x, sp[0]->s_vec, - sp[1]->s_vec, - sp[2]->s_vec, - sp[3]->s_vec, - sp[0]->s_n); - break; - } -} - -static void sfwrite_free(t_sfwrite* x) -{ - sfwrite_close(x); -} - - -static void *sfwrite_new(t_floatarg chan) -{ - t_sfwrite *x = (t_sfwrite *)pd_new(sfwrite_class); - t_int c = chan; - - if (c<1 || c > MAX_CHANS) c = 1; - - x->x_glist = (t_glist*) canvas_getcurrent(); - x->x_channels = c--; - x->x_file=0; - x->rec = 0; - x->size = 0; - x->x_blocked = 0; - x->x_blockwarn = 10; - while (c--) { - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - } - - - return (x); -} - -void sfwrite_tilde_setup(void) -{ - sfwrite_class = class_new(gensym("sfwrite~"), (t_newmethod)sfwrite_new, (t_method)sfwrite_free, - sizeof(t_sfwrite), 0,A_DEFFLOAT,0); - class_addmethod(sfwrite_class,nullfn,gensym("signal"), 0); - class_addmethod(sfwrite_class, (t_method) sfwrite_dsp, gensym("dsp"), 0); - class_addmethod(sfwrite_class, (t_method) sfwrite_open, gensym("open"), A_SYMBOL,A_NULL); - class_addmethod(sfwrite_class, (t_method) sfwrite_close, gensym("close"), 0); - class_addmethod(sfwrite_class, (t_method)sfwrite_block,gensym("block"),A_DEFFLOAT,0); - class_addfloat(sfwrite_class, sfwrite_float); -} diff --git a/apps/plugins/pdbox/PDa/intern/sig~.c b/apps/plugins/pdbox/PDa/intern/sig~.c index 70a616c..6cee184 100644 --- a/apps/plugins/pdbox/PDa/intern/sig~.c +++ b/apps/plugins/pdbox/PDa/intern/sig~.c @@ -65,70 +65,4 @@ void sig_tilde_setup(void) class_addfloat(sig_tilde_class, (t_method)sig_tilde_float); class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -static t_class *sig_tilde_class; - -typedef struct _sig -{ - t_object x_obj; - t_sample x_f; -} t_sig; - -static t_int *sig_tilde_perform(t_int *w) -{ - t_sample f = *(t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - int n = (int)(w[3]); - while (n--) - *out++ = f; - return (w+4); -} - -static t_int *sig_tilde_perf8(t_int *w) -{ - t_sample f = *(t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - int n = (int)(w[3]); - - for (; n; n -= 8, out += 8) - { - out[0] = f; - out[1] = f; - out[2] = f; - out[3] = f; - out[4] = f; - out[5] = f; - out[6] = f; - out[7] = f; - } - return (w+4); -} - -static void sig_tilde_float(t_sig *x, t_float f) -{ - x->x_f = ftofix(f); -} - -static void sig_tilde_dsp(t_sig *x, t_signal **sp) -{ - dsp_add(sig_tilde_perform, 3, &x->x_f, sp[0]->s_vec, sp[0]->s_n); -} - -static void *sig_tilde_new(t_floatarg f) -{ - t_sig *x = (t_sig *)pd_new(sig_tilde_class); - x->x_f = ftofix(f); - outlet_new(&x->x_obj, gensym("signal")); - return (x); -} - -void sig_tilde_setup(void) -{ - sig_tilde_class = class_new(gensym("sig~"), (t_newmethod)sig_tilde_new, 0, - sizeof(t_sig), 0, A_DEFFLOAT, 0); - class_addfloat(sig_tilde_class, (t_method)sig_tilde_float); - class_addmethod(sig_tilde_class, (t_method)sig_tilde_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/snapshot~.c b/apps/plugins/pdbox/PDa/intern/snapshot~.c index f63aeb7..cd3557a 100644 --- a/apps/plugins/pdbox/PDa/intern/snapshot~.c +++ b/apps/plugins/pdbox/PDa/intern/snapshot~.c @@ -55,60 +55,4 @@ void snapshot_tilde_setup(void) gensym("set"), A_DEFFLOAT, 0); class_addbang(snapshot_tilde_class, snapshot_tilde_bang); } -#include -#include - - -static t_class *snapshot_tilde_class; - -typedef struct _snapshot -{ - t_object x_obj; - t_sample x_value; - float x_f; -} t_snapshot; - -static void *snapshot_tilde_new(void) -{ - t_snapshot *x = (t_snapshot *)pd_new(snapshot_tilde_class); - x->x_value = 0; - outlet_new(&x->x_obj, &s_float); - x->x_f = 0; - return (x); -} - -static t_int *snapshot_tilde_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - *out = *in; - return (w+3); -} - -static void snapshot_tilde_dsp(t_snapshot *x, t_signal **sp) -{ - dsp_add(snapshot_tilde_perform, 2, sp[0]->s_vec + (sp[0]->s_n-1), - &x->x_value); -} - -static void snapshot_tilde_bang(t_snapshot *x) -{ - outlet_float(x->x_obj.ob_outlet, fixtof(x->x_value)); -} - -static void snapshot_tilde_set(t_snapshot *x, t_floatarg f) -{ - x->x_value = ftofix(f); -} -void snapshot_tilde_setup(void) -{ - snapshot_tilde_class = class_new(gensym("snapshot~"), snapshot_tilde_new, 0, - sizeof(t_snapshot), 0, 0); - CLASS_MAINSIGNALIN(snapshot_tilde_class, t_snapshot, x_f); - class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(snapshot_tilde_class, (t_method)snapshot_tilde_set, - gensym("set"), A_DEFFLOAT, 0); - class_addbang(snapshot_tilde_class, snapshot_tilde_bang); -} diff --git a/apps/plugins/pdbox/PDa/intern/sqrt~.c b/apps/plugins/pdbox/PDa/intern/sqrt~.c index 5e4b649..f5362f0 100644 --- a/apps/plugins/pdbox/PDa/intern/sqrt~.c +++ b/apps/plugins/pdbox/PDa/intern/sqrt~.c @@ -75,80 +75,3 @@ void sqrt_tilde_setup(void) class_addmethod(sigsqrt_class, (t_method)sigsqrt_dsp, gensym("dsp"), 0); } -#define DUMTAB1SIZE 256 -#define DUMTAB2SIZE 1024 - -#include -#include - -/* sigsqrt - square root good to 8 mantissa bits */ - -static float rsqrt_exptab[DUMTAB1SIZE], rsqrt_mantissatab[DUMTAB2SIZE]; - -static void init_rsqrt(void) -{ - int i; - for (i = 0; i < DUMTAB1SIZE; i++) - { - float f; - long l = (i ? (i == DUMTAB1SIZE-1 ? DUMTAB1SIZE-2 : i) : 1)<< 23; - *(long *)(&f) = l; - rsqrt_exptab[i] = 1./sqrt(f); - } - for (i = 0; i < DUMTAB2SIZE; i++) - { - float f = 1 + (1./DUMTAB2SIZE) * i; - rsqrt_mantissatab[i] = 1./sqrt(f); - } -} - -typedef struct sigsqrt -{ - t_object x_obj; - float x_f; -} t_sigsqrt; - -static t_class *sigsqrt_class; - -static void *sigsqrt_new(void) -{ - t_sigsqrt *x = (t_sigsqrt *)pd_new(sigsqrt_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -t_int *sigsqrt_perform(t_int *w) /* not static; also used in d_fft.c */ -{ - float *in = *(t_float **)(w+1), *out = *(t_float **)(w+2); - t_int n = *(t_int *)(w+3); - while (n--) - { - float f = *in; - long l = *(long *)(in++); - if (f < 0) *out++ = 0; - else - { - float g = rsqrt_exptab[(l >> 23) & 0xff] * - rsqrt_mantissatab[(l >> 13) & 0x3ff]; - *out++ = f * (1.5 * g - 0.5 * g * g * g * f); - } - } - return (w + 4); -} - -static void sigsqrt_dsp(t_sigsqrt *x, t_signal **sp) -{ - dsp_add(sigsqrt_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void sqrt_tilde_setup(void) -{ - init_rsqrt(); - sigsqrt_class = class_new(gensym("sqrt~"), (t_newmethod)sigsqrt_new, 0, - sizeof(t_sigsqrt), 0, 0); - class_addcreator(sigsqrt_new, gensym("q8_sqrt~"), 0); /* old name */ - CLASS_MAINSIGNALIN(sigsqrt_class, t_sigsqrt, x_f); - class_addmethod(sigsqrt_class, (t_method)sigsqrt_dsp, gensym("dsp"), 0); -} - diff --git a/apps/plugins/pdbox/PDa/intern/tabosc4~.c b/apps/plugins/pdbox/PDa/intern/tabosc4~.c index ec8ed84..f9b6ad0 100644 --- a/apps/plugins/pdbox/PDa/intern/tabosc4~.c +++ b/apps/plugins/pdbox/PDa/intern/tabosc4~.c @@ -131,134 +131,3 @@ void tabosc4_tilde_setup(void) gensym("ft1"), A_FLOAT, 0); } -#include -#include - -static t_class *tabosc4_tilde_class; - -typedef struct _tabosc4_tilde -{ - t_object x_obj; - int x_fnpoints; - int x_lognpoints; - t_sample *x_vec; - t_symbol *x_arrayname; - t_sample x_f; - unsigned int x_phase; - t_sample x_conv; -} t_tabosc4_tilde; - -static void *tabosc4_tilde_new(t_symbol *s) -{ - t_tabosc4_tilde *x = (t_tabosc4_tilde *)pd_new(tabosc4_tilde_class); - x->x_arrayname = s; - x->x_vec = 0; - x->x_fnpoints = 512; - outlet_new(&x->x_obj, gensym("signal")); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - x->x_f = 0; - post("new done"); - return (x); -} - -static t_int *tabosc4_tilde_perform(t_int *w) -{ - t_tabosc4_tilde *x = (t_tabosc4_tilde *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - int n = (int)(w[4]); - t_sample *tab = x->x_vec; - unsigned int phase = x->x_phase; - int conv = x->x_conv; - int off; - int frac; - int logp = x->x_lognpoints; - - if (!tab) goto zero; - - while (n--) { - t_sample f2; - phase+= mult(conv ,(*in++)); - phase &= (itofix(1) -1); - off = fixtoi((long long)phase<x_fnpoints) ? - mult(*(tab),frac) : - mult(*(tab + off + 1),frac); - - *out = mult(*(tab + off),(itofix(1) - frac)) + f2; -#endif - out++; - } - x->x_phase = phase; - - return (w+5); - -zero: - while (n--) *out++ = 0; - - return (w+5); -} - -void tabosc4_tilde_set(t_tabosc4_tilde *x, t_symbol *s) -{ - t_garray *a; - int npoints, pointsinarray; - x->x_arrayname = s; - - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) - pd_error(x, "tabosc4~: %s: no such array", x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &pointsinarray, &x->x_vec)) - { - pd_error(x, "%s: bad template for tabosc4~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else - { - int i; - x->x_fnpoints = pointsinarray; - x->x_lognpoints = ilog2(pointsinarray); - post("tabosc~: using %d (log %d) points of array",x->x_fnpoints,x->x_lognpoints); - - garray_usedindsp(a); - } -} - -static void tabosc4_tilde_ft1(t_tabosc4_tilde *x, t_float f) -{ - x->x_phase = f; -} - -static void tabosc4_tilde_dsp(t_tabosc4_tilde *x, t_signal **sp) -{ - x->x_conv = ftofix(1000.)/sp[0]->s_sr; - x->x_conv = mult(x->x_conv + 500,ftofix(0.001)); - - tabosc4_tilde_set(x, x->x_arrayname); - dsp_add(tabosc4_tilde_perform, 4, x, - sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void tabosc4_tilde_setup(void) -{ - tabosc4_tilde_class = class_new(gensym("tabosc4~"), - (t_newmethod)tabosc4_tilde_new, 0, - sizeof(t_tabosc4_tilde), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(tabosc4_tilde_class, t_tabosc4_tilde, x_f); - class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_set, - gensym("set"), A_SYMBOL, 0); - class_addmethod(tabosc4_tilde_class, (t_method)tabosc4_tilde_ft1, - gensym("ft1"), A_FLOAT, 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabplay~.c b/apps/plugins/pdbox/PDa/intern/tabplay~.c index c0032a1..5ac0d27 100644 --- a/apps/plugins/pdbox/PDa/intern/tabplay~.c +++ b/apps/plugins/pdbox/PDa/intern/tabplay~.c @@ -131,134 +131,3 @@ void tabplay_tilde_setup(void) class_addlist(tabplay_tilde_class, tabplay_tilde_list); } -#define FIXEDPOINT -#include -#include - -static t_class *tabplay_tilde_class; - -typedef struct _tabplay_tilde -{ - t_object x_obj; - t_outlet *x_bangout; - int x_phase; - int x_nsampsintab; - int x_limit; - t_sample *x_vec; - t_symbol *x_arrayname; - t_clock *x_clock; -} t_tabplay_tilde; - -static void tabplay_tilde_tick(t_tabplay_tilde *x); - -static void *tabplay_tilde_new(t_symbol *s) -{ - t_tabplay_tilde *x = (t_tabplay_tilde *)pd_new(tabplay_tilde_class); - x->x_clock = clock_new(x, (t_method)tabplay_tilde_tick); - x->x_phase = 0x7fffffff; - x->x_limit = 0; - x->x_arrayname = s; - outlet_new(&x->x_obj, &s_signal); - x->x_bangout = outlet_new(&x->x_obj, &s_bang); - return (x); -} - -static t_int *tabplay_tilde_perform(t_int *w) -{ - t_tabplay_tilde *x = (t_tabplay_tilde *)(w[1]); - t_sample *out = (t_sample *)(w[2]), *fp; - int n = (int)(w[3]), phase = x->x_phase, - endphase = (x->x_nsampsintab < x->x_limit ? - x->x_nsampsintab : x->x_limit), nxfer, n3; - if (!x->x_vec || phase >= endphase) - goto zero; - - nxfer = endphase - phase; - fp = x->x_vec + phase; - if (nxfer > n) - nxfer = n; - n3 = n - nxfer; - phase += nxfer; - while (nxfer--) - *out++ = *fp++; - if (phase >= endphase) - { - clock_delay(x->x_clock, 0); - x->x_phase = 0x7fffffff; - while (n3--) - *out++ = 0; - } - else x->x_phase = phase; - - return (w+4); -zero: - while (n--) *out++ = 0; - return (w+4); -} - -void tabplay_tilde_set(t_tabplay_tilde *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) pd_error(x, "tabplay~: %s: no such array", - x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) - { - error("%s: bad template for tabplay~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -static void tabplay_tilde_dsp(t_tabplay_tilde *x, t_signal **sp) -{ - tabplay_tilde_set(x, x->x_arrayname); - dsp_add(tabplay_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); -} - -static void tabplay_tilde_list(t_tabplay_tilde *x, t_symbol *s, - int argc, t_atom *argv) -{ - long start = atom_getfloatarg(0, argc, argv); - long length = atom_getfloatarg(1, argc, argv); - if (start < 0) start = 0; - if (length <= 0) - x->x_limit = 0x7fffffff; - else - x->x_limit = start + length; - x->x_phase = start; -} - -static void tabplay_tilde_stop(t_tabplay_tilde *x) -{ - x->x_phase = 0x7fffffff; -} - -static void tabplay_tilde_tick(t_tabplay_tilde *x) -{ - outlet_bang(x->x_bangout); -} - -static void tabplay_tilde_free(t_tabplay_tilde *x) -{ - clock_free(x->x_clock); -} - -void tabplay_tilde_setup(void) -{ - tabplay_tilde_class = class_new(gensym("tabplay~"), - (t_newmethod)tabplay_tilde_new, (t_method)tabplay_tilde_free, - sizeof(t_tabplay_tilde), 0, A_DEFSYM, 0); - class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_stop, - gensym("stop"), 0); - class_addmethod(tabplay_tilde_class, (t_method)tabplay_tilde_set, - gensym("set"), A_DEFSYM, 0); - class_addlist(tabplay_tilde_class, tabplay_tilde_list); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabread.c b/apps/plugins/pdbox/PDa/intern/tabread.c index 5cd51b3..16beb59 100644 --- a/apps/plugins/pdbox/PDa/intern/tabread.c +++ b/apps/plugins/pdbox/PDa/intern/tabread.c @@ -50,55 +50,4 @@ void tabread_setup(void) class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"), A_SYMBOL, 0); } -#include - -/* ---------- tabread: control, non-interpolating ------------------------ */ - -static t_class *tabread_class; - -typedef struct _tabread -{ - t_object x_obj; - t_symbol *x_arrayname; -} t_tabread; - -static void tabread_float(t_tabread *x, t_float f) -{ - t_garray *a; - int npoints; - t_sample *vec; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - pd_error(x, "%s: no such array", x->x_arrayname->s_name); - else if (!garray_getfloatarray(a, &npoints, &vec)) - pd_error(x, "%s: bad template for tabread", x->x_arrayname->s_name); - else - { - int n = f; - if (n < 0) n = 0; - else if (n >= npoints) n = npoints - 1; - outlet_float(x->x_obj.ob_outlet, (npoints ? fixtof(vec[n]) : 0)); - } -} - -static void tabread_set(t_tabread *x, t_symbol *s) -{ - x->x_arrayname = s; -} - -static void *tabread_new(t_symbol *s) -{ - t_tabread *x = (t_tabread *)pd_new(tabread_class); - x->x_arrayname = s; - outlet_new(&x->x_obj, &s_float); - return (x); -} - -void tabread_setup(void) -{ - tabread_class = class_new(gensym("tabread"), (t_newmethod)tabread_new, - 0, sizeof(t_tabread), 0, A_DEFSYM, 0); - class_addfloat(tabread_class, (t_method)tabread_float); - class_addmethod(tabread_class, (t_method)tabread_set, gensym("set"), - A_SYMBOL, 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabread4~.c b/apps/plugins/pdbox/PDa/intern/tabread4~.c index e530a9f..47a6fc3 100644 --- a/apps/plugins/pdbox/PDa/intern/tabread4~.c +++ b/apps/plugins/pdbox/PDa/intern/tabread4~.c @@ -104,107 +104,3 @@ void tabread4_tilde_setup(void) gensym("set"), A_SYMBOL, 0); } -#include -#include - - -static t_class *tabread4_tilde_class; - -typedef struct _tabread4_tilde -{ - t_object x_obj; - int x_npoints; - t_sample *x_vec; - t_symbol *x_arrayname; - float x_f; -} t_tabread4_tilde; - -static void *tabread4_tilde_new(t_symbol *s) -{ - t_tabread4_tilde *x = (t_tabread4_tilde *)pd_new(tabread4_tilde_class); - x->x_arrayname = s; - x->x_vec = 0; - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *tabread4_tilde_perform(t_int *w) -{ - t_tabread4_tilde *x = (t_tabread4_tilde *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - int n = (int)(w[4]); - int maxindex; - t_sample *buf = x->x_vec, *fp; - int i; - - maxindex = x->x_npoints - 3; - - if (!buf) goto zero; - - for (i = 0; i < n; i++) - { - t_time findex = ((long long) mult((*in++),ftofix(44.1))); - int index = fixtoi(findex); - t_sample frac; - // post("%d: index %d f %lld",index,findex,*in); - - if (index < 1) - index = 1, frac = 0; - else if (index > maxindex) - index = maxindex, frac = 1; - else frac = findex - itofix(index); - fp = buf + index; - *out++ = fp[0] + mult(frac,fp[1]-fp[0]); - } - return (w+5); - zero: - while (n--) *out++ = 0; - - return (w+5); -} - -void tabread4_tilde_set(t_tabread4_tilde *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) - error("tabread4~: %s: no such array", x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec)) - { - error("%s: bad template for tabread4~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -static void tabread4_tilde_dsp(t_tabread4_tilde *x, t_signal **sp) -{ - tabread4_tilde_set(x, x->x_arrayname); - - dsp_add(tabread4_tilde_perform, 4, x, - sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); - -} - -static void tabread4_tilde_free(t_tabread4_tilde *x) -{ -} - -void tabread4_tilde_setup(void) -{ - tabread4_tilde_class = class_new(gensym("tabread4~"), - (t_newmethod)tabread4_tilde_new, (t_method)tabread4_tilde_free, - sizeof(t_tabread4_tilde), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(tabread4_tilde_class, t_tabread4_tilde, x_f); - class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(tabread4_tilde_class, (t_method)tabread4_tilde_set, - gensym("set"), A_SYMBOL, 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabread~.c b/apps/plugins/pdbox/PDa/intern/tabread~.c index f1f4fd4..5a7ea5d 100644 --- a/apps/plugins/pdbox/PDa/intern/tabread~.c +++ b/apps/plugins/pdbox/PDa/intern/tabread~.c @@ -95,100 +95,4 @@ void tabread_tilde_setup(void) class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set, gensym("set"), A_SYMBOL, 0); } -#define FIXEDPOINT -#include -#include - -static t_class *tabread_tilde_class; - -typedef struct _tabread_tilde -{ - t_object x_obj; - int x_npoints; - t_sample *x_vec; - t_symbol *x_arrayname; - float x_f; -} t_tabread_tilde; - -static void *tabread_tilde_new(t_symbol *s) -{ - t_tabread_tilde *x = (t_tabread_tilde *)pd_new(tabread_tilde_class); - x->x_arrayname = s; - x->x_vec = 0; - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *tabread_tilde_perform(t_int *w) -{ - t_tabread_tilde *x = (t_tabread_tilde *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - t_sample *out = (t_sample *)(w[3]); - int n = (int)(w[4]); - int maxindex; - t_sample *buf = x->x_vec, *fp; - int i; - - maxindex = x->x_npoints - 1; - if (!buf) goto zero; - - for (i = 0; i < n; i++) - { - int index = ((long long) mult((*in++),ftofix(44.1)) >> fix1); - if (index < 0) - index = 0; - else if (index > maxindex) - index = maxindex; - *out++ = buf[index]; - } - return (w+5); - zero: - while (n--) *out++ = 0; - - return (w+5); -} - -void tabread_tilde_set(t_tabread_tilde *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) - error("tabread~: %s: no such array", x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_npoints, &x->x_vec)) - { - error("%s: bad template for tabread~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} -static void tabread_tilde_dsp(t_tabread_tilde *x, t_signal **sp) -{ - tabread_tilde_set(x, x->x_arrayname); - - dsp_add(tabread_tilde_perform, 4, x, - sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); - -} - -static void tabread_tilde_free(t_tabread_tilde *x) -{ -} - -void tabread_tilde_setup(void) -{ - tabread_tilde_class = class_new(gensym("tabread~"), - (t_newmethod)tabread_tilde_new, (t_method)tabread_tilde_free, - sizeof(t_tabread_tilde), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(tabread_tilde_class, t_tabread_tilde, x_f); - class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(tabread_tilde_class, (t_method)tabread_tilde_set, - gensym("set"), A_SYMBOL, 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabreceive~.c b/apps/plugins/pdbox/PDa/intern/tabreceive~.c index 82f2ff3..e51a5c0 100644 --- a/apps/plugins/pdbox/PDa/intern/tabreceive~.c +++ b/apps/plugins/pdbox/PDa/intern/tabreceive~.c @@ -59,64 +59,3 @@ void tabreceive_tilde_setup(void) gensym("dsp"), 0); } -#include -#include - -static t_class *tabreceive_class; - -typedef struct _tabreceive -{ - t_object x_obj; - t_sample *x_vec; - t_symbol *x_arrayname; -} t_tabreceive; - -static t_int *tabreceive_perform(t_int *w) -{ - t_tabreceive *x = (t_tabreceive *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - int n = w[3]; - t_sample *from = x->x_vec; - if (from) while (n--) *out++ = *from++; - else while (n--) *out++ = 0; - return (w+4); -} - -static void tabreceive_dsp(t_tabreceive *x, t_signal **sp) -{ - t_garray *a; - int vecsize; - - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*x->x_arrayname->s_name) - error("tabsend~: %s: no such array", x->x_arrayname->s_name); - } - else if (!garray_getfloatarray(a, &vecsize, &x->x_vec)) - error("%s: bad template for tabreceive~", x->x_arrayname->s_name); - else - { - int n = sp[0]->s_n; - if (n < vecsize) vecsize = n; - garray_usedindsp(a); - dsp_add(tabreceive_perform, 3, x, sp[0]->s_vec, vecsize); - } -} - -static void *tabreceive_new(t_symbol *s) -{ - t_tabreceive *x = (t_tabreceive *)pd_new(tabreceive_class); - x->x_arrayname = s; - outlet_new(&x->x_obj, &s_signal); - return (x); -} - -void tabreceive_tilde_setup(void) -{ - tabreceive_class = class_new(gensym("tabreceive~"), - (t_newmethod)tabreceive_new, 0, - sizeof(t_tabreceive), 0, A_DEFSYM, 0); - class_addmethod(tabreceive_class, (t_method)tabreceive_dsp, - gensym("dsp"), 0); -} - diff --git a/apps/plugins/pdbox/PDa/intern/tabsend~.c b/apps/plugins/pdbox/PDa/intern/tabsend~.c index 4d7ac90..9021bac 100644 --- a/apps/plugins/pdbox/PDa/intern/tabsend~.c +++ b/apps/plugins/pdbox/PDa/intern/tabsend~.c @@ -97,100 +97,3 @@ void tabsend_tilde_setup(void) class_addmethod(tabsend_class, (t_method)tabsend_dsp, gensym("dsp"), 0); } -#include -#include -static t_class *tabsend_class; - -typedef struct _tabsend -{ - t_object x_obj; - t_sample *x_vec; - int x_graphperiod; - int x_graphcount; - t_symbol *x_arrayname; - t_clock *x_clock; - float x_f; -} t_tabsend; - -static void tabsend_tick(t_tabsend *x); - -static void *tabsend_new(t_symbol *s) -{ - t_tabsend *x = (t_tabsend *)pd_new(tabsend_class); - x->x_graphcount = 0; - x->x_arrayname = s; - x->x_clock = clock_new(x, (t_method)tabsend_tick); - x->x_f = 0; - return (x); -} - -static t_int *tabsend_perform(t_int *w) -{ - t_tabsend *x = (t_tabsend *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - int n = w[3]; - t_sample *dest = x->x_vec; - int i = x->x_graphcount; - if (!x->x_vec) goto bad; - - while (n--) - { - t_sample f = *in++; - if (PD_BADFLOAT(f)) - f = 0; - *dest++ = f; - } - if (!i--) - { - clock_delay(x->x_clock, 0); - i = x->x_graphperiod; - } - x->x_graphcount = i; -bad: - return (w+4); -} - -static void tabsend_dsp(t_tabsend *x, t_signal **sp) -{ - int i, vecsize; - t_garray *a; - - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*x->x_arrayname->s_name) - error("tabsend~: %s: no such array", x->x_arrayname->s_name); - } - else if (!garray_getfloatarray(a, &vecsize, &x->x_vec)) - error("%s: bad template for tabsend~", x->x_arrayname->s_name); - else - { - int n = sp[0]->s_n; - int ticksper = sp[0]->s_sr/n; - if (ticksper < 1) ticksper = 1; - x->x_graphperiod = ticksper; - if (x->x_graphcount > ticksper) x->x_graphcount = ticksper; - if (n < vecsize) vecsize = n; - garray_usedindsp(a); - dsp_add(tabsend_perform, 3, x, sp[0]->s_vec, vecsize); - } -} - -static void tabsend_tick(t_tabsend *x) -{ - t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class); - if (!a) bug("tabsend_tick"); - else garray_redraw(a); -} - -static void tabsend_free(t_tabsend *x) -{ - clock_free(x->x_clock); -} - -void tabsend_tilde_setup(void) -{ - tabsend_class = class_new(gensym("tabsend~"), (t_newmethod)tabsend_new, - (t_method)tabsend_free, sizeof(t_tabsend), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(tabsend_class, t_tabsend, x_f); - class_addmethod(tabsend_class, (t_method)tabsend_dsp, gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabwrite.c b/apps/plugins/pdbox/PDa/intern/tabwrite.c index 8d6a6c0..ff4e40d 100644 --- a/apps/plugins/pdbox/PDa/intern/tabwrite.c +++ b/apps/plugins/pdbox/PDa/intern/tabwrite.c @@ -82,87 +82,4 @@ void tabwrite_setup(void) class_addfloat(tabwrite_class, (t_method)tabwrite_float); class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0); } -#include -/* ------------------ tabwrite: control ------------------------ */ - -static t_class *tabwrite_class; - -typedef struct _tabwrite -{ - t_object x_obj; - t_symbol *x_arrayname; - t_clock *x_clock; - float x_ft1; - double x_updtime; - int x_set; -} t_tabwrite; - -static void tabwrite_tick(t_tabwrite *x) -{ - t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class); - if (!a) bug("tabwrite_tick"); - else garray_redraw(a); - x->x_set = 0; - x->x_updtime = clock_getsystime(); -} -static void tabwrite_float(t_tabwrite *x, t_float f) -{ - int i, vecsize; - t_garray *a; - t_sample *vec; - - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - pd_error(x, "%s: no such array", x->x_arrayname->s_name); - else if (!garray_getfloatarray(a, &vecsize, &vec)) - pd_error(x, "%s: bad template for tabwrite", x->x_arrayname->s_name); - else - { - int n = x->x_ft1; - double timesince = clock_gettimesince(x->x_updtime); - if (n < 0) n = 0; - else if (n >= vecsize) n = vecsize-1; - vec[n] = ftofix(f); - if (timesince > 1000) - { - tabwrite_tick(x); - } - else - { - if (x->x_set == 0) - { - clock_delay(x->x_clock, 1000 - timesince); - x->x_set = 1; - } - } - } -} - -static void tabwrite_set(t_tabwrite *x, t_symbol *s) -{ - x->x_arrayname = s; -} - -static void tabwrite_free(t_tabwrite *x) -{ - clock_free(x->x_clock); -} - -static void *tabwrite_new(t_symbol *s) -{ - t_tabwrite *x = (t_tabwrite *)pd_new(tabwrite_class); - x->x_ft1 = 0; - x->x_arrayname = s; - x->x_updtime = clock_getsystime(); - x->x_clock = clock_new(x, (t_method)tabwrite_tick); - floatinlet_new(&x->x_obj, &x->x_ft1); - return (x); -} - -void tabwrite_setup(void) -{ - tabwrite_class = class_new(gensym("tabwrite"), (t_newmethod)tabwrite_new, - (t_method)tabwrite_free, sizeof(t_tabwrite), 0, A_DEFSYM, 0); - class_addfloat(tabwrite_class, (t_method)tabwrite_float); - class_addmethod(tabwrite_class, (t_method)tabwrite_set, gensym("set"), A_SYMBOL, 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/tabwrite~.c b/apps/plugins/pdbox/PDa/intern/tabwrite~.c index 47a49cd..6f9113c 100644 --- a/apps/plugins/pdbox/PDa/intern/tabwrite~.c +++ b/apps/plugins/pdbox/PDa/intern/tabwrite~.c @@ -131,134 +131,3 @@ void tabwrite_tilde_setup(void) class_addfloat(tabwrite_tilde_class, tabwrite_tilde_float); } -#include -#include - -static t_class *tabwrite_tilde_class; - -typedef struct _tabwrite_tilde -{ - t_object x_obj; - int x_phase; - int x_nsampsintab; - t_sample *x_vec; - t_symbol *x_arrayname; - t_clock *x_clock; - float x_f; -} t_tabwrite_tilde; - -static void tabwrite_tilde_tick(t_tabwrite_tilde *x); - -static void *tabwrite_tilde_new(t_symbol *s) -{ - t_tabwrite_tilde *x = (t_tabwrite_tilde *)pd_new(tabwrite_tilde_class); - x->x_clock = clock_new(x, (t_method)tabwrite_tilde_tick); - x->x_phase = 0x7fffffff; - x->x_arrayname = s; - x->x_f = 0; - return (x); -} - -static t_int *tabwrite_tilde_perform(t_int *w) -{ - t_tabwrite_tilde *x = (t_tabwrite_tilde *)(w[1]); - t_sample *in = (t_sample *)(w[2]); - int n = (int)(w[3]), phase = x->x_phase, endphase = x->x_nsampsintab; - if (!x->x_vec) goto bad; - - if (endphase > phase) - { - int nxfer = endphase - phase; - t_sample *fp = x->x_vec + phase; - if (nxfer > n) nxfer = n; - phase += nxfer; - while (nxfer--) - { - t_sample f = *in++; - *fp++ = f; - } - if (phase >= endphase) - { - clock_delay(x->x_clock, 0); - phase = 0x7fffffff; - } - x->x_phase = phase; - } -bad: - return (w+4); -} - -void tabwrite_tilde_set(t_tabwrite_tilde *x, t_symbol *s) -{ - t_garray *a; - - x->x_arrayname = s; - if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class))) - { - if (*s->s_name) pd_error(x, "tabwrite~: %s: no such array", - x->x_arrayname->s_name); - x->x_vec = 0; - } - else if (!garray_getfloatarray(a, &x->x_nsampsintab, &x->x_vec)) - { - error("%s: bad template for tabwrite~", x->x_arrayname->s_name); - x->x_vec = 0; - } - else garray_usedindsp(a); -} - -static void tabwrite_tilde_dsp(t_tabwrite_tilde *x, t_signal **sp) -{ - tabwrite_tilde_set(x, x->x_arrayname); - dsp_add(tabwrite_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); -} - -static void tabwrite_tilde_bang(t_tabwrite_tilde *x) -{ - x->x_phase = 0; -} - -static void tabwrite_tilde_float(t_tabwrite_tilde *x,t_float n) -{ - if (n < x->x_nsampsintab) - x->x_phase = n; - else - x->x_phase = 0; -} - -static void tabwrite_tilde_stop(t_tabwrite_tilde *x) -{ - if (x->x_phase != 0x7fffffff) - { - tabwrite_tilde_tick(x); - x->x_phase = 0x7fffffff; - } -} - -static void tabwrite_tilde_tick(t_tabwrite_tilde *x) -{ - t_garray *a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class); - if (!a) bug("tabwrite_tilde_tick"); - else garray_redraw(a); -} - -static void tabwrite_tilde_free(t_tabwrite_tilde *x) -{ - clock_free(x->x_clock); -} - -void tabwrite_tilde_setup(void) -{ - tabwrite_tilde_class = class_new(gensym("tabwrite~"), - (t_newmethod)tabwrite_tilde_new, (t_method)tabwrite_tilde_free, - sizeof(t_tabwrite_tilde), 0, A_DEFSYM, 0); - CLASS_MAINSIGNALIN(tabwrite_tilde_class, t_tabwrite_tilde, x_f); - class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_set, - gensym("set"), A_SYMBOL, 0); - class_addmethod(tabwrite_tilde_class, (t_method)tabwrite_tilde_stop, - gensym("stop"), 0); - class_addbang(tabwrite_tilde_class, tabwrite_tilde_bang); - class_addfloat(tabwrite_tilde_class, tabwrite_tilde_float); -} diff --git a/apps/plugins/pdbox/PDa/intern/threshold~.c b/apps/plugins/pdbox/PDa/intern/threshold~.c index 78b15f7..2b8fcf8 100644 --- a/apps/plugins/pdbox/PDa/intern/threshold~.c +++ b/apps/plugins/pdbox/PDa/intern/threshold~.c @@ -133,138 +133,4 @@ void threshold_tilde_setup( void) class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_dsp, gensym("dsp"), 0); } -#include -#include - -static t_class *threshold_tilde_class; - -typedef struct _threshold_tilde -{ - t_object x_obj; - t_outlet *x_outlet1; /* bang out for high thresh */ - t_outlet *x_outlet2; /* bang out for low thresh */ - t_clock *x_clock; /* wakeup for message output */ - float x_f; /* scalar inlet */ - int x_state; /* 1 = high, 0 = low */ - t_sample x_hithresh; /* value of high threshold */ - t_sample x_lothresh; /* value of low threshold */ - float x_deadwait; /* msec remaining in dead period */ - float x_msecpertick; /* msec per DSP tick */ - float x_hideadtime; /* hi dead time in msec */ - float x_lodeadtime; /* lo dead time in msec */ -} t_threshold_tilde; - -static void threshold_tilde_tick(t_threshold_tilde *x); -static void threshold_tilde_set(t_threshold_tilde *x, - t_floatarg hithresh, t_floatarg hideadtime, - t_floatarg lothresh, t_floatarg lodeadtime); - -static t_threshold_tilde *threshold_tilde_new(t_floatarg hithresh, - t_floatarg hideadtime, t_floatarg lothresh, t_floatarg lodeadtime) -{ - t_threshold_tilde *x = (t_threshold_tilde *) - pd_new(threshold_tilde_class); - x->x_state = 0; /* low state */ - x->x_deadwait = 0; /* no dead time */ - x->x_clock = clock_new(x, (t_method)threshold_tilde_tick); - x->x_outlet1 = outlet_new(&x->x_obj, &s_bang); - x->x_outlet2 = outlet_new(&x->x_obj, &s_bang); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1")); - x->x_msecpertick = 0.; - x->x_f = 0; - threshold_tilde_set(x, hithresh, hideadtime, lothresh, lodeadtime); - return (x); -} - - /* "set" message to specify thresholds and dead times */ -static void threshold_tilde_set(t_threshold_tilde *x, - t_floatarg hithresh, t_floatarg hideadtime, - t_floatarg lothresh, t_floatarg lodeadtime) -{ - if (lothresh > hithresh) - lothresh = hithresh; - x->x_hithresh = ftofix(hithresh); - x->x_hideadtime = hideadtime; - x->x_lothresh = ftofix(lothresh); - x->x_lodeadtime = lodeadtime; -} - - /* number in inlet sets state -- note incompatible with JMAX which used - "int" message for this, impossible here because of auto signal conversion */ -static void threshold_tilde_ft1(t_threshold_tilde *x, t_floatarg f) -{ - x->x_state = (f != 0); - x->x_deadwait = 0; -} - -static void threshold_tilde_tick(t_threshold_tilde *x) -{ - if (x->x_state) - outlet_bang(x->x_outlet1); - else outlet_bang(x->x_outlet2); -} -static t_int *threshold_tilde_perform(t_int *w) -{ - t_sample *in1 = (t_sample *)(w[1]); - t_threshold_tilde *x = (t_threshold_tilde *)(w[2]); - int n = (t_int)(w[3]); - if (x->x_deadwait > 0) - x->x_deadwait -= x->x_msecpertick; - else if (x->x_state) - { - /* we're high; look for low sample */ - for (; n--; in1++) - { - if (*in1 < x->x_lothresh) - { - clock_delay(x->x_clock, 0L); - x->x_state = 0; - x->x_deadwait = x->x_lodeadtime; - goto done; - } - } - } - else - { - /* we're low; look for high sample */ - for (; n--; in1++) - { - if (*in1 >= x->x_hithresh) - { - clock_delay(x->x_clock, 0L); - x->x_state = 1; - x->x_deadwait = x->x_hideadtime; - goto done; - } - } - } -done: - return (w+4); -} - -void threshold_tilde_dsp(t_threshold_tilde *x, t_signal **sp) -{ - x->x_msecpertick = 1000. * sp[0]->s_n / sp[0]->s_sr; - dsp_add(threshold_tilde_perform, 3, sp[0]->s_vec, x, sp[0]->s_n); -} - -static void threshold_tilde_ff(t_threshold_tilde *x) -{ - clock_free(x->x_clock); -} - -void threshold_tilde_setup( void) -{ - threshold_tilde_class = class_new(gensym("threshold~"), - (t_newmethod)threshold_tilde_new, (t_method)threshold_tilde_ff, - sizeof(t_threshold_tilde), 0, - A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(threshold_tilde_class, t_threshold_tilde, x_f); - class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_set, - gensym("set"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); - class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_ft1, - gensym("ft1"), A_FLOAT, 0); - class_addmethod(threshold_tilde_class, (t_method)threshold_tilde_dsp, - gensym("dsp"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/vcf~.c b/apps/plugins/pdbox/PDa/intern/vcf~.c index 1ff0981..e78993a 100644 --- a/apps/plugins/pdbox/PDa/intern/vcf~.c +++ b/apps/plugins/pdbox/PDa/intern/vcf~.c @@ -117,122 +117,3 @@ void vcf_tilde_setup(void) class_sethelpsymbol(sigvcf_class, gensym("lop~-help.pd")); } -#include -#include -#include "cos_table.h" - -/* ---------------- vcf~ - 2-pole bandpass filter. ----------------- */ -/* GG: complex resonator with signal frequency control - this time using the bigger cos_table without interpolation - really have to switch to a separate fixpoint format sometime -*/ - -typedef struct vcfctl -{ - t_sample c_re; - t_sample c_im; - t_sample c_q; - t_sample c_isr; -} t_vcfctl; - -typedef struct sigvcf -{ - t_object x_obj; - t_vcfctl x_cspace; - t_vcfctl *x_ctl; - float x_f; -} t_sigvcf; - -t_class *sigvcf_class; - -static void *sigvcf_new(t_floatarg q) -{ - t_sigvcf *x = (t_sigvcf *)pd_new(sigvcf_class); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); - inlet_new(&x->x_obj, &x->x_obj.ob_pd, gensym("float"), gensym("ft1")); - outlet_new(&x->x_obj, gensym("signal")); - outlet_new(&x->x_obj, gensym("signal")); - x->x_ctl = &x->x_cspace; - x->x_cspace.c_re = 0; - x->x_cspace.c_im = 0; - x->x_cspace.c_q = ftofix(q); - x->x_cspace.c_isr = 0; - x->x_f = 0; - return (x); -} - -static void sigvcf_ft1(t_sigvcf *x, t_floatarg f) -{ - x->x_ctl->c_q = (f > 0 ? ftofix(f) : 0); -} - -static t_int *sigvcf_perform(t_int *w) -{ - t_sample *in1 = (t_sample *)(w[1]); - t_sample *in2 = (t_sample *)(w[2]); - t_sample *out1 = (t_sample *)(w[3]); - t_sample *out2 = (t_sample *)(w[4]); - t_vcfctl *c = (t_vcfctl *)(w[5]); - int n = (t_int)(w[6]); - int i; - t_sample re = c->c_re, re2; - t_sample im = c->c_im; - t_sample q = c->c_q; - t_sample qinv = (q > 0 ? idiv(ftofix(1.0),q) : 0); - t_sample ampcorrect = ftofix(2.0f) - idiv(ftofix(2.0f) , (q + ftofix(2.0f))); - t_sample isr = c->c_isr; - t_sample coefr, coefi; - t_sample *tab = cos_table; - t_sample oneminusr,cfindx,cf,r; - - for (i = 0; i < n; i++) - { - cf = mult(*in2++,isr); - if (cf < 0) cf = 0; - cfindx = mult(cf,ftofix(0.15915494))>>(fix1-ILOGCOSTABSIZE); /* 1/2*PI */ - r = (qinv > 0 ? ftofix(1.01) - mult(cf,qinv) : 0); - - if (r < 0) r = 0; - oneminusr = ftofix(1.02f) - r; /* hand adapted */ - - /* r*cos(cf) */ - coefr = mult(r,tab[cfindx]); - - /* r*sin(cf) */ - cfindx-=(ICOSTABSIZE>>2); - cfindx += cfindx < 0 ? ICOSTABSIZE:0; - coefi = mult(r,tab[cfindx]); - - re2 = re; - *out1++ = re = mult(ampcorrect,mult(oneminusr,*in1++)) - + mult(coefr,re2) - mult(coefi, im); - *out2++ = im = mult(coefi,re2) + mult(coefr,im); - } - c->c_re = re; - c->c_im = im; - return (w+7); -} - -static void sigvcf_dsp(t_sigvcf *x, t_signal **sp) -{ - /* TODO sr is hardcoded */ - x->x_ctl->c_isr = ftofix(0.0001424758); -// idiv(ftofix(6.28318),ftofix(sp[0]->s_sr)); - post("%f",fixtof(x->x_ctl->c_isr)); - dsp_add(sigvcf_perform, 6, - sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[3]->s_vec, - x->x_ctl, sp[0]->s_n); - -} - -void vcf_tilde_setup(void) -{ - sigvcf_class = class_new(gensym("vcf~"), (t_newmethod)sigvcf_new, 0, - sizeof(t_sigvcf), 0, A_DEFFLOAT, 0); - CLASS_MAINSIGNALIN(sigvcf_class, t_sigvcf, x_f); - class_addmethod(sigvcf_class, (t_method)sigvcf_dsp, gensym("dsp"), 0); - class_addmethod(sigvcf_class, (t_method)sigvcf_ft1, - gensym("ft1"), A_FLOAT, 0); - class_sethelpsymbol(sigvcf_class, gensym("lop~-help.pd")); -} - diff --git a/apps/plugins/pdbox/PDa/intern/vd~.c b/apps/plugins/pdbox/PDa/intern/vd~.c index 2c68b27..471df56 100644 --- a/apps/plugins/pdbox/PDa/intern/vd~.c +++ b/apps/plugins/pdbox/PDa/intern/vd~.c @@ -90,95 +90,4 @@ void vd_tilde_setup(void) class_addmethod(sigvd_class, (t_method)sigvd_dsp, gensym("dsp"), 0); CLASS_MAINSIGNALIN(sigvd_class, t_sigvd, x_f); } -#include -#include - -#include "delay.h" - -extern int ugen_getsortno(void); - -#define DEFDELVS 64 /* LATER get this from canvas at DSP time */ -static int delread_zero = 0; /* four bytes of zero for delread~, vd~ */ - -static t_class *sigvd_class; - -typedef struct _sigvd -{ - t_object x_obj; - t_symbol *x_sym; - t_sample x_sr; /* samples per msec */ - int x_zerodel; /* 0 or vecsize depending on read/write order */ - float x_f; -} t_sigvd; - -static void *sigvd_new(t_symbol *s) -{ - t_sigvd *x = (t_sigvd *)pd_new(sigvd_class); - if (!*s->s_name) s = gensym("vd~"); - x->x_sym = s; - x->x_sr = 1; - x->x_zerodel = 0; - outlet_new(&x->x_obj, &s_signal); - x->x_f = 0; - return (x); -} - -static t_int *sigvd_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - t_delwritectl *ctl = (t_delwritectl *)(w[3]); - t_sigvd *x = (t_sigvd *)(w[4]); - int n = (int)(w[5]); - - int nsamps = ctl->c_n; - int fn = n; - t_sample limit = nsamps - n - 1; - t_sample *vp = ctl->c_vec, *bp, *wp = vp + ctl->c_phase; - t_sample zerodel = x->x_zerodel; - while (n--) - { - t_time delsamps = ((long long) mult((*in++),ftofix(44.1)));//- itofix(zerodel); - int index = fixtoi(delsamps); - t_sample frac; - // post("%d: index %d f %lld",index,findex,*in); - - frac = delsamps - itofix(index); - index+=fn; - if (index < 1 ) index += nsamps ; - if (index > limit) index-= nsamps; - bp = wp - index; - if (bp < vp + 2) bp += nsamps; - *out++ = bp[-1] + mult(frac,bp[-1]-bp[0]); - wp++; - } - return (w+6); -} - - - -static void sigvd_dsp(t_sigvd *x, t_signal **sp) -{ - t_sigdelwrite *delwriter = - (t_sigdelwrite *)pd_findbyclass(x->x_sym, sigdelwrite_class); - x->x_sr = sp[0]->s_sr * 0.001; - if (delwriter) - { - sigdelwrite_checkvecsize(delwriter, sp[0]->s_n); - x->x_zerodel = (delwriter->x_sortno == ugen_getsortno() ? - 0 : delwriter->x_vecsize); - dsp_add(sigvd_perform, 5, - sp[0]->s_vec, sp[1]->s_vec, - &delwriter->x_cspace, x, sp[0]->s_n); - } - else error("vd~: %s: no such delwrite~",x->x_sym->s_name); -} - -void vd_tilde_setup(void) -{ - sigvd_class = class_new(gensym("vd~"), (t_newmethod)sigvd_new, 0, - sizeof(t_sigvd), 0, A_DEFSYM, 0); - class_addmethod(sigvd_class, (t_method)sigvd_dsp, gensym("dsp"), 0); - CLASS_MAINSIGNALIN(sigvd_class, t_sigvd, x_f); -} diff --git a/apps/plugins/pdbox/PDa/intern/vline~.c b/apps/plugins/pdbox/PDa/intern/vline~.c index 74edb83..15f0d17 100644 --- a/apps/plugins/pdbox/PDa/intern/vline~.c +++ b/apps/plugins/pdbox/PDa/intern/vline~.c @@ -182,187 +182,4 @@ void vline_tilde_setup(void) class_addmethod(vline_tilde_class, (t_method)vline_tilde_stop, gensym("stop"), 0); } -#include -#include - - - -static t_class *vline_tilde_class; - -typedef struct _vseg -{ - t_time s_targettime; - t_time s_starttime; - t_sample s_target; - struct _vseg *s_next; -} t_vseg; - -typedef struct _vline -{ - t_object x_obj; - t_sample x_value; - t_sample x_inc; - t_time x_referencetime; - t_time x_samppermsec; - t_time x_msecpersamp; - t_time x_targettime; - t_sample x_target; - float x_inlet1; - float x_inlet2; - t_vseg *x_list; -} t_vline; - -static t_int *vline_tilde_perform(t_int *w) -{ - t_vline *x = (t_vline *)(w[1]); - t_sample *out = (t_sample *)(w[2]); - int n = (int)(w[3]), i; - t_sample f = x->x_value; - t_sample inc = x->x_inc; - t_time msecpersamp = x->x_msecpersamp; - t_time samppermsec = x->x_samppermsec; - t_time timenow = clock_gettimesince(x->x_referencetime) - n * msecpersamp; - t_vseg *s = x->x_list; - for (i = 0; i < n; i++) - { - t_time timenext = timenow + msecpersamp; - checknext: - if (s) - { - /* has starttime elapsed? If so update value and increment */ - if (s->s_starttime < timenext) - { - if (x->x_targettime <= timenext) - f = x->x_target, inc = 0; - /* if zero-length segment bash output value */ - if (s->s_targettime <= s->s_starttime) - { - f = s->s_target; - inc = 0; - } - else - { - t_time incpermsec = div((s->s_target - f), - (s->s_targettime - s->s_starttime)); - f = mult(f + incpermsec,(timenext - s->s_starttime)); - inc = mult(incpermsec,msecpersamp); - } - x->x_inc = inc; - x->x_target = s->s_target; - x->x_targettime = s->s_targettime; - x->x_list = s->s_next; - t_freebytes(s, sizeof(*s)); - s = x->x_list; - goto checknext; - } - } - if (x->x_targettime <= timenext) - f = x->x_target, inc = 0; - *out++ = f; - f = f + inc; - timenow = timenext; - } - x->x_value = f; - return (w+4); -} -static void vline_tilde_stop(t_vline *x) -{ - t_vseg *s1, *s2; - for (s1 = x->x_list; s1; s1 = s2) - s2 = s1->s_next, t_freebytes(s1, sizeof(*s1)); - x->x_list = 0; - x->x_inc = 0; - x->x_inlet1 = x->x_inlet2 = 0; -} - -static void vline_tilde_float(t_vline *x, t_float f) -{ - t_time timenow = clock_gettimesince(x->x_referencetime); - t_sample inlet1 = (x->x_inlet1 < 0 ? 0 : (t_sample)x->x_inlet1); - t_sample inlet2 = (t_sample) x->x_inlet2; - t_time starttime = timenow + inlet2; - t_vseg *s1, *s2, *deletefrom = 0, - *snew = (t_vseg *)t_getbytes(sizeof(*snew)); - if (PD_BADFLOAT(f)) - f = 0; - - /* negative delay input means stop and jump immediately to new value */ - if (inlet2 < 0) - { - vline_tilde_stop(x); - x->x_value = ftofix(f); - return; - } - /* check if we supplant the first item in the list. We supplant - an item by having an earlier starttime, or an equal starttime unless - the equal one was instantaneous and the new one isn't (in which case - we'll do a jump-and-slide starting at that time.) */ - if (!x->x_list || x->x_list->s_starttime > starttime || - (x->x_list->s_starttime == starttime && - (x->x_list->s_targettime > x->x_list->s_starttime || inlet1 <= 0))) - { - deletefrom = x->x_list; - x->x_list = snew; - } - else - { - for (s1 = x->x_list; s2 = s1->s_next; s1 = s2) - { - if (s2->s_starttime > starttime || - (s2->s_starttime == starttime && - (s2->s_targettime > s2->s_starttime || inlet1 <= 0))) - { - deletefrom = s2; - s1->s_next = snew; - goto didit; - } - } - s1->s_next = snew; - deletefrom = 0; - didit: ; - } - while (deletefrom) - { - s1 = deletefrom->s_next; - t_freebytes(deletefrom, sizeof(*deletefrom)); - deletefrom = s1; - } - snew->s_next = 0; - snew->s_target = f; - snew->s_starttime = starttime; - snew->s_targettime = starttime + inlet1; - x->x_inlet1 = x->x_inlet2 = 0; -} - -static void vline_tilde_dsp(t_vline *x, t_signal **sp) -{ - dsp_add(vline_tilde_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); - x->x_samppermsec = idiv(ftofix(sp[0]->s_sr),ftofix(1000)); - x->x_msecpersamp = idiv(ftofix(1000),ftofix(sp[0]->s_sr)); -} - -static void *vline_tilde_new(void) -{ - t_vline *x = (t_vline *)pd_new(vline_tilde_class); - outlet_new(&x->x_obj, gensym("signal")); - floatinlet_new(&x->x_obj, &x->x_inlet1); - floatinlet_new(&x->x_obj, &x->x_inlet2); - x->x_inlet1 = x->x_inlet2 = 0; - x->x_value = x->x_inc = 0; - x->x_referencetime = clock_getlogicaltime(); - x->x_list = 0; - x->x_samppermsec = 0; - return (x); -} - -void vline_tilde_setup(void) -{ - vline_tilde_class = class_new(gensym("vline~"), vline_tilde_new, - (t_method)vline_tilde_stop, sizeof(t_vline), 0, 0); - class_addfloat(vline_tilde_class, (t_method)vline_tilde_float); - class_addmethod(vline_tilde_class, (t_method)vline_tilde_dsp, - gensym("dsp"), 0); - class_addmethod(vline_tilde_class, (t_method)vline_tilde_stop, - gensym("stop"), 0); -} diff --git a/apps/plugins/pdbox/PDa/intern/vsnapshot~.c b/apps/plugins/pdbox/PDa/intern/vsnapshot~.c index afa9417..282a6f2 100644 --- a/apps/plugins/pdbox/PDa/intern/vsnapshot~.c +++ b/apps/plugins/pdbox/PDa/intern/vsnapshot~.c @@ -86,91 +86,3 @@ void vsnapshot_tilde_setup(void) class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang); } -#include -#include - - -static t_class *vsnapshot_tilde_class; - -typedef struct _vsnapshot -{ - t_object x_obj; - int x_n; - int x_gotone; - t_sample *x_vec; - float x_f; - float x_sampspermsec; - double x_time; -} t_vsnapshot; - -static void *vsnapshot_tilde_new(void) -{ - t_vsnapshot *x = (t_vsnapshot *)pd_new(vsnapshot_tilde_class); - outlet_new(&x->x_obj, &s_float); - x->x_f = 0; - x->x_n = 0; - x->x_vec = 0; - x->x_gotone = 0; - return (x); -} - -static t_int *vsnapshot_tilde_perform(t_int *w) -{ - t_sample *in = (t_sample *)(w[1]); - t_vsnapshot *x = (t_vsnapshot *)(w[2]); - t_sample *out = x->x_vec; - int n = x->x_n, i; - for (i = 0; i < n; i++) - out[i] = in[i]; - x->x_time = clock_getlogicaltime(); - x->x_gotone = 1; - return (w+3); -} - -static void vsnapshot_tilde_dsp(t_vsnapshot *x, t_signal **sp) -{ - int n = sp[0]->s_n; - if (n != x->x_n) - { - if (x->x_vec) - t_freebytes(x->x_vec, x->x_n * sizeof(t_sample)); - x->x_vec = (t_sample *)getbytes(n * sizeof(t_sample)); - x->x_gotone = 0; - x->x_n = n; - } - x->x_sampspermsec = sp[0]->s_sr / 1000; - dsp_add(vsnapshot_tilde_perform, 2, sp[0]->s_vec, x); -} - -static void vsnapshot_tilde_bang(t_vsnapshot *x) -{ - float val; - if (x->x_gotone) - { - int indx = clock_gettimesince(x->x_time) * x->x_sampspermsec; - if (indx < 0) - indx = 0; - else if (indx >= x->x_n) - indx = x->x_n - 1; - val = x->x_vec[indx]; - } - else val = 0; - outlet_float(x->x_obj.ob_outlet, val); -} - -static void vsnapshot_tilde_ff(t_vsnapshot *x) -{ - if (x->x_vec) - t_freebytes(x->x_vec, x->x_n * sizeof(t_sample)); -} - -void vsnapshot_tilde_setup(void) -{ - vsnapshot_tilde_class = class_new(gensym("vsnapshot~"), - vsnapshot_tilde_new, (t_method)vsnapshot_tilde_ff, - sizeof(t_vsnapshot), 0, 0); - CLASS_MAINSIGNALIN(vsnapshot_tilde_class, t_vsnapshot, x_f); - class_addmethod(vsnapshot_tilde_class, (t_method)vsnapshot_tilde_dsp, gensym("dsp"), 0); - class_addbang(vsnapshot_tilde_class, vsnapshot_tilde_bang); -} - diff --git a/apps/plugins/pdbox/PDa/intern/wrap~.c b/apps/plugins/pdbox/PDa/intern/wrap~.c index dda79f2..c011bab 100644 --- a/apps/plugins/pdbox/PDa/intern/wrap~.c +++ b/apps/plugins/pdbox/PDa/intern/wrap~.c @@ -51,54 +51,3 @@ void wrap_tilde_setup(void) class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0); } -#include -#include - -typedef struct wrap -{ - t_object x_obj; - float x_f; -} t_sigwrap; - -t_class *sigwrap_class; - -static void *sigwrap_new(void) -{ - t_sigwrap *x = (t_sigwrap *)pd_new(sigwrap_class); - outlet_new(&x->x_obj, gensym("signal")); - x->x_f = 0; - return (x); -} - -static t_int *sigwrap_perform(t_int *w) -{ - t_sample *in = *(t_sample **)(w+1), *out = *(t_sample **)(w+2); - t_int n = *(t_int *)(w+3); - while (n--) - { - t_sample f = *in++; - -#ifndef FIXEDPOINT - int k = f; - if (f > 0) *out++ = f-k; - else *out++ = f - (k-1); -#else - int k = ftofix(1.) - 1; - *out = f&k; -#endif - } - return (w + 4); -} - -static void sigwrap_dsp(t_sigwrap *x, t_signal **sp) -{ - dsp_add(sigwrap_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); -} - -void wrap_tilde_setup(void) -{ - sigwrap_class = class_new(gensym("wrap~"), (t_newmethod)sigwrap_new, 0, - sizeof(t_sigwrap), 0, 0); - CLASS_MAINSIGNALIN(sigwrap_class, t_sigwrap, x_f); - class_addmethod(sigwrap_class, (t_method)sigwrap_dsp, gensym("dsp"), 0); -} -- cgit v1.1