aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas O Fredericks <mrtof@users.sourceforge.net>2009-09-29 22:41:29 +0000
committerThomas O Fredericks <mrtof@users.sourceforge.net>2009-09-29 22:41:29 +0000
commit9778ee26904658e7c0a149e71d5de8d534209012 (patch)
treeb951e5142489c2346a31f61cdd5df96c8d4809da
parente420e83534daf42568eba431d3b994ef585dabf9 (diff)
Modified crossfade~'s float inlet to a signal inlet
svn path=/trunk/externals/tof/; revision=12495
-rw-r--r--help/crossfade~-help.pd42
-rw-r--r--src/crossfade~.c43
2 files changed, 51 insertions, 34 deletions
diff --git a/help/crossfade~-help.pd b/help/crossfade~-help.pd
index 488b0e9..7149f02 100644
--- a/help/crossfade~-help.pd
+++ b/help/crossfade~-help.pd
@@ -1,19 +1,18 @@
-#N canvas 339 91 631 441 10;
+#N canvas 339 91 665 533 10;
#X floatatom 323 276 5 0 0 0 - - -;
-#X obj 123 292 crossfade~ 2;
#X obj 32 -13 cnv 15 400 100 empty empty empty 20 12 0 14 -249661 -66577
0;
#X text 37 21 author: mrtoftrash@gmail.com;
#X text 37 32 version: 2009-06-04 (initial release);
#X obj 36 164 osc~ 100;
-#X obj 123 388 dac~;
+#X obj 36 444 dac~;
#X obj 197 189 noise~;
#X obj 93 163 osc~ 500;
#X obj 248 189 osc~ 200;
-#X obj 122 361 *~ 0.5;
-#X obj 193 360 *~ 0.5;
-#X obj 229 338 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
--1 -1 0 1;
+#X obj 35 417 *~ 0.5;
+#X obj 106 416 *~ 0.5;
+#X obj 142 394 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 400 1;
#X text 35 142 First source: signal inlets to the left.;
#X text 187 170 Second source: signal inlets to the right.;
#X obj 326 255 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
@@ -25,15 +24,20 @@ value.;
#X text 37 -14 description: crossfades 2 multi-channel sources;
#X text 41 104 Argument: The number of channels for each source (defaults
to 2);
-#X connect 0 0 1 4;
-#X connect 1 0 10 0;
-#X connect 1 1 11 0;
-#X connect 5 0 1 0;
-#X connect 7 0 1 2;
-#X connect 8 0 1 1;
-#X connect 9 0 1 3;
-#X connect 10 0 6 0;
-#X connect 11 0 6 1;
-#X connect 12 0 10 1;
-#X connect 12 0 11 1;
-#X connect 15 0 0 0;
+#X obj 36 348 tof/crossfade~ 2;
+#X msg 323 298 \$1 5;
+#X obj 328 336 line~;
+#X connect 0 0 21 0;
+#X connect 4 0 20 0;
+#X connect 6 0 20 2;
+#X connect 7 0 20 1;
+#X connect 8 0 20 3;
+#X connect 9 0 5 0;
+#X connect 10 0 5 1;
+#X connect 11 0 9 1;
+#X connect 11 0 10 1;
+#X connect 14 0 0 0;
+#X connect 20 0 9 0;
+#X connect 20 1 10 0;
+#X connect 21 0 22 0;
+#X connect 22 0 20 4;
diff --git a/src/crossfade~.c b/src/crossfade~.c
index 75cd9b6..6a546cd 100644
--- a/src/crossfade~.c
+++ b/src/crossfade~.c
@@ -8,7 +8,8 @@ static t_class *crossfade_tilde_class;
typedef struct _crossfade_tilde {
t_object x_obj;
- t_float mix; //The mix value (0: input 1, 1:input2)
+ //t_float mix; //The mix value (0: input 1, 1:input2)
+ //t_float sig_mode;
int n_in;
int channels;
t_sample **in;
@@ -27,19 +28,24 @@ static t_int *crossfade_tilde_perform(t_int *w)
t_crossfade_tilde *x = (t_crossfade_tilde *)(w[1]);
int n = (int)(w[2]);
- if (x->mix < 0) x->mix = 0;
- if (x->mix > 1) x->mix = 1;
- t_float inv_mix = 1-x->mix;
+ //if (x->mix < 0) x->mix = 0;
+ //if (x->mix > 1) x->mix = 1;
+ //t_float inv_mix = 1-x->mix;
int i;
int j;
t_sample* out;
-
-
+ t_sample* mix = (t_sample *) (w[3]);
+ t_sample mix_f;
+ t_sample inv_mix_f;
+
for ( j =0; j < n; j++) {
-
+ mix_f = *mix++;
+ //if (mix_f > 1) mix_f = 1;
+ //if (mix_f < 0) mix_f = 0;
+ inv_mix_f = 1-mix_f;
// Copy one sample of all the inputs
for ( i=0; i < x->n_in;i++ ) {
x->buffer[i] = (t_sample) x->in[i][j];
@@ -48,13 +54,13 @@ static t_int *crossfade_tilde_perform(t_int *w)
for ( i=0; i < x->channels;i++ ) {
out = (t_sample *)(x->out[i]);
- out[j] = (x->buffer[i] * inv_mix) + (x->buffer[i+x->channels] * x->mix) ;
+ out[j] = (x->buffer[i] * inv_mix_f) + (x->buffer[i+x->channels] * mix_f) ;
}
}
- return (w+3);
+ return (w+4);
}
@@ -67,11 +73,13 @@ static void crossfade_tilde_dsp(t_crossfade_tilde *x, t_signal **sp)
t_sample **dummy=x->in;
for(n=0;n<x->n_in;n++)*dummy++=sp[n]->s_vec;
+ //Add +1 because of the mix inlet
+
dummy=x->out;
- for(n=0;n<x->n_out;n++)*dummy++=sp[n+x->n_in]->s_vec;
+ for(n=0;n<x->n_out;n++)*dummy++=sp[n+x->n_in+1]->s_vec;
- dsp_add(crossfade_tilde_perform, 2, x, sp[0]->s_n);
+ dsp_add(crossfade_tilde_perform, 3, x, sp[0]->s_n, sp[x->n_in]->s_vec);
}
@@ -91,7 +99,6 @@ static void *crossfade_tilde_new(t_floatarg f)
x->channels = (int) f;
if ( x->channels < 1 ) x->channels = 2;
-
x->n_in = x->channels * 2;
x->in = (t_sample **)getbytes(x->n_in * sizeof(t_sample *));
@@ -106,18 +113,24 @@ static void *crossfade_tilde_new(t_floatarg f)
x->buffer = getbytes(x->n_in * sizeof( * x->buffer));
-
+ //if (ac && IS_A_FLOAT(av,0) {
+ // x->sig_mode = 0;
+ //} else {
+ // x->sig_mode = 1;
+ //}
for (i=0; i < x->n_in - 1; i++) {
inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
}
+ //if ( x->sig_mode ) inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
+
for (i=0; i < x->n_out; i++) {
outlet_new(&x->x_obj, &s_signal);
}
-
- floatinlet_new (&x->x_obj, &x->mix);
+ //if ( x->sig_mode == 0 ) floatinlet_new (&x->x_obj, &x->mix);
return (void *)x;