I attach a version of lrshift~.c and the new help file. It now accepts floats to change the shift amount. Maybe you could check to see if it works well. I guess I could commit it to cvs if approved. Martin
From: "Charles Henry" czhenry@gmail.com Date: 2006/11/06 Mon AM 11:24:26 EST To: pd-list@iem.at Subject: Re: [PD] Per sampleblock manipulation question
lrshift~ needs to have a second inlet, or a float method to change the argument (grumble....gripe....moan) :P
I'd volunteer to add it, but what would the procedure be like for that? Chuck
On 11/6/06, Mathieu Bouchard matju@artengine.ca wrote:
On Sun, 5 Nov 2006, thewade wrote:
Quoting Mathieu Bouchard matju@artengine.ca: I will poke around in the help files to see if I can find the incorrectly-named help for this object, to see what the related objects are.
It's just named rlshift~ instead. Else it should work fine (unless you have additional -path -helppath required, which may happen on some setups)
no, convolution is a bunch of sample-wise shifts and [*~] and [+~] together (as many as there are values in the convolution kernel).
Yes, but conceptually convolution is converting time domain sounds into frequency domain, storing the values in a sample block, and multiplying the two blocks together (and normalizing of course).
Convolution can be defined in two completely equivalent ways: one as polynomial product in the time domain (using a "z-series" representation) and one as the complex multiplication of two frequency spectra using an infinite blocksize.
Almost all of the time, the time-domain representation is taught first. This might be especially important as the frequency-domain only becomes tangible once some kind of Fourier transform is in place, and the polynomial product is certainly easier to explain than the Fourier transform. (and that's even more true for realtime)
But if you want to apply convolutions with large kernels and/or large pieces of data, you really have to use [fft~] (for sound) or [#fft] (for spatial-frequencies of images).
So if one block has no sound at 300Hz and the other block does, the resulting block does NOT have sound at 300Hz, right?
Right.
So if your block size was four and you had one FFT block that was: 0,1,0,1 And another that was: 0,0,0,1 The convolved "real" sound block (before going to ifft~) would be 0,0,0,1 Right?
Yes, supposing each of those values is a complex number. But that's because "AND" is a special case of multiplication, because:
0*0 = 0 0*1 = 0 1*0 = 0 1*1 = 1
so * over {0,1} is exactly AND.
_ _ __ ___ _____ ________ _____________ _____________________ ...
| Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montréal QC Canada
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
#include "m_pd.h"
/* ------------------------ lrshift~ ----------------------------- */
static t_class *lrshift_tilde_class;
typedef struct _lrshift_tilde { t_object x_obj; int x_n; } t_lrshift_tilde;
static t_int *leftshift_perform(t_int *w) { t_float *in = (t_float *)(w[1]); t_float *out= (t_float *)(w[2]); int n = (int)(w[3]); int shift = (int)(w[4]); in += shift; n -= shift; while (n--) *out++ = *in++; while (shift--) *out++ = 0; return (w+5); }
static t_int *rightshift_perform(t_int *w) { t_float *in = (t_float *)(w[1]); t_float *out= (t_float *)(w[2]); int n = (int)(w[3]); int shift = (int)(w[4]); n -= shift; in -= shift; while (n--) *--out = *--in; while (shift--) *--out = 0; return (w+5); }
static t_int *lrshift_perform(t_int *w) { t_float *in = (t_float *)(w[1]); t_float *out= (t_float *)(w[2]); int n = (int)(w[3]); t_lrshift_tilde *x = (t_lrshift_tilde *)w[4]; int shift = x->x_n;
if (shift > n)
shift = n;
if (shift < -n)
shift = -n;
if (shift < 0)
{
shift = -shift;
out += n;
in += n;
n -= shift;
in -= shift;
while (n--)
*--out = *--in;
while (shift--)
*--out = 0;
}
else
{
in += shift;
n -= shift;
while (n--)
*out++ = *in++;
while (shift--)
*out++ = 0;
}
return (w+5);
}
static void lrshift_tilde_dsp(t_lrshift_tilde *x, t_signal **sp) { int n = sp[0]->s_n; dsp_add(lrshift_perform, 4, sp[0]->s_vec, sp[1]->s_vec, n, x);
}
static void *lrshift_tilde_new(t_floatarg f) { t_lrshift_tilde *x = (t_lrshift_tilde *)pd_new(lrshift_tilde_class); x->x_n = f; outlet_new(&x->x_obj, gensym("signal")); return (x); }
static void lrshift_tilde_float(t_lrshift_tilde *x, t_floatarg f) { x->x_n = f; }
void lrshift_tilde_setup(void) { lrshift_tilde_class = class_new(gensym("lrshift~"), (t_newmethod)lrshift_tilde_new, 0, sizeof(t_lrshift_tilde), 0, A_DEFFLOAT, 0); class_addmethod(lrshift_tilde_class, nullfn, gensym("signal"), 0); class_addmethod(lrshift_tilde_class, (t_method)lrshift_tilde_dsp, gensym("dsp"), 0); class_addfloat(lrshift_tilde_class, (t_method)lrshift_tilde_float); }
#N canvas 552 267 685 337 12; #X msg 268 277 bang; #X obj 244 303 print~; #X msg 185 278 bang; #X obj 161 304 print~; #X text 53 117 click here first; #X msg 72 270 bang; #X obj 48 296 print~; #X text 162 222 shift left; #X text 243 224 shift right; #X obj 161 252 lrshift~ 1; #X obj 244 251 lrshift~ -1; #X text 39 37 Acting at whatever vector size the window is running at , lrshift~ shifts samples to the left (toward the beginning sample) or to the right. The argument gives the direction and the amount of the shift. The rightmost (or leftmost) samples are set to zero.; #N canvas 0 0 450 300 (subpatch) 0; #X array shiftin 64 float 0; #X coords 0 1 63 0 200 140 1; #X restore 448 118 graph; #X text 115 11 -- shift signal vector elements left or right; #X msg 54 138 ; pd dsp 1 ; shiftin 1 1; #X obj 48 204 tabreceive~ shiftin; #X text 525 308 Updated for Pd 0.31.; #X obj 47 11 lrshift~; #X floatatom 339 209 5 0 0 0 - - -; #X msg 363 277 bang; #X obj 339 303 print~; #X text 277 186 change shift amount; #X obj 339 251 lrshift~; #X connect 0 0 1 0; #X connect 2 0 3 0; #X connect 5 0 6 0; #X connect 9 0 3 0; #X connect 10 0 1 0; #X connect 15 0 6 0; #X connect 15 0 9 0; #X connect 15 0 10 0; #X connect 15 0 22 0; #X connect 18 0 22 0; #X connect 19 0 20 0; #X connect 22 0 20 0;
Thanks Martin. I will try it out and see! Chuck
On 11/6/06, martin.peach@sympatico.ca martin.peach@sympatico.ca wrote:
I attach a version of lrshift~.c and the new help file. It now accepts floats to change the shift amount. Maybe you could check to see if it works well. I guess I could commit it to cvs if approved. Martin
Hallo, martin.peach@sympatico.ca hat gesagt: // martin.peach@sympatico.ca wrote:
I attach a version of lrshift~.c and the new help file. It now accepts floats to change the shift amount. Maybe you could check to see if it works well. I guess I could commit it to cvs if approved.
To get it into Miller's branch it's best to put it into the Sourceforge bugtracker so it won't get lost.
Frank Barknecht _ ______footils.org_ __goto10.org__
Works great! Maybe, you could comment out the leftperform and rightperform routines, included, but not used anymore, before putting in CVS. Chuck
On 11/6/06, martin.peach@sympatico.ca martin.peach@sympatico.ca wrote:
I attach a version of lrshift~.c and the new help file. It now accepts floats to change the shift amount. Maybe you could check to see if it works well. I guess I could commit it to cvs if approved. Martin