summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/intern/samphold~.c
diff options
context:
space:
mode:
authorPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
committerPeter D'Hoye <peter.dhoye@gmail.com>2009-05-24 21:28:16 +0000
commit526b5580dabbfed7cfe5439dc3a90ec727f563c2 (patch)
tree22b1af92348785daad16714ee5e2b633017e0e48 /apps/plugins/pdbox/PDa/intern/samphold~.c
parent4f2dfcc01b260d946044ef2b6af5fe36cb772c8d (diff)
downloadrockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.tar.gz
rockbox-526b5580dabbfed7cfe5439dc3a90ec727f563c2.zip
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
Diffstat (limited to 'apps/plugins/pdbox/PDa/intern/samphold~.c')
-rw-r--r--apps/plugins/pdbox/PDa/intern/samphold~.c74
1 files changed, 0 insertions, 74 deletions
diff --git a/apps/plugins/pdbox/PDa/intern/samphold~.c b/apps/plugins/pdbox/PDa/intern/samphold~.c
index 5ccf3d9cfe..8f0656c795 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)
73 class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp, 73 class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp,
74 gensym("dsp"), 0); 74 gensym("dsp"), 0);
75} 75}
76#include <m_pd.h>
77#include <m_fixed.h>
78
79typedef struct sigsamphold
80{
81 t_object x_obj;
82 t_sample x_f;
83 t_sample x_lastin;
84 t_sample x_lastout;
85} t_sigsamphold;
86
87t_class *sigsamphold_class;
88
89static void *sigsamphold_new(void)
90{
91 t_sigsamphold *x = (t_sigsamphold *)pd_new(sigsamphold_class);
92 inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
93 outlet_new(&x->x_obj, gensym("signal"));
94 x->x_lastin = 0;
95 x->x_lastout = 0;
96 x->x_f = 0;
97 return (x);
98}
99
100static t_int *sigsamphold_perform(t_int *w)
101{
102 t_sample *in1 = (t_sample *)(w[1]);
103 t_sample *in2 = (t_sample *)(w[2]);
104 t_sample *out = (t_sample *)(w[3]);
105 t_sigsamphold *x = (t_sigsamphold *)(w[4]);
106 int n = (t_int)(w[5]);
107 int i;
108 t_sample lastin = x->x_lastin;
109 t_sample lastout = x->x_lastout;
110 for (i = 0; i < n; i++, *in1++)
111 {
112 t_sample next = *in2++;
113 if (next < lastin) lastout = *in1;
114 *out++ = lastout;
115 lastin = next;
116 }
117 x->x_lastin = lastin;
118 x->x_lastout = lastout;
119 return (w+6);
120}
121 76
122static void sigsamphold_dsp(t_sigsamphold *x, t_signal **sp)
123{
124 dsp_add(sigsamphold_perform, 5,
125 sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec,
126 x, sp[0]->s_n);
127}
128
129static void sigsamphold_reset(t_sigsamphold *x)
130{
131 x->x_lastin = 0x7fffffff;
132}
133
134static void sigsamphold_set(t_sigsamphold *x, t_float f)
135{
136 x->x_lastout = f;
137}
138
139void samphold_tilde_setup(void)
140{
141 sigsamphold_class = class_new(gensym("samphold~"),
142 (t_newmethod)sigsamphold_new, 0, sizeof(t_sigsamphold), 0, 0);
143 CLASS_MAINSIGNALIN(sigsamphold_class, t_sigsamphold, x_f);
144 class_addmethod(sigsamphold_class, (t_method)sigsamphold_set,
145 gensym("set"), A_FLOAT, 0);
146 class_addmethod(sigsamphold_class, (t_method)sigsamphold_reset,
147 gensym("reset"), 0);
148 class_addmethod(sigsamphold_class, (t_method)sigsamphold_dsp,
149 gensym("dsp"), 0);
150}