pd-bsaylor_0.1/0000755000076500007650000000000011466373565012206 5ustar hanshanspd-bsaylor_0.1/partconv~-help.pd0000644000076500007650000000420411466373036015504 0ustar hanshans#N canvas 0 30 680 606 10; #X obj 201 569 dac~; #X obj 40 168 dirac~; #X msg 40 148 0; #X obj 177 190 osc~; #X obj 177 164 mtof; #X floatatom 177 141 5 0 0 0 - - -; #X obj 419 358 soundfiler; #X obj 419 259 loadbang; #X obj 201 541 *~; #X obj 302 282 openpanel; #X obj 302 309 t b s; #X obj 302 240 bng 32 250 50 0 empty empty empty 0 -6 0 8 -260818 -1 -1; #X obj 331 466 vsl 8 128 0 100 0 1 empty empty empty 0 -8 0 8 -260818 -1 -1 9700 1; #X text 300 219 load a soundfile to use as the impulse response; #X text 9 127 test with an impulse; #X text 431 7 Ben Saylor - bensaylor@fastmail.fm; #X text 105 7 partitioned convolution external; #X obj 437 388 table irL; #X msg 272 350 set irL; #X msg 341 350 set irR; #X obj 230 541 *~; #X obj 259 426 partconv~ irR 2048; #X msg 427 333 read -resize \$1 irL irR; #X obj 437 410 table irR; #X msg 232 190 0; #X msg 270 190 0.1; #X obj 177 212 *~ 0; #X obj 271 515 dbtorms; #X text 226 155 test with a sine; #X obj 110 187 adc~ 1; #X text 10 8 partconv~; #X text 26 44 version 0.2 \, August 12 \, 2005; #X text 258 43 [partconv~ ]; #X obj 126 426 partconv~ irL 2048; #X msg 419 283 read -resize examples/noiseburst.wav irL; #X msg 419 307 read -resize examples/noiseburst.wav irR; #X text 258 71 The partition size must be a power of 2 greater than or equal to the block size. Larger partition sizes are more efficient \, to a point \, but increase latency (the delay between input and output is equal to the partition size minus the block size).; #X connect 1 0 21 0; #X connect 1 0 33 0; #X connect 2 0 1 0; #X connect 3 0 26 0; #X connect 4 0 3 0; #X connect 5 0 4 0; #X connect 7 0 34 0; #X connect 7 0 35 0; #X connect 8 0 0 0; #X connect 9 0 10 0; #X connect 10 0 18 0; #X connect 10 0 19 0; #X connect 10 1 22 0; #X connect 11 0 9 0; #X connect 12 0 27 0; #X connect 18 0 33 0; #X connect 19 0 21 0; #X connect 20 0 0 1; #X connect 21 0 20 0; #X connect 22 0 6 0; #X connect 24 0 26 1; #X connect 25 0 26 1; #X connect 26 0 21 0; #X connect 26 0 33 0; #X connect 27 0 8 1; #X connect 27 0 20 1; #X connect 29 0 21 0; #X connect 29 0 33 0; #X connect 33 0 8 0; #X connect 34 0 6 0; #X connect 35 0 6 0; pd-bsaylor_0.1/aenv~.c0000644000076500007650000000764111466373036013502 0ustar hanshans/* Copyright 2002 Benjamin R. Saylor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "m_pd.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif enum { ATTACK, DECAY, RELEASE, LINEAR, LOGARITHMIC }; #define THRESHOLD 0.99 #define SCALE 4600.0 #define CLIP(x) ((x < 0.1) ? 0.1 : x) #define IS_DENORMAL(f) (((*(unsigned int *)&(f))&0x7f800000) == 0) static t_class *aenv_class; typedef struct _aenv { t_object x_obj; t_float srate; t_float a; t_float d; t_float s; t_float r; t_float lastval; int stage; int attacktype; } t_aenv; static t_int *aenv_perform(t_int *w) { t_aenv *x = (t_aenv *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); t_float lastval = x->lastval; t_float a, d, s, r; switch (x->stage) { case ATTACK: if (x->attacktype == LINEAR) { a = 1000 / (x->a * x->srate); while (n--) { *out = lastval + a; lastval = *(out++); if (lastval > THRESHOLD) { x->stage = DECAY; break; } } } else { a = SCALE / (CLIP(x->a) * x->srate); while (n--) { *out = lastval + a * (1 - lastval); lastval = *(out++); if (lastval > THRESHOLD) { x->stage = DECAY; break; } } } case DECAY: d = SCALE / (CLIP(x->d) * x->srate); s = x->s; while (n-- > 0) { *out = lastval - d * (lastval - s); if (IS_DENORMAL(*out)) *out = 0.0; lastval = *(out++); } break; case RELEASE: r = SCALE / (CLIP(x->r) * x->srate); while (n--) { *out = lastval - r * lastval; if (IS_DENORMAL(*out)) *out = 0.0; lastval = *(out++); } } x->lastval = lastval; return (w+4); } static void aenv_dsp(t_aenv *x, t_signal **sp) { dsp_add(aenv_perform, 3, x, sp[0]->s_vec, sp[0]->s_n); } static void aenv_float(t_aenv *x, t_float f) { if (f == 0) x->stage = RELEASE; else x->stage = ATTACK; } static void *aenv_new(t_symbol *s, int argc, t_atom *argv) { t_aenv *x = (t_aenv *)pd_new(aenv_class); floatinlet_new(&x->x_obj, &x->a); floatinlet_new(&x->x_obj, &x->d); floatinlet_new(&x->x_obj, &x->s); floatinlet_new(&x->x_obj, &x->r); outlet_new(&x->x_obj, gensym("signal")); x->srate = sys_getsr(); x->a = 500; x->d = 500; x->s = 0.5; x->r = 500; x->lastval = 0; x->stage = RELEASE; x->attacktype = LOGARITHMIC; if (argc == 4) { x->a = atom_getfloat(argv); x->d = atom_getfloat(argv+1); x->s = atom_getfloat(argv+2); x->r = atom_getfloat(argv+3); } return (x); } static void aenv_lina(t_aenv *x) { x->attacktype = LINEAR; } static void aenv_loga(t_aenv *x) { x->attacktype = LOGARITHMIC; } static void aenv_zero(t_aenv *x) { x->stage = RELEASE; x->lastval = 0.0; } void aenv_tilde_setup(void) { aenv_class = class_new(gensym("aenv~"), (t_newmethod)aenv_new, 0, sizeof(t_aenv), 0, A_GIMME, 0); class_addmethod(aenv_class, (t_method)aenv_dsp, gensym("dsp"), 0); class_addfloat(aenv_class, (t_method)aenv_float); class_addmethod(aenv_class, (t_method)aenv_lina, gensym("lina"), 0); class_addmethod(aenv_class, (t_method)aenv_loga, gensym("loga"), 0); class_addmethod(aenv_class, (t_method)aenv_zero, gensym("zero"), 0); } pd-bsaylor_0.1/partconv~.vcproj0000644000076500007650000001122611466373036015460 0ustar hanshans pd-bsaylor_0.1/sse-conv.inc.c0000644000076500007650000000543211466373036014654 0ustar hanshans// Ben Saylor 2005-08-10 // attempt at an SSE version of the convolution loop. // Results sound weird, and CPU usage is about the same. :( cursumbuf_fd = (v4sf *) x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; input_fd = (v4sf *) x->input_fd; irpart_fd = (v4sf *) x->irpart_fd[p]; nvecs = x->paddedsize/4; for (v1=0, v2=1; v2 < nvecs; v1+=2, v2+=2) { // v1 is the index of the first 4-float vector (v4sf) to process (v2 is the second) // input_fd, etc. are v4sf pointers. // pull in 4 bins (8 floats) (2 v4sfs) at a time. // (a + bi) * (c + di) = (ac - bd) + (ad + bc)i asm volatile ( // load inputs "movaps %[in1], %%xmm0\n\t" "movaps %[in2], %%xmm6\n\t" "movaps %[ir1], %%xmm2\n\t" "movaps %[ir2], %%xmm7\n\t" "movaps %%xmm0, %%xmm1\n\t" "movaps %%xmm2, %%xmm3\n\t" // xmm0 = xmm1 = [a1 b1 a2 b2] // xmm6 = [a3 b3 a4 b4] // xmm2 = xmm3 = [c1 d1 c2 d2] // xmm7 = [c3 d3 c4 d4] // de-interleave real and imaginary parts "shufps $0x88, %%xmm6, %%xmm0\n\t" // xmm0 = [a1 a2 a3 a4] "shufps $0xDD, %%xmm6, %%xmm1\n\t" // xmm1 = [b1 b2 b3 b4] "shufps $0x88, %%xmm7, %%xmm2\n\t" // xmm2 = [c1 c2 c3 c4] "shufps $0xDD, %%xmm7, %%xmm3\n\t" // xmm3 = [d1 d2 d3 d4] // load output (early, maybe it will help) "movaps %[out1], %%xmm6\n\t" "movaps %[out2], %%xmm7\n\t" // compute the real part of the complex product // (work on copies of xmm0 and xmm1, because we need to keep them) "movaps %%xmm0, %%xmm4\n\t" // xmm4 = [a1 a2 a3 a4] "mulps %%xmm2, %%xmm4\n\t" // xmm4 = [a1c1 a2c2 a3c3 a4c4] "movaps %%xmm1, %%xmm5\n\t" // xmm5 = [b1 b2 b3 b4] "mulps %%xmm3, %%xmm5\n\t" // xmm5 = [b1d1 b2d2 b3d3 b4d4] "subps %%xmm5, %%xmm4\n\t" // xmm4 = (ac - bd) [r1 r2 r3 r4] // compute the imaginary part of the complex product "mulps %%xmm3, %%xmm0\n\t" // xmm0 = [a1d1 a2d2 a3d3 a4d4] "mulps %%xmm2, %%xmm1\n\t" // xmm1 = [b1c1 b2c2 b3c3 b4c4] "addps %%xmm1, %%xmm0\n\t" // xmm0 = (ad + bc) [i1 i2 i3 i4] // re-interleave "movaps %%xmm4, %%xmm5\n\t" // xmm5 = [r1 r2 r3 r4] "unpcklps %%xmm0, %%xmm4\n\t" // xmm4 = [r1 i1 r2 i2] "unpckhps %%xmm5, %%xmm0\n\t" // xmm0 = [r3 i3 r4 i4] // add into sumbuf "addps %%xmm4, %%xmm6\n\t" "addps %%xmm0, %%xmm7\n\t" "movaps %%xmm6, %[out1]\n\t" "movaps %%xmm7, %[out2]" // output/input operands : [out1] "+m" (cursumbuf_fd[v1]), [out2] "+m" (cursumbuf_fd[v2]) // input operands : [in1] "m" (input_fd[v1]), [in2] "m" (input_fd[v2]), [ir1] "m" (irpart_fd[v1]), [ir2] "m" (irpart_fd[v2]) // clobbered registers : "%xmm0", "%xmm1", "%xmm2", "%xmm3", "%xmm4", "%xmm5", "%xmm6", "%xmm7" ); } pd-bsaylor_0.1/mtosr-help.pd0000644000076500007650000000030711466373036014616 0ustar hanshans#N canvas 320 213 450 300 10; #X obj 177 104 mtosr; #X text 95 204 creation argument: samplerate at middle C.; #X text 46 145 takes midi note value and converts to a samplerate for sample playback.; pd-bsaylor_0.1/examples/0000755000076500007650000000000011466373565014024 5ustar hanshanspd-bsaylor_0.1/examples/noiseburst.wav0000644000076500007650000025425411466373036016745 0ustar hanshansRIFFXWAVEfmt DXdataX&=pyS8=u|c{1PG i\z\tAZ <#~iglRF7ss71bdJ H -Ks>P~AK00N:;I"yU{Lf3r 0_@=1F:lX;ioL mI7-{>)T]KV+Oh2VzT# #8:DAsRW~V`|:,hUQR&<;#HX[}Q\+*W BV8i7lA-#$ b RF @!> 4e XYW[V7m3J +>4)Y* GN# !_[J:+5$MmN=Q<Y1f *j @ ' PVO tr^f|*~ ;Zao  @ ,N+ozK,  b  n 4N ] o_IEHu )2 i f UY US& 7 fr X Y% 391 kP 5/ # d> s]*z  R0 ;JF<n czp _ 5LB  L HNr g 0To! g0G sS X1)) vD"E 0 e [a 0V$0J5 S u/% 2o3  Cmg LC O 0$~T%. Rh > @o  S j v  yu!H C7l WZ )8IC  (zo _d n  @ #K -F%_{ 0,t _<RQ;-O [LFa!puVu e k_e  0n F#1r Z"{wh-[U.{[- 9#%%[C} C i  I \  6aO5 k[Tf lkI? !i; No Wuc#bSt .  G  D  @g?r r( M ~H.G  P$S"@ #z h   30,  vir 1 (,^ 1_C "< 3d(+ 9l U#,[ / . ^  ? c*l N 8 bR q6- Po  )GG Jf }:1R}F4M b@A|=,(` 1v}^D `m0X<.aOG j 7)qL?N)Y;xK2 AC 1r 9CO q">l\Z&1   ) ]E F KXX'B : A e N i c Y V= RgV \ AqYlqs6t}PN ;  E#$  W-= S&R  2B1  c ^H  YX V \t+> Z~ \.L; $f,ET ] -SaW N ff mb3.h \{ ylhEC7MR[:vh+ 7;E \s f+:XZ^VD q &M ;V4'q Vf_  o  % ):4D|wuWej x]:) Rt m( UF( lH ` ie ID 5l| w +gv i{0  -wR`[uV LE  6%/ s 1= /L@d z-$I rI PO]T( .cJ }^~RtGsD^q xwooA  =j n xHd ~X X E| l T du3MaI3D/i^2 kvxQD ^ l8,+ 2 0_ 8 -NNnQF Q xL V } /h| z f l}H ]@|<W~K  4B.5,?v3 B 7 2^> | L!4  V   o - & b  G  x R(` N\ z  z*2x ) U)  -9K   5 _2u: VzX 8d f i " i_. (" `  B` a-# zl A \d: " M{C?  P % S =$ ; `    r^  f e?o{  4kZ 4 6@ N  ^N d )o ;NY + /!Q SWM ak  ]1i | F$ U\ )nx mN! [ Z 8 2 XR $ = hea \? j  x3H'B) e yF6F vK} J0FD;#' * 3K! :}Ex` * } tnFI mQ @ h   "v@,.AU`i zC :  gD`F } *1k) ',!J  ^s 0 L p; _Hwx_39#~ $N 8Ux - L s"! j}RY$g- u 5Q&UY ;UX" / UehH;w*V 0dB  lD  3g i<s /+o? ?0p} KO\B5 K-H 4G  o * RjalrtJ^  z .tBml eP   Ot m}X pE:*R _<:*#QZ-&I v O Tes2. K st,  o =d 8#{ e f b=`'U Nz *GQ&]! lywl)*I4% Q n}\  ^  0[~@ gn N L Lg ?/u  *  Ta \ W8m i  V{q|_ `n d WPKLe"vkX["/9 ; QJFy a S, y A^l1 zSF_`  Yk / 3M%C 1> = 0ZAmhW<  g~ R%g[S xg? Hc+dzX{66QvJ\> 94 Vw<RJt/ + <3Q >Y]d)+q_ Vb/. ID"3 2o,w?. d}iwb`"X  g54b*dq~ {}t d5pT.. 7 {= S]\Sna KlvXPCM7'2 }`0\J&a:h|p B g2 Go1K>u o8,U9UK=&4)O{U)P}#%;K m0LV@i z Z$r>9?Yjq!q TBeM1VGh iOh5xuf7kNR*Hww u( \ W.R'-_" 4 Tqk@=N~2#T>, iwn*aR hL*OH!qnV]\R }tDj  Sx%;ge ^'VU(aVA t[uzNs 42j| |mS;63Z(~9W, XBr;F ZZ e+56S{Ql;0jd:%I\`Cc=k  u9D;V4KJ3wE/H=!rwK&QcJPl0YsK:P\Y<e y LK<=)]$%4Gtoz]wOycK0B<Q5Ka]!vX,3F\zd-=,JIN)p N[v +6{FO/RnS]KB8p;(G O{b!lR{V%GpA 22%ZD^Gdqr{~?8DPjX\6@:\ z$^JFhUM]lE/Uj.]RHb_V_w~-YO7 'R`2y,8vmE`Qm3*WbBcV-\ &Vh .-q|lYQ3GB` 1-rH} o@#= $end-v~fxQ/Ezn!Zd'.&C {MzrR!bBikUj41s^3pE-"v6:>1n~ = lFfq X&,JXO, 6+`2\_B@[UD0$tOm{ ]AKb8%c Q@g@o;*Nv)k#Uw&"Ty4OO~.kjS\~E_m@L"P`=0k;9q\v(k1 Uhb9?&Va)]"0DAK0 *x`'g^jFceI}z7 ET Js)DY$i_,0lyvMz-`.UP0Owv,62^&uWod!F?9&Sn["  CFM[E-58NhjN{*]lzX"Vih@<+ </n7}Rd9o#i^ KK%=|W%v 9J<o&P 6v|g7KNFg(hw'\$4*G5w{_0*9\}SF1=;5n`#yo==1q?%z#j;Qu,~ <kdDfh kFu!&Sis,a<O?}kd=(&%gKk& K*>1F vAN^wyPTeRm:OI9{B'G^0UB?r#RHoFcUZ~O5WCZ0IbUC!|^wl!7Ov{h%W.~*Z:{P ^rdLwYzJlZ%C  u5*_ m09$ar jF TJt\ O8i8xM sSk@Xr}2dHxP]b)YSJ/K<<e#gY+4jR:A) eEjd 6vDm<$T|!1mI9?Gzfk~Vm}qEr$YhhmoKq/Pm@%!?9aVI>)1qe:#%>2N e ONgtCkVG5Z2pb6'JcQ4!B]@" >CV~[JFX;vt$1s.VwK#lH1&:cRHdf"O8"hO.HZ}:Z Re19T;W wIFRZ@=2;6<=SLGD0Q%y,0a3\tOqk ~RQ%<MK _zeV- jQF;%0Y]ne7*T}SU>nFuR+!RV#i. N@<;7oD00<<1H\.wv-;$-S 0Ks1v'o%35I_5UTLo LhK|$oy<YSk_F4>hG Vr/!U -'A.+2)n3+T<U>a. ?v\ITRYRg   ]"^@feyaQVe&'9K4(^]Db"t, K<&bNu5N,`^1/j-glvh*#-S)90=Ob^QN{%gKBD4f[YZUiDF9N&Wb `l PL$H&5Em'~^Q7ODpUg{\2izs Z"PzjR<4D>}nB( lZw2'x,W*-J?7cHcPJl4V%oZ7TV5y,Ks)EX1!UCg 0HJTDF,>=:o;HuYVk<Y2}*= 6@Q_jopzn[[A0K| > 0 K [(Dj2uq(Irb&Y0;6P~fLd6.h_5+CRt;I^Ks>ops3SPsJ6b5s(b]Jy1HL +Zb` W`pF+^Hilq?a ~YJ Y&f7!EFA?9hy{7U&c$V;2:UzC)!S'{^n=w5_FAc1sHok?t-[-=]#(}cr;WlBAjYkk?Ua2p>k;U<ni!\%=AM LsmoCP_ye`]G]DsZyTH`^4PZw8km]xU +kY[>k@"b03b/RIU!n&-\/FsL:QM"2Oe !N\br-8AL< -FNl"2\N1W-U(2:GH ;i`.Tl #!%2!:[;b uFtx)}%c0JqH$7Bx?]8;f=X1mv<.\dhqB@oS c]6B|}c!A6`XKGP"J PTgwqR :y[$R})6aZ+^m $[Kj[z>~{ D4'1,2CZJ]wC2 w# `"P)ekh,v+pT).SA6_f8hp^mk*XM|~7a  hv1J"bgtrYA(gEF; &D7jZYHM7v^r"M(";H}crx/?GC{5ypw1`Q!^ITjE]Mt.$ +<iI1R?s@_+)QhF~Sl8FA4V@; Jpa-B7"x*< 8)MEq9v6n)0 g*H 4Udcrmp8='vC'BMj=7 +>m:g M,}[3+7|DnQyP#MN:qA0&i}(Qw*Z/=( E$A]n f^ -_'A0Df~ q$( X?4 j$qKxLBAKS7rp(=S<ZW^3%Vc_v:t%yhpT$J"xW{diaBLbR|BI^D"R#S; KMK4q,r^CC#,H .h'i1=:*Sa{@Cg5jV$,t$')0>4?DWAG7Dgj57$a $ ,eiNa9?# 2Raiq<U.e} _+jzEBaKB? "2R~PpE)syZH<z}0m"^wx$>0[#^bXr-uyiclKEQ8% H,tW|ltlyqq]:=y* b#7_L*kK gs60(O)[8;\#hI9]K;V6VN,NHiC+;2HCtU^#i=-H5hKw-,QqC)5rg4ek11nC;9u(pz}e87P6R17]-,MqVO^^ZO} h7N>28hp7?d SNpkpDccyO'gn=;kj@YPbi>_(0fA Df[ .2TTFrJy(01a4C$x4FNJ^`benH!B@mtTS(dIiW?di\29m#o6,6Nj28: " 1Fz{O0PF#nL4sA>hS/|91OXSc|~^ +r .$wbt&jUT{]|szzebD~>8_mMb"}-a|\B{L[D)RbUNLNt'/eGBK^FmQ\pf.ebiolovtq_J{lb{ODjk7Gq-dD7ibM,|y,ls!Kh =E2--'V(Q30 B~n6'rPK>p" |b3)Az.S-0@?YOS~lEs/U  \-{/9B| hQEx[Z1<.]7%.%!nk4Y`9=SZ cWBR~{H)Q a\83L)GZy.5Ui]#J U7QR(U BQvIto.n*.X4MMr#? ;YZrSCF><[0WQ bnVt)p*B<0.KK{d5K|SzKE\CM5 :>RL \$E]u.YUnQ9ByA+?rAB(ri("gt4O-C'"&32g>Ts C)Cb`,<Ful1em1s/;)w01q ;Kyb}`4ulqf1vpW6lbz ?OTexkV#X__5UP1/bp^>sM!W7OS/!j>"#0|4Rx?0)H.HJ/"7&=1fCcu2IuBu'r.|Xd cYa]{,)g=$FS a| ?9:-4 2R/x*6dnmuS8D)p3K\xEOFb9;@M`LGz]kT @M%Ks$y%SJHuk9=qYTgK6P-vz:`_R0's'4Ic}Lbm`4 n5izIX}9TYk@KD4[."q%mN`-O4 z9;g>^/{1QDK#5i nTheg:CT;R 34ZR+RqPze_)6ZfzEgU#)* _Z.nv*p,aDlPj)LrPu@ycOX^1c>w y#|\mJ$zzVR /T~}vGE-(-TRuu~/IlJN$3:5gz{r}4hb/:%yl9\ i4JaBMwcm` NVrbDY\QD6,P`+Xk^X;VW#m':^r;yR :L:xF a>Z"IIP_enhVX%+ ]RBAQlt: :,CsNh%J[>x!C'zE^pLpn4&n Z7z'z&/1%~ZP'))`rtt%M NYW U%TN0 KKE>#A-z,YuRMXd$,D-g[kSo 5*&7`omWp&!~0MTn6ibBdwh,ki::23jOu{} <c C`8 m2:~q35}CE)f\M=TY~%D!LpdvuqH-@gmB}`%=N1}N2,ZX!y$Lt#PKH'hv[^h(BrN*sXAf2>p{v`<L_LT7rRVU)dievLE^5G?`^UoJG>Z][NVe\xcz6V8|+ WO/q*<Icf~P Y.i5{og6UNZ[)(K7XL}ln /z?~mnF81+*o_Zi"bn]t6Zrwmm2OWUx. %s/hVCn+[o4RzGrQT&*`e\wu USzQ2[GY~i:Y}dgU; VSJjDVkk@3 & _.c:f + + naT@. O\Qn1nE[aa:aya}\vv?e-h"^y9`[3>[n:nh|B.t[U[ E{?pnh| JeBK~94ogYi# HW0WRwyCqu-!gvr=Ic7J\ 4fPgdd8]IhGi/N-{Rklgp)^ ot0A~oDIrqx%=J4g~kp,KK:KJ(ixW,<G ~i-Dy-isk`n2d_l{~%n!pAs7<c]|RX jxuS-ytnn-RBp/(969xfws{Q2:yN+rs"fQ=z?2!u8x@u^qs.ra'go(Z^EyL :-OhQ":v6 G|?{^2]!w}I.~XtG1i7E |RD`b'hu@fS0q rzwDO7giOGN FOGlcEam .SX/s5y$_ T>YSc|aB`f|}cAm]SJ'M=|)\fD|mbV* Hh+|Goz(xpY=Ras#h}Qd~# d-iZbd3p=D:^-Ve2O Q4 0++M$N7`j'3!5jWf3G]@KOw( 3K{^1`v4E FJGAb/ob,O<H>w0|3Cl5{!Jt{2EBb>_Z*4d3Y$3r'& Xl A^&qc!HQBK hQ64K>tJAI2(>H#X[ cg'Kb C17;L7c5`S)$W(_7<)R8=XsRm.=THekY>$Yhe&)i@ ,>!2 /)GdSTR)'pR0 (@HS!MXfNe$R oQ1So?,SdLn#cUUe3<`'3 l2)@3=G/f:ZMM+ ,6; gFS7<,)? $P=-\+"9WhGQ>[BUOX-7 .=;c[M)= 8/$&bIS\'a' `BBJ1NSN78>`8*_][4[K6=35R>\%+bY9FP\]OTYS^G7HI P]=^NUWCI_O-RL5ZD9W81Y.`aJ5aM$:QP$6/ V@Z(AI$7G'8 KAW %;:,FW"K-6BW TC L\;1KGC=),OL394FL!WWP0X=%<3ZFH#<M/+1R 5HX =J)HRJ@A'4<C1XVN&UMXD#VF(K,2)<>XUB 8B5U41(6J 6#EOQ%  M> ;=5,+F$4-OFEML?#1;$77;>(I.B563/FG:RP<$2/7BA<O.3P)>@3J 3:,9J;!$L<L$Q5"'DFDBK(BM*L0,; E.4?;7ED,%#%'B8'$AC 0"A7/+JEF 00L@-KNKBC4:N&36?- (AFK ;G"$/ 9IM;LL;*AI 0."-&&@87.E<8## &@C?-9&E6#;#$ ,""1 ,;.2IE$5 I. +E+' (7GB06,$5><+CD2C6".B.8&G$F'E"7 ' :12 *!*+D $ F)6 <?>4#1; '4B!%#-*+7')C6; 6%, 52!A$9".%") :,  <A 1  :2 428);4? ?:1?,*4':")<(%-34,.95.>4)9-1"")=9<(7&. .+!9.*%=" ,4 #$+ +=/<0 2+43(6; ,<46 **%13<'908(&) $08 0 *6"" .:8&$ ! '1 ,869#93/ .  *%%    2-7 4%,2 *7! ' 1,+4 '#.%$ (  11  2&+22 #&$,/4%.,&-!, 5 -'-' +-1%')%&! '/ !1)04&!!&,/ & "+%!"2!+(3  ///$'  !0# 2 )  02(%( .  "  '''&.) #"   %)&+ )* /+&/ -"#!")*--& , ) (#)" ")-  )#! !$+ !++ -+,&%"((% $* %+#%,$&*"" ((%$"! " # ) +) % ('+ $& &#(!&*"  ! '  #$&!( # %$$()& " ! #' %( %# " %' "&"%" $%&  % $!  %"#    "" !!#  !!   "  $     "  ! !"  !                                                                                                                                                                                                                                                                                                                                                                                              pd-bsaylor_0.1/bsaylor-meta.pd0000644000076500007650000000031611466373036015123 0ustar hanshans#N canvas 15 49 200 200 10; #N canvas 25 49 420 300 META 1; #X text 13 41 NAME bsaylor; #X text 10 25 AUTHOR Benjamin R. Saylor ; #X text 10 10 VERSION 0.1; #X restore 10 10 pd META; pd-bsaylor_0.1/pvoc~-help.pd0000644000076500007650000000452111466373036014621 0ustar hanshans#N canvas 143 0 760 635 10; #X declare -lib bsaylor; #X obj 265 611 dac~; #X obj 304 561 vsl 8 64 0 1 0 1 empty empty empty 0 -8 0 8 -260818 -1 -1 3200 1; #X obj 265 587 *~; #X obj 68 158 cnv 15 580 220 empty empty empty 20 12 0 14 -195568 -66577 0; #N canvas 0 0 450 300 graph1 0; #X array sample 62079 float 0; #X coords 0 1 62078 -1 560 100 1; #X restore 77 52 graph; #X msg 346 506 read -resize ../../sound/voice.wav sample ; #X obj 346 526 soundfiler; #X obj 346 547 s length; #X obj 346 485 loadbang; #X obj 77 172 hsl 560 15 0 1 0 0 empty empty time-position -2 -6 0 8 -233017 -1 -1 26900 1; #X obj 214 222 vsl 15 128 0.5 2 1 0 empty empty pitch-shift 0 -8 0 8 -261681 -1 -1 6350 1; #X msg 182 203 1; #X floatatom 214 356 5 0 0 0 - - -; #X obj 280 222 vsl 15 128 0 1 0 0 empty empty phase-locking 0 -8 0 8 -225280 -1 -1 0 1; #X floatatom 280 356 5 0 0 0 - - -; #X obj 74 532 line~; #X msg 74 510 \$1 200; #X obj 74 488 *; #X obj 90 423 r length; #X text 6 28 [pvoc~ ]; #X obj 226 551 lop~ 10; #X msg 433 486 read -resize \$1 sample; #X obj 433 466 openpanel; #X obj 548 337 bng 32 250 50 0 empty empty empty 0 -6 0 8 -260818 -1 -1; #X msg 280 457 locking \$1; #X msg 99 447 setarray sample; #X msg 380 292 transients 0 6227 35716 53368; #X msg 380 314 notransients; #X text 380 275 de-smear transients at these locations; #X text 546 319 load a sample; #X obj 226 531 sig~ 1; #X msg 125 261 0.5; #X msg 125 281 1; #X msg 125 301 2; #X msg 125 341 4; #X msg 125 510 0 \, 4.41e+06 \$1; #X obj 125 399 * 100000; #X msg 125 321 3; #X text 8 6 pvoc~ 0.2 Ben Saylor bensaylor@fastmail.fm; #X obj 99 571 pvoc~ sample 2048 4; #X connect 1 0 2 1; #X connect 2 0 0 0; #X connect 2 0 0 1; #X connect 5 0 6 0; #X connect 6 0 7 0; #X connect 8 0 5 0; #X connect 9 0 17 0; #X connect 10 0 12 0; #X connect 11 0 10 0; #X connect 12 0 30 0; #X connect 13 0 14 0; #X connect 14 0 24 0; #X connect 15 0 39 0; #X connect 16 0 15 0; #X connect 17 0 16 0; #X connect 18 0 17 1; #X connect 18 0 25 0; #X connect 20 0 39 1; #X connect 21 0 6 0; #X connect 22 0 21 0; #X connect 23 0 22 0; #X connect 24 0 39 0; #X connect 25 0 39 0; #X connect 26 0 39 0; #X connect 27 0 39 0; #X connect 30 0 20 0; #X connect 31 0 36 0; #X connect 32 0 36 0; #X connect 33 0 36 0; #X connect 34 0 36 0; #X connect 35 0 15 0; #X connect 36 0 35 0; #X connect 37 0 36 0; #X connect 39 0 2 0; pd-bsaylor_0.1/susloop~-help.pd0000644000076500007650000000570211466373036015360 0ustar hanshans#N canvas 236 83 735 643 10; #N canvas 0 0 450 300 graph1 0; #X array sample 86754 float 0; #X coords 0 1 86753 -1 200 64 1; #X restore 441 412 graph; #X obj 480 341 soundfiler; #X msg 480 315 read -resize \$1 sample; #X obj 480 289 openpanel; #X obj 480 267 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; #X obj 8 513 dac~; #X floatatom 69 489 5 0 0; #X obj 69 513 / 100; #X obj 8 450 tabread4~ sample; #X obj 8 481 *~; #X floatatom 127 272 5 0 0; #X obj 127 310 mtosr 44100; #X msg 17 271 type 0; #X msg 17 299 type 1; #X msg 176 272 44100; #X floatatom 322 380 5 0 0; #X floatatom 179 380 6 0 0; #X floatatom 245 380 6 0 0; #X obj 88 271 bng 15 250 50 0 empty empty empty 20 8 0 8 -262144 -1 -1; #X text 514 265 <- load a sample; #X text 421 230 Ben Saylor - bsaylor@macalester.edu; #X msg 124 489 70; #X obj 156 489 loadbang; #X text 54 45 optional creation args:; #X text 239 45 [loopstart loopend [looptype [startpos]]]; #X text 172 336 loopstart; #X text 242 337 loopend; #X text 319 338 startpos; #X text 38 154 is 0 for a forward loop (default) and 1 for a pingpong loop.; #X text 40 193 Playback speed is in samples/sec - send a float or signal to the left inlet.; #X text 10 7 susloop~ - another phase generator for sample looping ; #X obj 127 414 susloop~ 4000 12000; #X text 37 94 When the left inlet gets a bang \, the phase output will start at (defaults to 0) \, continue until it reaches \, and then start looping between and .; #X floatatom 480 366 5 0 0; #X obj 442 480 hsl 200 15 0 1 0 0 empty empty loop_start 10 8 0 8 -195568 -33289 -33289 13700 0; #X obj 442 499 hsl 200 15 0 1 0 0 empty empty loop_end 10 8 0 8 -233017 -1 -1 16900 0; #X obj 250 565 *; #X obj 293 565 *; #X obj 293 589 int; #X obj 250 589 int; #X obj 531 366 s filesize; #X obj 266 501 r filesize; #X obj 229 616 s lstart; #X obj 293 615 s lend; #X obj 245 356 r lend; #X obj 179 358 r lstart; #X obj 442 516 hsl 200 15 0 1 0 0 empty empty start 10 8 0 8 -262144 -1 -1 0 0; #X obj 346 567 *; #X obj 346 591 int; #X obj 346 616 s start; #X obj 322 356 r start; #X connect 1 0 33 0; #X connect 1 0 40 0; #X connect 2 0 1 0; #X connect 3 0 2 0; #X connect 4 0 3 0; #X connect 6 0 7 0; #X connect 7 0 9 1; #X connect 8 0 9 0; #X connect 9 0 5 0; #X connect 9 0 5 1; #X connect 10 0 11 0; #X connect 11 0 31 0; #X connect 12 0 31 0; #X connect 13 0 31 0; #X connect 14 0 31 0; #X connect 15 0 31 3; #X connect 16 0 31 1; #X connect 17 0 31 2; #X connect 18 0 31 0; #X connect 21 0 7 0; #X connect 22 0 21 0; #X connect 31 0 8 0; #X connect 34 0 36 0; #X connect 35 0 37 0; #X connect 36 0 39 0; #X connect 37 0 38 0; #X connect 38 0 43 0; #X connect 39 0 42 0; #X connect 41 0 36 1; #X connect 41 0 37 1; #X connect 41 0 47 1; #X connect 44 0 17 0; #X connect 45 0 16 0; #X connect 46 0 47 0; #X connect 47 0 48 0; #X connect 48 0 49 0; #X connect 50 0 15 0; pd-bsaylor_0.1/svf~-help.pd0000644000076500007650000000715211466373036014453 0ustar hanshans#N canvas 10 20 762 475 10; #X obj 170 445 dac~; #X obj 7 369 phasor~; #X floatatom 7 347 5 0 0; #X obj 145 329 sig~; #X obj 190 329 sig~; #X obj 97 257 mtof; #X obj 97 120 vsl 15 128 16 135 0 0 empty empty empty 0 -8 0 8 -262144 -1 -1 0 1; #X obj 145 120 vsl 15 128 0 1 0 0 empty empty empty 0 -8 0 8 -262144 -1 -1 0 1; #X obj 190 119 vsl 15 128 0 1 0 0 empty empty empty 0 -8 0 8 -262144 -1 -1 0 1; #X obj 97 329 line~; #X msg 97 306 \$1 100; #X floatatom 200 281 5 0 0; #X floatatom 155 281 5 0 0; #X floatatom 97 281 7 0 0; #X msg 361 123 low; #X msg 361 147 high; #X msg 361 171 band; #X msg 361 195 notch; #X msg 361 219 peak; #X obj 7 303 loadbang; #N canvas 4 20 608 388 hanning-table 0; #X obj 92 206 phasor~; #X obj 92 234 cos~; #X obj 23 328 tabwrite~ hanning; #X obj 30 252 -~; #X obj 28 218 sig~ 1; #X msg 37 180 0; #X text 141 13 CALCULATE HANNING; #X text 141 27 WINDOW TABLE; #N canvas 0 0 450 300 graph1 0; #X array hanning 512 float 0; #X coords 0 1 511 0 256 128 1; #X restore 305 93 graph; #X obj 93 171 sig~; #X text 24 354 sample rate / window size; #X msg 23 144 bang; #X obj 66 269 sig~ 0.5; #X obj 49 300 *~; #X obj 67 96 samplerate~; #X obj 25 53 t b f; #X obj 25 8 loadbang; #X msg 25 31 512; #X obj 94 131 / 512; #X connect 0 0 1 0; #X connect 1 0 3 1; #X connect 3 0 13 0; #X connect 4 0 3 0; #X connect 5 0 0 1; #X connect 9 0 0 0; #X connect 11 0 2 0; #X connect 11 0 5 0; #X connect 12 0 13 1; #X connect 13 0 2 0; #X connect 14 0 18 0; #X connect 15 0 14 0; #X connect 15 0 11 0; #X connect 15 1 18 1; #X connect 16 0 17 0; #X connect 17 0 15 0; #X connect 18 0 9 0; #X restore 13 430 pd hanning-table; #N canvas 10 112 328 354 fft-analysis 0; #X obj 69 15 inlet~; #X obj 43 74 rfft~; #X obj 37 123 *~; #X obj 81 124 *~; #X obj 49 167 +~; #X obj 49 196 sqrt~; #X obj 27 297 tabsend~ response; #X obj 171 209 block~ 512 2; #X obj 182 61 tabreceive~ hanning; #X obj 164 99 *~; #X obj 69 36 /~ 8; #X obj 51 249 clip~ 0 1; #X connect 0 0 10 0; #X connect 1 0 2 0; #X connect 1 0 2 1; #X connect 1 1 3 0; #X connect 1 1 3 1; #X connect 2 0 4 0; #X connect 3 0 4 1; #X connect 4 0 5 0; #X connect 5 0 11 0; #X connect 8 0 9 1; #X connect 9 0 1 0; #X connect 10 0 9 0; #X connect 11 0 6 0; #X restore 216 421 pd fft-analysis; #N canvas 0 0 450 300 graph1 0; #X array response 256 float 0; #X coords 0 1 255 0 256 140 1; #X restore 478 10 graph; #X msg 7 325 110; #X text 5 1 svf~ - state-variable filter; #X text 146 99 q; #X text 171 100 resonance; #X text 67 100 frequency; #X text 331 100 filter type; #X obj 200 387 svf~ low; #X text 8 28 A port of Steve Harris' LADSPA plugin; #X text 6 45 (http://plugin.org.uk); #X text 325 313 Notes:; #X text 338 334 'q' controls the filter resonance. The resonance input is for 'extra' resonance.. :); #X text 400 171 <- keep q below 0.1; #X text 339 370 The filters don't use the same scale for frequency. Bandpass frequency seems to be in Hz. If the frequency is set too high \, LOUD aliasing is produced.; #X text 339 418 The bandpass filter is very sensitive to q - normal range is 0 to 0.1.; #X connect 1 0 29 0; #X connect 2 0 1 0; #X connect 3 0 29 2; #X connect 4 0 29 3; #X connect 5 0 13 0; #X connect 6 0 5 0; #X connect 7 0 3 0; #X connect 7 0 12 0; #X connect 8 0 4 0; #X connect 8 0 11 0; #X connect 9 0 29 1; #X connect 10 0 9 0; #X connect 13 0 10 0; #X connect 14 0 29 0; #X connect 15 0 29 0; #X connect 16 0 29 0; #X connect 17 0 29 0; #X connect 18 0 29 0; #X connect 19 0 23 0; #X connect 23 0 2 0; #X connect 29 0 0 0; #X connect 29 0 0 1; #X connect 29 0 21 0; pd-bsaylor_0.1/README.txt0000644000076500007650000000255011466373036013677 0ustar hanshans aenv~ is a asymptotic ADSR envelope generator; The output value approaches the target values as asymptotes. partconv~ is an external that implements partitioned fast convolution, suitable for convolving input signals with long impulse responses for reverbs, etc. This release offers much improved performance, as well as independence of the partition size and your patch's blocksize. It includes Altivec code from Chris Clepper. There's also some SSE 1 code that produces almost correct results but doesn't seem to improve performance. If you are familiar with SSE and want to have a go at writing an SSE version, please do! partconv~ requires FFTW3 (http://fftw.org) pvoc~ is a phase vocoder based on Pd's 09.pvoc.pd example patch. Advantages over the abstraction include (reportedly) faster execution, instantaneous response to input, and adjustable phase locking. It requires FFTW3. bensaylor's Home susloop~: sample player with various loop methods (ping-pong, ... ) think tracker. svf~ This is a signal-controlled port of Steve Harris' state variable filter LADSPA plugin. svf~: a signal-controlled port of Steve Harris' state variable filter LADSPA plugin (http://plugin.org.uk). zhzhx~: Turns the input signal into a staticky, distorted mess. Comes with tone control. Benjamin R. Saylor pd-bsaylor_0.1/pvoc~.c0000644000076500007650000003027411466373036013516 0ustar hanshans/* Copyright 2003 Benjamin R. Saylor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "m_pd.h" // FIXME: // set array when dsp is turned on // get rid of shiftbuf, just save values that will be needed next before overwriting them // cubic interp // use float fftw? // performance testing // what if there are 2 transients less than fftsize apart? second one might get smeared. // compare sound with phaselockedvoc.pd // detect transients // peaks + noise // other phase locking methods // use floats? // use in-place? // if don't have an array, call setarray(x->arrayname) // window size and fft size independent (what is gained by zero-padding?) // error if parent blocksize is larger than hopsize // slowly return window to true position after centering around a transient? // use fewer fft arrays? // DONE: // use FFTW_MEASURE static t_class *pvoc_class; typedef struct _pvoc { t_object x_obj; t_symbol *arrayname; t_garray *arrayobj; t_float *array; int arraysize; double *window; int fftsize; int overlap; int hopsize; // = fftsize / overlap int trans[256]; // sample indices of transients int ntrans; // number of transients int wastrans; // there was a transient in the left half of the window during the previous frame double phaselocking; fftw_plan fftplan; fftw_plan fft2plan; fftw_plan ifftplan; double *fftin; double *fft2in; double *ifftout; fftw_complex *fftout; fftw_complex *fft2out; fftw_complex *ifftin; fftw_complex *shiftbuf; double *outbuf; int outbufpos; } t_pvoc; // if there is a transient between samples a and b, return its position, else return -1 static inline int transient_between(t_pvoc *x, int a, int b) { // linear search for now: FIXME int i; for (i = 0; i < x->ntrans; i++) if (a <= x->trans[i] && b >= x->trans[i]) return x->trans[i]; return -1; } #if 1 static inline double interpolate(t_pvoc *x, double t) { // linear interpolation for now: FIXME if (t < 0 || t > (x->arraysize - 1)) return 0.0; else { int x_1 = t; double y_1 = x->array[x_1]; double y_2 = x->array[x_1 + 1]; return (y_2 - y_1) * (t - x_1) + y_1; } } #else static inline double interpolate(t_pvoc *x, double t) { // FIXME check bounds (can't think now) int truncphase = (int) x->phase; double fr = x->phase - ((double) truncphase); double inm1 = x->ifftout[truncphase - 1]; double in = x->ifftout[truncphase + 0]; double inp1 = x->ifftout[truncphase + 1]; double inp2 = x->ifftout[truncphase + 2]; // taken from swh-plugins-0.4.0/ladspa-util.h cube_interp, made to use doubles instead since doubles are what i'm using for some reason return in + 0.5 * fr * (inp1 - inm1 + fr * (4.0 * inp1 + 2.0 * inm1 - 5.0 * in - inp2 + fr * (3.0 * (in - inp1) - inm1 + inp2))); } #endif static t_int *pvoc_perform(t_int *w) { t_pvoc *x = (t_pvoc *)(w[1]); t_float *in1 = (t_float *)(w[2]); t_float *in2 = (t_float *)(w[3]); t_float *out = (t_float *)(w[4]); int n = (int)(w[5]); double t; double pitchshift; int transientpos; int desmear; double framestart; double frameend; int i; // 0 to n -type iterator int j; // start to end -type iterator int k; // bin iterator double xlook; // iterator for interpolated table lookup // if we are at the start of a new frame... if (x->outbufpos % x->hopsize == 0) { // don't desmear this frame by default desmear = 0; // sample the input signals (FIXME just sample these in the beginning..) t = in1[0]; // time position pitchshift = in2[0]; // pitch shift // set the frame boundaries with the desired time pos in the middle framestart = t - (pitchshift * x->fftsize / 2); frameend = framestart + pitchshift * x->fftsize; // prepare to de-smear transients transientpos = transient_between(x, (int) framestart, (int) frameend); if (transientpos != -1) { // there is a transient in this frame #if 0 if (transientpos > t) { // there is a transient in the right half of the window: // --> move the window left until the transient is outside it frameend = transientpos; framestart = frameend - x->fftsize; x->wastrans = 0; } else if ( ! x->wastrans) { // there is a transient in the left half of the window, // and there was no transient there during the previous frame: // --> center the window around the transient and remember to desmear this frame framestart = transientpos - (x->fftsize / 2); frameend = framestart + x->fftsize; desmear = 1; x->wastrans = 1; } else x->wastrans = 1; #else // this simpler method turns out to sound better (timing sounds more accurate, no "frozen" sound preceding transients) if ( ! x->wastrans) { // there is a transient in the window, // and there wasn't during the previous frame: // --> center the window around the transient and remember to desmear this frame framestart = transientpos - (pitchshift * x->fftsize / 2); desmear = 1; } x->wastrans = 1; #endif } else x->wastrans = 0; // interpolate-read the array from framestart to frameend into fftin, windowing it for (i = 0, xlook = framestart; i < x->fftsize; xlook += pitchshift, i++) { x->fftin[i] = interpolate(x, xlook) * x->window[i]; } // hop forward and read the second frame into fft2in // FIXME merge the two loops? framestart += pitchshift * x->hopsize; for (i = 0, xlook = framestart; i < x->fftsize; xlook += pitchshift, i++) { x->fft2in[i] = interpolate(x, xlook) * x->window[i]; } // do the ffts fftw_execute(x->fftplan); fftw_execute(x->fft2plan); if ( ! desmear) { // Miller Puckette's phase modification math (translation from 09.pvoc.pd and 10.phaselockedvoc.pd) double a, b, r, c, d; // propagate phase for (k = 0; k < (x->fftsize / 2 + 1); k++) { a = x->ifftin[k][0] * x->fftout[k][0] + x->ifftin[k][1] * x->fftout[k][1] + 0.00000000000000000001; b = x->ifftin[k][1] * x->fftout[k][0] - x->ifftin[k][0] * x->fftout[k][1]; r = 1 / sqrt(a * a + b * b); c = a * r; d = b * r; x->shiftbuf[k][0] = c * x->fft2out[k][0] - d * x->fft2out[k][1]; x->shiftbuf[k][1] = c * x->fft2out[k][1] + d * x->fft2out[k][0]; } // don't phase-lock the first bin x->ifftin[0][0] = x->shiftbuf[0][0]; x->ifftin[0][1] = x->shiftbuf[0][1]; // phase-lock for (k = 1; k < (x->fftsize / 2); k++) { x->ifftin[k][0] = x->shiftbuf[k][0] - x->phaselocking * (x->shiftbuf[k - 1][0] + x->shiftbuf[k + 1][0]); x->ifftin[k][1] = x->shiftbuf[k][1] - x->phaselocking * (x->shiftbuf[k - 1][1] + x->shiftbuf[k + 1][1]); } // don't phase-lock the last bin x->ifftin[x->fftsize / 2][0] = x->shiftbuf[x->fftsize / 2][0]; x->ifftin[x->fftsize / 2][1] = x->shiftbuf[x->fftsize / 2][1]; } else { // this frame is to be de-smeared, which means don't modify the phases, just preserve the original phases for (k = 0; k < (x->fftsize / 2 + 1); k++) { x->ifftin[k][0] = x->fftout[k][0]; x->ifftin[k][1] = x->fftout[k][1]; } } // do the ifft fftw_execute(x->ifftplan); // add into output buffer, windowing and normalizing first (divide by blocksize) for (i = 0, j = x->outbufpos; i < x->fftsize; i++, j++) { x->outbuf[j % x->fftsize] += x->ifftout[i] / x->fftsize * x->window[i]; } } // output one block of the output buffer for (i = 0, j = x->outbufpos; i < n; i++, j++) { out[i] = x->outbuf[j % x->fftsize]; x->outbuf[j % x->fftsize] = 0; // zero the part of the buffer that was just output } // move the output buffer pointer forward by one block x->outbufpos = (x->outbufpos + n) % x->fftsize; return (w+6); } static void pvoc_dsp(t_pvoc *x, t_signal **sp) { dsp_add(pvoc_perform, 5, x, sp[0]->s_vec, sp[1]->s_vec, sp[2]->s_vec, sp[0]->s_n); } // adapted from jsarlo's windowing library // Hanning static void makewindow(double *w, int n) { int i; double xshift = n / 2.0; double x; for (i = 0; i < n; i++) { x = (i - xshift) / xshift; w[i] = 0.5 * (1 + cos(M_PI * x)); } } static void setarray(t_pvoc *x, t_symbol *s) { x->arrayname = s; if ( ! (x->arrayobj = (t_garray *)pd_findbyclass(x->arrayname, garray_class))) { if (*x->arrayname->s_name) pd_error(x, "pvoc~: %s: no such array", x->arrayname->s_name); x->array = NULL; x->arraysize = 0; } else if ( ! garray_getfloatarray(x->arrayobj, &x->arraysize, &x->array)) { error("%s: bad template", x->arrayname->s_name); x->array = NULL; x->arraysize = 0; } else { garray_usedindsp(x->arrayobj); } } static void locking(t_pvoc *x, t_floatarg f) { x->phaselocking = f; } // takes a list of sample positions of transients to be de-smeared static void transients(t_pvoc *x, t_symbol *s, int argc, t_atom *argv) { int i; x->ntrans = argc; for (i = 0; i < x->ntrans; i++) x->trans[i] = atom_getfloatarg(i, argc, argv); } // for clarity (same as "transients" with no args) static void notransients(t_pvoc *x) { x->ntrans = 0; } static void *pvoc_new(t_symbol *s, int argc, t_atom *argv) { t_pvoc *x = (t_pvoc *)pd_new(pvoc_class); int i; inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); // pitch-shift inlet outlet_new(&x->x_obj, gensym("signal")); if (argc != 3) { post("argc = %d", argc); error("pvoc~: usage: [pvoc~ ]"); return NULL; } x->fftsize = atom_getfloatarg(1, argc, argv); x->overlap = atom_getfloatarg(2, argc, argv); x->hopsize = x->fftsize / x->overlap; x->ntrans = 0; x->wastrans = 0; x->phaselocking = 0; // get the source array setarray(x, atom_getsymbol(argv)); // set up output ring buffer x->outbuf = getbytes(sizeof(double) * x->fftsize); x->outbufpos = 0; for (i = 0; i < x->fftsize; i++) x->outbuf[i] = 0; // make table for window function x->window = getbytes(sizeof(double) * x->fftsize); makewindow(x->window, x->fftsize); // set up fftw stuff x->fftin = fftw_malloc(sizeof(double) * x->fftsize); x->fft2in = fftw_malloc(sizeof(double) * x->fftsize); x->ifftout = fftw_malloc(sizeof(double) * x->fftsize); x->fftout = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); x->fft2out = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); x->ifftin = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); x->shiftbuf = fftw_malloc(sizeof(fftw_complex) * (x->fftsize / 2 + 1)); for (i = 0; i < (x->fftsize / 2 + 1); i++) { x->ifftin[i][0] = 0; // need to start the phases from zero x->ifftin[i][1] = 0; } x->fftplan = fftw_plan_dft_r2c_1d(x->fftsize, x->fftin, x->fftout, FFTW_MEASURE); x->fft2plan = fftw_plan_dft_r2c_1d(x->fftsize, x->fft2in, x->fft2out, FFTW_MEASURE); x->ifftplan = fftw_plan_dft_c2r_1d(x->fftsize, x->ifftin, x->ifftout, FFTW_MEASURE | FFTW_PRESERVE_INPUT); return (x); } static void pvoc_free(t_pvoc *x) { freebytes(x->outbuf, sizeof(double) * x->fftsize); freebytes(x->window, sizeof(double) * x->fftsize); fftw_free(x->fftin); fftw_free(x->fft2in); fftw_free(x->ifftout); fftw_free(x->fftout); fftw_free(x->fft2out); fftw_free(x->ifftin); fftw_free(x->shiftbuf); fftw_destroy_plan(x->fftplan); fftw_destroy_plan(x->fft2plan); fftw_destroy_plan(x->ifftplan); } void pvoc_tilde_setup(void) { pvoc_class = class_new(gensym("pvoc~"), (t_newmethod)pvoc_new, (t_method)pvoc_free, sizeof(t_pvoc), 0, A_GIMME, 0); class_addmethod(pvoc_class, nullfn, gensym("signal"), 0); class_addmethod(pvoc_class, (t_method) pvoc_dsp, gensym("dsp"), 0); class_addmethod(pvoc_class, (t_method) setarray, gensym("setarray"), A_DEFSYMBOL, 0); class_addmethod(pvoc_class, (t_method) locking, gensym("locking"), A_DEFFLOAT, 0); class_addmethod(pvoc_class, (t_method) transients, gensym("transients"), A_GIMME, 0); class_addmethod(pvoc_class, (t_method) notransients, gensym("notransients"), 0); } pd-bsaylor_0.1/zhzxh~-help.pd0000644000076500007650000000205311466373036015023 0ustar hanshans#N canvas 12 60 418 347 10; #X floatatom 127 195 5 0 0; #X obj 76 307 dac~; #X obj 78 277 *~; #X obj 13 123 readsf~; #X msg 36 94 1; #X floatatom 99 46 5 0 0; #X obj 130 183 hsl 128 8 0 2500 0 1 empty empty tone -2 -6 0 8 -262144 -1 -1 8200 1; #X obj 78 220 zhzxh~; #X msg 13 56 open \$1; #X obj 136 244 vsl 8 64 0 1 0 1 empty empty empty 0 -8 0 8 -262144 -1 -1 4200 1; #X text 163 25 http://www.macalester.edu/~bsaylor; #X text 160 9 Ben Saylor ; #X obj 13 31 openpanel; #X obj 13 8 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 ; #X obj 105 120 *~; #X obj 155 94 tgl 15 1 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 ; #X obj 99 67 mtof; #X obj 99 93 osc~ 50; #X connect 0 0 7 1; #X connect 2 0 1 0; #X connect 2 0 1 1; #X connect 3 0 7 0; #X connect 4 0 3 0; #X connect 5 0 16 0; #X connect 6 0 0 0; #X connect 7 0 2 0; #X connect 8 0 3 0; #X connect 9 0 2 1; #X connect 12 0 8 0; #X connect 13 0 12 0; #X connect 14 0 7 0; #X connect 15 0 14 1; #X connect 16 0 17 0; #X connect 17 0 14 0; pd-bsaylor_0.1/LICENSE.txt0000644000076500007650000004313111466373036014024 0ustar hanshans GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. pd-bsaylor_0.1/partconv~.dsp0000644000076500007650000001042111466373036014737 0ustar hanshans# Microsoft Developer Studio Project File - Name="partconv" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** NICHT BEARBEITEN ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=partconv - Win32 Debug !MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE !MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl !MESSAGE !MESSAGE NMAKE /f "partconv.mak". !MESSAGE !MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben !MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: !MESSAGE !MESSAGE NMAKE /f "partconv.mak" CFG="partconv - Win32 Debug" !MESSAGE !MESSAGE Fr die Konfiguration stehen zur Auswahl: !MESSAGE !MESSAGE "partconv - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE "partconv - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "partconv - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc07 /d "NDEBUG" # ADD RSC /l 0xc07 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 !ELSEIF "$(CFG)" == "partconv - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /GZ /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PARTCONV_EXPORTS" /YX /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0xc07 /d "_DEBUG" # ADD RSC /l 0xc07 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pd.lib fftw3.lib /nologo /dll /debug /machine:I386 /out:"C:\Programme\pd_0.37\extra\partconv.dll" /pdbtype:sept !ENDIF # Begin Target # Name "partconv - Win32 Release" # Name "partconv - Win32 Debug" # Begin Group "Quellcodedateien" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\partconv.c # End Source File # End Group # Begin Group "Header-Dateien" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\fftw3.h # End Source File # Begin Source File SOURCE=.\m_pd.h # End Source File # End Group # Begin Group "Ressourcendateien" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project pd-bsaylor_0.1/Makefile0000644000076500007650000002544511466373036013651 0ustar hanshans## Pd library template version 1.0.4 # For instructions on how to use this template, see: # http://puredata.info/docs/developer/MakefileTemplate LIBRARY_NAME = bsaylor # add your .c source files, one object per file, to the SOURCES # variable, help files will be included automatically SOURCES = aenv~.c partconv~.c pvoc~.c susloop~.c svf~.c zhzxh~.c # list all pd objects (i.e. myobject.pd) files here, and their helpfiles will # be included automatically PDOBJECTS = mtosr.pd # example patches and related files, in the 'examples' subfolder EXAMPLES = noiseburst.wav # manuals and related files, in the 'manual' subfolder MANUAL = # if you want to include any other files in the source and binary tarballs, # list them here. This can be anything from header files, test patches, # documentation, etc. README.txt and LICENSE.txt are required and therefore # automatically included EXTRA_DIST = partconv~.dsp partconv~.dsw partconv~.vcproj sse-conv.inc.c altivec-perform.inc.c # NOTE: added custom targets for partconv~ and pvoc~ #------------------------------------------------------------------------------# # # things you might need to edit if you are using other C libraries # #------------------------------------------------------------------------------# CFLAGS = -DPD -I"$(PD_INCLUDE)" -Wall -W -g LDFLAGS = LIBS = -lm #------------------------------------------------------------------------------# # # you shouldn't need to edit anything below here, if we did it right :) # #------------------------------------------------------------------------------# # get library version from meta file LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) CFLAGS += -DVERSION='"$(LIBRARY_VERSION)"' PD_INCLUDE = $(PD_PATH)/include # where to install the library, overridden below depending on platform prefix = /usr/local libdir = $(prefix)/lib pkglibdir = $(libdir)/pd-externals objectsdir = $(pkglibdir) INSTALL = install INSTALL_PROGRAM = $(INSTALL) -p -m 644 INSTALL_DATA = $(INSTALL) -p -m 644 INSTALL_DIR = $(INSTALL) -p -m 755 -d ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION) UNAME := $(shell uname -s) ifeq ($(UNAME),Darwin) CPU := $(shell uname -p) ifeq ($(CPU),arm) # iPhone/iPod Touch SOURCES += $(SOURCES_iphoneos) EXTENSION = pd_darwin OS = iphoneos PD_PATH = /Applications/Pd-extended.app/Contents/Resources IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin CC=$(IPHONE_BASE)/gcc CPP=$(IPHONE_BASE)/cpp CXX=$(IPHONE_BASE)/g++ ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) LIBS += -lc STRIP = strip -x DISTBINDIR=$(DISTDIR)-$(OS) else # Mac OS X SOURCES += $(SOURCES_macosx) EXTENSION = pd_darwin OS = macosx PD_PATH = /Applications/Pd-extended.app/Contents/Resources OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast # build universal 32-bit on 10.4 and 32/64 on newer ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4 else FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 SOURCES += $(SOURCES_iphoneos) endif CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib # if the 'pd' binary exists, check the linking against it to aid with stripping LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd) LIBS += -lc STRIP = strip -x DISTBINDIR=$(DISTDIR)-$(OS) # install into ~/Library/Pd on Mac OS X since /usr/local isn't used much pkglibdir=$(HOME)/Library/Pd endif endif ifeq ($(UNAME),Linux) CPU := $(shell uname -m) SOURCES += $(SOURCES_linux) EXTENSION = pd_linux OS = linux PD_PATH = /usr OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += -fPIC LDFLAGS += -Wl,--export-dynamic -shared -fPIC LIBS += -lc STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) endif ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) CPU := $(shell uname -m) SOURCES += $(SOURCES_cygwin) EXTENSION = dll OS = cygwin PD_PATH = $(cygpath $(PROGRAMFILES))/pd OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer CFLAGS += LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" LIBS += -lc -lpd STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS) endif ifeq (MINGW,$(findstring MINGW,$(UNAME))) CPU := $(shell uname -m) SOURCES += $(SOURCES_windows) EXTENSION = dll OS = windows PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd) OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer CFLAGS += -mms-bitfields LDFLAGS += -s -shared -Wl,--enable-auto-import LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 STRIP = strip --strip-unneeded -R .note -R .comment DISTBINDIR=$(DISTDIR)-$(OS) endif # in case somebody manually set the HELPPATCHES above HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.pd=-help.pd) CFLAGS += $(OPT_CFLAGS) .PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME) all: $(SOURCES:.c=.$(EXTENSION)) %.o: %.c $(CC) $(CFLAGS) -o "$*.o" -c "$*.c" %.$(EXTENSION): %.o $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS) chmod a-x "$*.$(EXTENSION)" partconv~.$(EXTENSION): partconv~.o $(CC) $(LDFLAGS) -o "partconv~.$(EXTENSION)" "partconv~.o" $(LIBS) -lfftw3f chmod a-x "partconv~.$(EXTENSION)" pvoc~.$(EXTENSION): pvoc~.o $(CC) $(LDFLAGS) -o "pvoc~.$(EXTENSION)" "pvoc~.o" $(LIBS) -lfftw3 chmod a-x "pvoc~.$(EXTENSION)" # this links everything into a single binary file $(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS) chmod a-x $(LIBRARY_NAME).$(EXTENSION) install: libdir_install # The meta and help files are explicitly installed to make sure they are # actually there. Those files are not optional, then need to be there. libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES))" || (\ $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) test -z "$(strip $(PDOBJECTS))" || \ $(INSTALL_DATA) $(PDOBJECTS) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) # install library linked as single binary single_install: $(LIBRARY_NAME) install-doc install-exec $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) install-doc: $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \ $(INSTALL_DATA) $(HELPPATCHES) \ $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt install-examples: test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ for file in $(EXAMPLES); do \ $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ done install-manual: test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ for file in $(MANUAL); do \ $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ done clean: -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) -rm -f -- $(SOURCES:.c=.$(EXTENSION)) -rm -f -- $(LIBRARY_NAME).o -rm -f -- $(LIBRARY_NAME).$(EXTENSION) distclean: clean -rm -f -- $(DISTBINDIR).tar.gz -rm -rf -- $(DISTBINDIR) -rm -f -- $(DISTDIR).tar.gz -rm -rf -- $(DISTDIR) -rm -f -- $(ORIGDIR).tar.gz -rm -rf -- $(ORIGDIR) $(DISTBINDIR): $(INSTALL_DIR) $(DISTBINDIR) libdir: all $(DISTBINDIR) $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) $(INSTALL_DATA) $(SOURCES) $(DISTBINDIR) $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR) test -z "$(strip $(EXTRA_DIST))" || \ $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR) # tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) $(DISTDIR): $(INSTALL_DIR) $(DISTDIR) $(ORIGDIR): $(INSTALL_DIR) $(ORIGDIR) dist: $(DISTDIR) $(INSTALL_DATA) Makefile $(DISTDIR) $(INSTALL_DATA) README.txt $(DISTDIR) $(INSTALL_DATA) LICENSE.txt $(DISTDIR) $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR) test -z "$(strip $(ALLSOURCES))" || \ $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR) test -z "$(strip $(PDOBJECTS))" || \ $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR) test -z "$(strip $(HELPPATCHES))" || \ $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR) test -z "$(strip $(EXTRA_DIST))" || \ $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR) test -z "$(strip $(EXAMPLES))" || \ $(INSTALL_DIR) $(DISTDIR)/examples && \ for file in $(EXAMPLES); do \ $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \ done test -z "$(strip $(MANUAL))" || \ $(INSTALL_DIR) $(DISTDIR)/manual && \ for file in $(MANUAL); do \ $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \ done tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) # make a Debian source package dpkg-source: debclean make distclean dist mv $(DISTDIR) $(ORIGDIR) tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) rm -f -- $(DISTDIR).tar.gz rm -rf -- $(DISTDIR) $(ORIGDIR) cd .. && dpkg-source -b $(LIBRARY_NAME) etags: etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h showsetup: @echo "CFLAGS: $(CFLAGS)" @echo "LDFLAGS: $(LDFLAGS)" @echo "LIBS: $(LIBS)" @echo "PD_INCLUDE: $(PD_INCLUDE)" @echo "PD_PATH: $(PD_PATH)" @echo "objectsdir: $(objectsdir)" @echo "LIBRARY_NAME: $(LIBRARY_NAME)" @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)" @echo "SOURCES: $(SOURCES)" @echo "PDOBJECTS: $(PDOBJECTS)" @echo "ALLSOURCES: $(ALLSOURCES)" @echo "UNAME: $(UNAME)" @echo "CPU: $(CPU)" @echo "pkglibdir: $(pkglibdir)" @echo "DISTDIR: $(DISTDIR)" @echo "ORIGDIR: $(ORIGDIR)" pd-bsaylor_0.1/partconv~.dsw0000644000076500007650000000106711466373036014754 0ustar hanshansMicrosoft Developer Studio Workspace File, Format Version 6.00 # WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELSCHT WERDEN! ############################################################################### Project: "partconv"=.\partconv.dsp - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### pd-bsaylor_0.1/svf~.c0000644000076500007650000001142011466373036013335 0ustar hanshans/* * copyright Steve Harris, Ben Saylor * see GPL.txt */ #include #include #include "m_pd.h" #ifdef NT #define inline __inline #define M_PI 3.14159265358979323846 #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif // Number of filter oversamples #define F_R 3 // Denormalise floats, only actually needed for PIII and very recent PowerPC #define FLUSH_TO_ZERO(fv) (((*(unsigned int*)&(fv))&0x7f800000)==0)?0.0f:(fv) /* pd's samplerate */ float fs; static t_class *svf_class; typedef struct _svf { t_object x_obj; float f; // 2.0*sin(PI*fs/(fc*r)); float q; // 2.0*cos(pow(q, 0.1)*PI*0.5); float qnrm; // sqrt(m/2.0f+0.01f); float h; // high pass output float b; // band pass output float l; // low pass output float p; // peaking output (allpass with resonance) float n; // notch output float *op; // pointer to output value } t_svf; /* Store data in SVF struct, takes the sampling frequency, cutoff frequency and Q, and fills in the structure passed */ //static inline void setup_svf(sv_filter *sv, float fs, float fc, float q, int t) { static inline void setup_svf(t_svf *sv, float fc, float q) { sv->f = 2.0f * sin(M_PI * fc / (float)(fs * F_R)); sv->q = 2.0f * cos(pow(q, 0.1f) * M_PI * 0.5f); sv->qnrm = sqrt(sv->q/2.0+0.01); } /* Run one sample through the SV filter. Filter is by andy@vellocet */ static inline float run_svf(t_svf *sv, float in) { float out; int i; in = sv->qnrm * in ; for (i=0; i < F_R; i++) { // only needed for pentium chips // OLD VERSION in = FLUSH_TO_ZERO(in); sv->l = FLUSH_TO_ZERO(sv->l); // new versions, thanks to Damon Chaplin, inserted by Ed Kelly, not yet working!!! //in = ((int)in & 0x7f800000)==0?0.0f:in; //sv->l = ((int)sv->l & 0x7f800000)==0?0.0f:sv->l; // very slight waveshape for extra stability sv->b = sv->b - sv->b * sv->b * sv->b * 0.001f; // regular state variable code here // the notch and peaking outputs are optional sv->h = in - sv->l - sv->q * sv->b; sv->b = sv->b + sv->f * sv->h; sv->l = sv->l + sv->f * sv->b; sv->n = sv->l + sv->h; sv->p = sv->l - sv->h; out = *(sv->op); in = out; } return out; } static void svf_setstate_LP(t_svf *sv) { sv->op = &(sv->l); } static void svf_setstate_HP(t_svf *sv) { sv->op = &(sv->h); } static void svf_setstate_BP(t_svf *sv) { sv->op = &(sv->b); } static void svf_setstate_BR(t_svf *sv) { sv->op = &(sv->n); } static void svf_setstate_AP(t_svf *sv) { sv->op = &(sv->p); } static t_int *svf_perform(t_int *w) { t_svf *obj = (t_svf *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *freq = (t_float *)(w[3]); t_float *q = (t_float *)(w[4]); t_float *res = (t_float *)(w[5]); t_float *out = (t_float *)(w[6]); int n = (int)(w[7]); while (n--) { float f = *(in++); setup_svf(obj, *(freq++), *(q++)); *(out++) = run_svf(obj, f + ((obj->b) * (*(res++)))); } return (w+8); } static void svf_dsp(t_svf *x, t_signal **sp) { dsp_add(svf_perform, 7, 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); } static void *svf_new(t_symbol *s, int argc, t_atom *argv) { char string[11]; t_svf *x = (t_svf *)pd_new(svf_class); svf_setstate_LP(x); if (argc > 0) { atom_string(argv, string, 10); if (!strcmp(string, "high")) svf_setstate_HP(x); if (!strcmp(string, "band")) svf_setstate_BP(x); if (!strcmp(string, "notch")) svf_setstate_BR(x); if (!strcmp(string, "peak")) svf_setstate_AP(x); } 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); inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal); outlet_new(&x->x_obj, gensym("signal")); return (x); } void svf_tilde_setup(void) { fs = sys_getsr(); svf_class = class_new(gensym("svf~"), (t_newmethod)svf_new, 0, sizeof(t_svf), 0, A_GIMME, 0); class_addmethod(svf_class, nullfn, gensym("signal"), 0); class_addmethod(svf_class, (t_method)svf_dsp, gensym("dsp"), 0); class_addmethod(svf_class, (t_method)svf_setstate_LP, gensym("low"), 0); class_addmethod(svf_class, (t_method)svf_setstate_HP, gensym("high"), 0); class_addmethod(svf_class, (t_method)svf_setstate_BP, gensym("band"), 0); class_addmethod(svf_class, (t_method)svf_setstate_BR, gensym("notch"), 0); class_addmethod(svf_class, (t_method)svf_setstate_AP, gensym("peak"), 0); } pd-bsaylor_0.1/zhzxh~.c0000644000076500007650000000416211466373036013717 0ustar hanshans/* Copyright 2002 Benjamin R. Saylor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "m_pd.h" #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif static t_class *zhzxh_class; typedef struct _zhzxh { t_object x_obj; t_float slope; t_float lastval; t_float srate; t_float f; } t_zhzxh; static t_int *zhzxh_perform(t_int *w) { t_zhzxh *x = (t_zhzxh *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); t_float f; t_float lastval = x->lastval; t_float delta = x->slope / x->srate; while (n--) { f = *(in++); if (lastval < f) *out = lastval + delta; else *out = lastval - delta; lastval = *(out++); } x->lastval = lastval; return (w+5); } static void zhzxh_dsp(t_zhzxh *x, t_signal **sp) { dsp_add(zhzxh_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *zhzxh_new(t_symbol *s, int argc, t_atom *argv) { t_zhzxh *x = (t_zhzxh *)pd_new(zhzxh_class); x->slope = 1; x->lastval = 0; x->srate = sys_getsr(); floatinlet_new(&x->x_obj, &x->slope); outlet_new(&x->x_obj, gensym("signal")); return (x); } void zhzxh_tilde_setup(void) { zhzxh_class = class_new(gensym("zhzxh~"), (t_newmethod)zhzxh_new, 0, sizeof(t_zhzxh), 0, A_GIMME, 0); CLASS_MAINSIGNALIN(zhzxh_class, t_zhzxh, f); class_addmethod(zhzxh_class, (t_method)zhzxh_dsp, gensym("dsp"), 0); } pd-bsaylor_0.1/susloop~.c0000644000076500007650000000764511466373036014261 0ustar hanshans/* Copyright 2002 Benjamin R. Saylor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "m_pd.h" static t_class *susloop_class; static t_float pdsr; /* pd's sample rate */ typedef struct _susloop { t_object x_obj; t_float a; /* beginning of loop */ t_float b; /* end of loop */ t_float startpos; /* start offset */ t_float pos; /* position in sample */ t_float direction; /* for pingpong loops */ t_float f; /* dummy for when input is float instead of signal */ void (*susloop_func)(t_int *x, t_float *in, t_float *out, int n); /* can be forward or pingpong */ } t_susloop; static void susloop_forward(t_int *x, t_float *in, t_float *out, int n) { t_float sr; t_float p = ((t_susloop *)x)->pos; t_float a = ((t_susloop *)x)->a; t_float b = ((t_susloop *)x)->b; while (n--) { sr = *in; if (p > b) { p = a + (p - b); } *out = p; p += sr/pdsr; in++; out++; } ((t_susloop *)x)->pos = p; } static void susloop_pingpong(t_int *x, t_float *in, t_float *out, int n) { t_float sr; t_float p = ((t_susloop *)x)->pos; t_float a = ((t_susloop *)x)->a; t_float b = ((t_susloop *)x)->b; t_float d = ((t_susloop *)x)->direction; while (n--) { sr = *in; if (p > b) { p = b - (p - b); d = -1; } else if (p < a && d < 0) { p = a + (a - p); d = 1; } *out = p; p += d*(sr/pdsr); in++; out++; } ((t_susloop *)x)->pos = p; ((t_susloop *)x)->direction = d; } static t_int *susloop_perform(t_int *w) { ((t_susloop *)w[1])->susloop_func((t_int *)w[1], (t_float *)(w[2]), (t_float *)(w[3]), (int)(w[4])); return (w+5); } static void susloop_dsp(t_susloop *x, t_signal **sp) { dsp_add(susloop_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *susloop_new(t_symbol *s, int argc, t_atom *argv) { t_susloop *x = (t_susloop *)pd_new(susloop_class); int looptype = 0; x->a = x->b = x->startpos = 0; x->direction = 1; x->susloop_func = susloop_forward; switch (argc) { case 4: x->startpos = atom_getfloat(argv+3); case 3: looptype = atom_getint(argv+2); if (looptype == 0) x->susloop_func = susloop_forward; else x->susloop_func = susloop_pingpong; case 2: x->a = atom_getfloat(argv); x->b = atom_getfloat(argv+1); } floatinlet_new(&x->x_obj, &x->a); floatinlet_new(&x->x_obj, &x->b); floatinlet_new(&x->x_obj, &x->startpos); outlet_new(&x->x_obj, gensym("signal")); return (x); } static void susloop_bang(t_susloop *x) { x->pos = x->startpos; x->direction = 1; } static void susloop_setfunc(t_susloop *x, t_floatarg type) { if (type == 1) { x->direction = 1; x->susloop_func = susloop_pingpong; } else x->susloop_func = susloop_forward; } void susloop_tilde_setup(void) { pdsr = sys_getsr(); susloop_class = class_new(gensym("susloop~"), (t_newmethod)susloop_new, 0, sizeof(t_susloop), 0, A_GIMME, 0); class_addbang(susloop_class, susloop_bang); /* class_addmethod(susloop_class, nullfn, gensym("signal"), 0); */ CLASS_MAINSIGNALIN(susloop_class, t_susloop, f); class_addmethod(susloop_class, (t_method)susloop_dsp, gensym("dsp"), 0); class_addmethod(susloop_class, (t_method)susloop_setfunc, gensym("type"), A_DEFFLOAT, 0); } pd-bsaylor_0.1/partconv~.c0000644000076500007650000002717511466373036014411 0ustar hanshans/* Copyright 2003-2005 Benjamin R. Saylor * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ // Thu Feb 17 22:29:27 CST 2005 - Changed outbuf loops to use comparison instead of modulo (suggested by c. clepper) - faster // Sat Jul 30 19:59:08 AKDT 2005 - Completed modification for re-blocking and dividing up the work between calls. // This has eliminated dropouts due to lots of work on large block boundaries. // Fri Aug 5 10:46:33 AKDT 2005 - accumulate in the frequency domain, so only 1 IFFT is needed per input block, // rather than IFFTs. Big performance boost. // Fri Aug 5 20:27:05 AKDT 2005 - should work properly with arbitrary (2^n) blocksize <= partsize // Fri Aug 12 00:32:29 AKDT 2005 - added altivec code by Chris Clepper // TODO // SSE version // multichannel (multiple IRs)? probably wouldn't gain much from this // divide work more evenly? (0, 15, 7, 23, 3, 11, 19, 27, ...) // someday, an SSE3 version (supposed to make complex math fast) #include #include #include #include "m_pd.h" #ifdef __VEC__ #include #endif #define MAXPARTS 256 // max number of partitions #ifdef USE_SSE typedef float v4sf __attribute__ ((vector_size (16))); #endif static t_class *partconv_class; struct sumbuffer { int index; fftwf_complex *fd; float *td; fftwf_plan plan; int readpos; struct sumbuffer *next, *prev; }; typedef struct _partconv { t_object x_obj; t_symbol *arrayname; int partsize; int fftsize; float scale; int paddedsize; int nbins; int nparts; int ir_prepared; int pd_blocksize; // partitions of impulse response fftwf_plan irpart_plan; float *irpart_td[MAXPARTS]; fftwf_complex *irpart_fd[MAXPARTS]; // input fftwf_plan input_plan; float *inbuf; int inbufpos; float *input_td; fftwf_complex *input_fd; // circular array/list of buffers for accumulating results of convolution struct sumbuffer sumbufs[MAXPARTS+2]; int nsumbufs; // number of sumbufs struct sumbuffer *sumbuf; // the current sumbuf corresponding to the first partition of the IR // dividing up the work between calls to perform() int parts_per_call[MAXPARTS]; // parts_per_call[c] is the number of partitions to convolve during perform() call c int curcall; // current call, counted from the beginning of the current cycle (input buffer full) int curpart; // current partition to convolve } t_partconv; // Determine how to divide the work as evenly as possible between calls to perform(). static void partconv_deal_work(t_partconv *x) { int calls_per_cycle; int parts_to_distribute; int i; // Like dealing cards. // One cycle is defined as the time it takes to fill the input buffer (whose size is the user-given partition size) calls_per_cycle = x->partsize / x->pd_blocksize; for (i = 0; i < calls_per_cycle; i++) { x->parts_per_call[i] = 0; } i = 0; parts_to_distribute = x->nparts; while (parts_to_distribute) { x->parts_per_call[i]++; parts_to_distribute--; i = (i + 1) % calls_per_cycle; } /* for (i = 0; i < calls_per_cycle; i++) { printf("parts_per_call[%d] = %d\n", i, x->parts_per_call[i]); } */ } #ifdef __VEC__ #include "altivec-perform.inc.c" #else static t_int *partconv_perform(t_int *w) { t_partconv *x = (t_partconv *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; int j; int k; // bin int p; // partition int endpart; #ifdef USE_SSE int v1; int v2; int nvecs; v4sf *cursumbuf_fd; v4sf *input_fd; v4sf *irpart_fd; #else fftwf_complex *cursumbuf_fd; fftwf_complex *input_fd; fftwf_complex *irpart_fd; #endif float *sumbuf1ptr; float *sumbuf2ptr; memcpy(&(x->inbuf[x->inbufpos]), in, n*sizeof(float)); // gather a block of input into input buffer x->inbufpos += n; if (x->inbufpos >= x->partsize) { // input buffer is full, so we begin a new cycle if (x->pd_blocksize != n) { // the patch's blocksize has change since we last dealt the work x->pd_blocksize = n; partconv_deal_work(x); } x->inbufpos = 0; x->curcall = 0; x->curpart = 0; memcpy(x->input_td, x->inbuf, x->partsize * sizeof(float)); // copy 'gathering' input buffer into 'transform' buffer memset(&(x->input_td[x->partsize]), 0, (x->paddedsize - x->partsize) * sizeof(float)); // pad fftwf_execute(x->input_plan); // transform the input // everything has been read out of prev sumbuf, so clear it memset(x->sumbuf->prev->td, 0, x->paddedsize * sizeof(float)); // advance sumbuf pointers x->sumbuf = x->sumbuf->next; x->sumbuf->readpos = 0; x->sumbuf->prev->readpos = x->partsize; } // convolve this call's portion of partitions endpart = x->curpart + x->parts_per_call[x->curcall]; if (endpart > x->nparts) // FIXME does this ever happen? endpart = x->nparts; for (p = x->curpart; p < endpart; p++) { // multiply the input block by the partition, accumulating the result in the appropriate sumbuf #ifdef USE_SSE #include "sse-conv.inc.c" #else cursumbuf_fd = x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; input_fd = x->input_fd; irpart_fd = x->irpart_fd[p]; for (k = 0; k < x->nbins; k++) { cursumbuf_fd[k][0] += ( input_fd[k][0] * irpart_fd[k][0] - input_fd[k][1] * irpart_fd[k][1]); cursumbuf_fd[k][1] += ( input_fd[k][0] * irpart_fd[k][1] + input_fd[k][1] * irpart_fd[k][0]); } #endif } x->curpart = p; // The convolution of the fresh block of input with the first partition of the IR // is the last thing that gets summed into the current sumbuf before it gets IFFTed and starts being output. // This happens during the first call of every cycle. if (x->curcall == 0) { // current sumbuf has been filled, so transform it // Output loop will begin to read it and sum it with the last one fftwf_execute(x->sumbuf->plan); } // we're summing and outputting the first half of the most recently IFFTed sumbuf // and the second half of the previous one sumbuf1ptr = &(x->sumbuf->td[x->sumbuf->readpos]); sumbuf2ptr = &(x->sumbuf->prev->td[x->sumbuf->prev->readpos]); for (i = 0; i < n; i++) { out[i] = (sumbuf1ptr[i] + sumbuf2ptr[i]) * x->scale; } x->sumbuf->readpos += n; x->sumbuf->prev->readpos += n; x->curcall++; return (w+5); } #endif // __VEC__ static void partconv_free(t_partconv *x) { int i; fftwf_free(x->inbuf); for (i = 0; i < x->nparts; i++) fftwf_free(x->irpart_td[i]); fftwf_free(x->input_td); fftwf_destroy_plan(x->input_plan); for (i = 0; i < x->nsumbufs; i++) { fftwf_free(x->sumbufs[i].fd); fftwf_destroy_plan(x->sumbufs[i].plan); } } static void partconv_set(t_partconv *x, t_symbol *s) { int i; int j; t_garray *arrayobj; t_float *array; int arraysize; int arraypos; // get the array from pd x->arrayname = s; if ( ! (arrayobj = (t_garray *)pd_findbyclass(x->arrayname, garray_class))) { if (*x->arrayname->s_name) { pd_error(x, "partconv~: %s: no such array", x->arrayname->s_name); return; } } else if ( ! garray_getfloatarray(arrayobj, &arraysize, &array)) { pd_error(x, "%s: bad template", x->arrayname->s_name); return; } // if the IR has already been prepared, free everything first if (x->ir_prepared == 1) { partconv_free(x); } // caculate number of partitions x->nparts = arraysize / x->partsize; if (arraysize % x->partsize != 0) x->nparts++; if (x->nparts > MAXPARTS) x->nparts = MAXPARTS; // allocate, fill, pad, and transform each IR partition for (arraypos = 0, i = 0; i < x->nparts; i++) { x->irpart_td[i] = fftwf_malloc(sizeof(float) * x->paddedsize); x->irpart_fd[i] = (fftwf_complex *) x->irpart_td[i]; x->irpart_plan = fftwf_plan_dft_r2c_1d(x->fftsize, x->irpart_td[i], x->irpart_fd[i], FFTW_MEASURE); for (j = 0; j < x->partsize && arraypos < arraysize; j++, arraypos++) { x->irpart_td[i][j] = array[arraypos]; } for ( ; j < x->paddedsize; j++) { x->irpart_td[i][j] = 0; } fftwf_execute(x->irpart_plan); fftwf_destroy_plan(x->irpart_plan); // now, x->irpart[i] contains the DFT of the ith partition of the impulse response. } x->inbuf = fftwf_malloc(sizeof(float) * x->partsize); x->inbufpos = 0; // allocate buffer for DFT of padded input x->input_td = fftwf_malloc(sizeof(float) * x->paddedsize); // float array into which input block is copied and padded x->input_fd = (fftwf_complex *) x->input_td; // fftwf_complex pointer to the same array to facilitate in-place fft x->input_plan = fftwf_plan_dft_r2c_1d(x->fftsize, x->input_td, x->input_fd, FFTW_MEASURE); // set up circular list/array of buffers for accumulating results of convolution x->nsumbufs = x->nparts + 2; x->sumbuf = &(x->sumbufs[0]); for (i = 0; i < x->nsumbufs; i++) { x->sumbufs[i].index = i; x->sumbufs[i].fd = fftwf_malloc(sizeof(float) * x->paddedsize); memset(x->sumbufs[i].fd, 0, sizeof(float) * x->paddedsize); x->sumbufs[i].td = (float *) x->sumbufs[i].fd; x->sumbufs[i].plan = fftwf_plan_dft_c2r_1d(x->fftsize, x->sumbufs[i].fd, x->sumbufs[i].td, FFTW_MEASURE); x->sumbufs[i].readpos = 0; } x->sumbufs[0].next = &(x->sumbufs[1]); x->sumbufs[0].prev = &(x->sumbufs[x->nsumbufs - 1]); for (i = 1; i < x->nsumbufs; i++) { x->sumbufs[i].next = &(x->sumbufs[(i + 1) % x->nsumbufs]); x->sumbufs[i].prev = &(x->sumbufs[i - 1]); } partconv_deal_work(x); x->curcall = 0; x->curpart = 0; post("partconv~: using %s in %d partitions with FFT-size %d", x->arrayname->s_name, x->nparts, x->fftsize); x->ir_prepared = 1; } static void partconv_dsp(t_partconv *x, t_signal **sp) { // if the ir array has not been prepared, prepare it if (x->ir_prepared == 0) { partconv_set(x, x->arrayname); } dsp_add(partconv_perform, 4, x, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n); } static void *partconv_new(t_symbol *s, int argc, t_atom *argv) { t_partconv *x = (t_partconv *)pd_new(partconv_class); outlet_new(&x->x_obj, gensym("signal")); if (argc != 2) { post("argc = %d", argc); error("partconv~: usage: [partconv~ ]\n\t- partition size must be a power of 2 >= blocksize"); return NULL; } x->arrayname = atom_getsymbol(argv); x->partsize = atom_getfloatarg(1, argc, argv); if (x->partsize <= 0 || x->partsize != (1 << ilog2(x->partsize))) { error("partconv~: partition size not a power of 2"); return NULL; } x->fftsize = 2 * x->partsize; x->scale = 1 / ((float) x->fftsize); // need 2*(n/2+1) float array for in-place transform, where n is fftsize. #ifdef USE_SSE // for sse, make it a multiple of 8, because we pull in 4 bins at a time and don't want to get a segfault x->paddedsize = 2 * (x->fftsize / 2 + 4); #else x->paddedsize = 2 * (x->fftsize / 2 + 1); #endif x->nbins = x->fftsize / 2 + 1; x->ir_prepared = 0; x->pd_blocksize = sys_getblksize(); return (x); } void partconv_tilde_setup(void) { partconv_class = class_new(gensym("partconv~"), (t_newmethod)partconv_new, (t_method)partconv_free, sizeof(t_partconv), 0, A_GIMME, 0); class_addmethod(partconv_class, nullfn, gensym("signal"), 0); class_addmethod(partconv_class, (t_method) partconv_dsp, gensym("dsp"), 0); class_addmethod(partconv_class, (t_method) partconv_set, gensym("set"), A_DEFSYMBOL, 0); } pd-bsaylor_0.1/aenv~-help.pd0000644000076500007650000000415711466373036014610 0ustar hanshans#N canvas 10 20 762 475 10; #X floatatom 238 150 5 0 0; #X floatatom 281 150 5 0 0; #X floatatom 324 150 5 0 0; #X floatatom 367 150 5 0 0; #X msg 8 115 1; #X msg 50 115 0; #N canvas 0 0 450 300 graph1 0; #X array env 88200 float 0; #X coords 0 1 88199 0 300 140 1; #X restore 455 327 graph; #X msg 20 250 bang; #X obj 142 353 tabwrite~ env; #X obj 291 335 *~; #X obj 312 444 dac~; #X obj 318 410 *~; #X obj 364 395 vsl 8 64 0 1 0 1 empty empty empty 0 -8 0 8 -262144 -1 -1 4900 1; #X obj 170 211 aenv~ 100 200 0.6 500; #X obj 430 222 phasor~ 100; #X obj 430 266 lop~ 1000; #X obj 430 244 -~ 0.5; #X obj 238 75 vsl 8 64 10 2000 0 1 empty empty attack 0 -8 0 8 -262144 -1 -1 600 1; #X obj 281 75 vsl 8 64 10 2000 0 1 empty empty decay 0 -8 0 8 -262144 -1 -1 800 1; #X obj 367 75 vsl 8 64 10 2000 0 1 empty empty release 0 -8 0 8 -262144 -1 -1 2600 1; #X obj 324 75 vsl 8 64 0 1 0 1 empty empty sustain 0 -8 0 8 -262144 -1 -1 4400 1; #X obj 430 146 notein 1; #X obj 430 196 mtof; #X text 42 206 nonzero -> attack; #X text 484 81 Ben Saylor ; #X text 500 97 http://www.macalester.edu/~bsaylor; #X obj 8 20 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 -1 ; #X text 27 17 <- click here; #X obj 20 70 del 800; #X text 452 6 aenv~: asymptotic ADSR envelope generator; #X msg 198 73 lina; #X msg 198 104 loga; #X text 104 73 linear attack; #X text 120 105 log attack; #X msg 198 133 zero; #X text 77 219 0 -> release; #X connect 0 0 13 1; #X connect 1 0 13 2; #X connect 2 0 13 3; #X connect 3 0 13 4; #X connect 4 0 7 0; #X connect 4 0 13 0; #X connect 5 0 13 0; #X connect 7 0 8 0; #X connect 9 0 11 0; #X connect 11 0 10 0; #X connect 11 0 10 1; #X connect 12 0 11 1; #X connect 13 0 8 0; #X connect 13 0 9 0; #X connect 14 0 16 0; #X connect 15 0 9 1; #X connect 16 0 15 0; #X connect 17 0 0 0; #X connect 18 0 1 0; #X connect 19 0 3 0; #X connect 20 0 2 0; #X connect 21 0 22 0; #X connect 21 1 13 0; #X connect 22 0 14 0; #X connect 26 0 4 0; #X connect 26 0 28 0; #X connect 28 0 5 0; #X connect 30 0 13 0; #X connect 31 0 13 0; #X connect 34 0 13 0; pd-bsaylor_0.1/altivec-perform.inc.c0000644000076500007650000002556211466373036016224 0ustar hanshans//altivec version by Chris Clepper // static t_int *partconv_perform(t_int *w) { t_partconv *x = (t_partconv *)(w[1]); t_float *in = (t_float *)(w[2]); t_float *out = (t_float *)(w[3]); int n = (int)(w[4]); int i; int j; int k; // bin int p; // partition int endpart; fftwf_complex *cursumbuf_fd; float *sumbuf1ptr; float *sumbuf2ptr; union { unsigned char c[16]; vector unsigned char v; }permfill; union { float f[4]; vector float v; }floatfill; vector float *load_input, *load_irpart; vector float store_multbuf1,store_multbuf2; vector float vinput_fd0, vinput_fd4; //input vectors vector float virpart_fd0, virpart_fd4; //ir partition vectors vector float permtemp1357, permtemp0246; vector float vzero;// vscale; vector unsigned char input_0022, input_1133, perm_0246, perm_1357, perm_0123,perm_4567; vector float vtemp1, vtemp2, vtemp3, vtemp4, vtemp5, vtemp6, vtemp7, vtemp8; floatfill.f[0] = 0.f; floatfill.f[1] = 0.f; floatfill.f[2] = 0.f; floatfill.f[3] = 0.f; vzero = floatfill.v; //store_multbuf = vzero; floatfill.f[0] = x->scale; floatfill.f[1] = x->scale; floatfill.f[2] = x->scale; floatfill.f[3] = x->scale; //vscale = floatfill.v; //fill the permute buffer for the first input_fd multiply permfill.c[0] = 0; permfill.c[1] = 1; permfill.c[2] = 2; permfill.c[3] = 3; //first float permfill.c[4] = 0; permfill.c[5] = 1; permfill.c[6] = 2; permfill.c[7] = 3; //second float permfill.c[8] = 8; permfill.c[9] = 9; permfill.c[10] = 10; permfill.c[11] = 11; //third float permfill.c[12] = 8; permfill.c[13] = 9; permfill.c[14] = 10; permfill.c[15] = 11; //fourth float input_0022 = permfill.v; permfill.c[0] = 4; permfill.c[1] = 5; permfill.c[2] = 6; permfill.c[3] = 7; //first float permfill.c[4] = 4; permfill.c[5] = 5; permfill.c[6] = 6; permfill.c[7] = 7; //second float permfill.c[8] = 12; permfill.c[9] = 13; permfill.c[10] = 14; permfill.c[11] = 15; //third float permfill.c[12] = 12; permfill.c[13] = 13; permfill.c[14] = 14; permfill.c[15] = 15; //fourth float input_1133 = permfill.v; //perm_0246 //0,1,2,3, 8,9,10,11, 16,17,18,19, 24,25,26,27 permfill.c[0] = 0; permfill.c[1] = 1; permfill.c[2] = 2; permfill.c[3] = 3; //first float permfill.c[4] = 8; permfill.c[5] = 9; permfill.c[6] = 10; permfill.c[7] = 11; //second float permfill.c[8] = 16; permfill.c[9] = 17; permfill.c[10] = 18; permfill.c[11] = 19; //third float permfill.c[12] = 24; permfill.c[13] = 25; permfill.c[14] = 26; permfill.c[15] = 27; //fourth float perm_0246 = permfill.v; // perm_1357 // 4,5,6,7, 12,13,14,15, 20,21,22,23, 28,29,30,31 permfill.c[0] = 4; permfill.c[1] = 5; permfill.c[2] = 6; permfill.c[3] = 7; //first float permfill.c[4] = 12; permfill.c[5] = 13; permfill.c[6] = 14; permfill.c[7] = 15; //second float permfill.c[8] = 20; permfill.c[9] = 21; permfill.c[10] = 22; permfill.c[11] = 23; //third float permfill.c[12] = 28; permfill.c[13] = 29; permfill.c[14] = 30; permfill.c[15] = 31; //fourth float perm_1357 = permfill.v; // perm_0123 from [0,2,4,6] and [1,3,5,7] // 0,1,2,3 16,17,18,19 4,5,6,7 20,21,22,23 permfill.c[0] = 0; permfill.c[1] = 1; permfill.c[2] = 2; permfill.c[3] = 3; //first float permfill.c[4] = 16; permfill.c[5] = 17; permfill.c[6] = 18; permfill.c[7] = 19; //second float permfill.c[8] = 4; permfill.c[9] = 5; permfill.c[10] = 6; permfill.c[11] = 7; //third float permfill.c[12] = 20; permfill.c[13] = 21; permfill.c[14] = 22; permfill.c[15] = 23; //fourth float perm_0123 = permfill.v; // perm_4567 from [0,2,4,6] and [1,3,5,7] // 8.9.10.11 24,25,26,27 12,13,14,15 28,29,30,31 permfill.c[0] = 8; permfill.c[1] = 9; permfill.c[2] = 10; permfill.c[3] = 11; //first float permfill.c[4] = 24; permfill.c[5] = 25; permfill.c[6] = 26; permfill.c[7] = 27; //second float permfill.c[8] = 12; permfill.c[9] = 13; permfill.c[10] = 14; permfill.c[11] = 15; //third float permfill.c[12] = 28; permfill.c[13] = 29; permfill.c[14] = 30; permfill.c[15] = 31; //fourth float // perm_4567 from [0,2,4,6] and [1,3,5,7] // 8.9.10.11 24,25,26,27 12,13,14,15 28,29,30,31 permfill.c[0] = 8; permfill.c[1] = 9; permfill.c[2] = 10; permfill.c[3] = 11; //first float permfill.c[4] = 24; permfill.c[5] = 25; permfill.c[6] = 26; permfill.c[7] = 27; //second float permfill.c[8] = 12; permfill.c[9] = 13; permfill.c[10] = 14; permfill.c[11] = 15; //third float permfill.c[12] = 28; permfill.c[13] = 29; permfill.c[14] = 30; permfill.c[15] = 31; //fourth float perm_4567 = permfill.v; memcpy(&(x->inbuf[x->inbufpos]), in, n*sizeof(float)); // gather a block of input into input buffer x->inbufpos += n; if (x->inbufpos >= x->partsize) { // input buffer is full, so we begin a new cycle if (x->pd_blocksize != n) { // the patch's blocksize has change since we last dealt the work x->pd_blocksize = n; partconv_deal_work(x); } x->inbufpos = 0; x->curcall = 0; x->curpart = 0; memcpy(x->input_td, x->inbuf, x->partsize * sizeof(float)); // copy 'gathering' input buffer into 'transform' buffer memset(&(x->input_td[x->partsize]), 0, (x->paddedsize - x->partsize) * sizeof(float)); // pad fftwf_execute(x->input_plan); // transform the input // everything has been read out of prev sumbuf, so clear it memset(x->sumbuf->prev->td, 0, x->paddedsize * sizeof(float)); // advance sumbuf pointers x->sumbuf = x->sumbuf->next; x->sumbuf->readpos = 0; x->sumbuf->prev->readpos = x->partsize; } // convolve this call's portion of partitions endpart = x->curpart + x->parts_per_call[x->curcall]; if (endpart > x->nparts) // FIXME does this ever happen? endpart = x->nparts; for (p = x->curpart; p < endpart; p++) { //printf("convolving with partition %d\n", p); // // multiply the input block by the partition, accumulating the result in the appropriate sumbuf // // FIXME do this in a circular list-type fashion so we don't need "index" cursumbuf_fd = x->sumbufs[(x->sumbuf->index + p) % x->nsumbufs].fd; for (k = 0; k < x->nbins; k+=4) { load_input = (vector float *)&x->input_fd[k][0]; vinput_fd0 = vec_ld(0, (vector float *) load_input); vtemp1 = vec_perm(load_input[0],vzero,input_0022); load_input = (vector float *)&x->input_fd[k][4]; //load input_fd[k][4] //vector will have input_fd[4,5,6,7] vinput_fd4 = vec_ld(0, (vector float *) &x->input_fd[k][4]); vtemp3 = vec_perm(load_input[0],vzero,input_0022); //vec_ld irpart[p][k][0] //vector will have irpart_fd[0,1,2,3] load_irpart = (vector float *) &x->irpart_fd[p][k][0]; virpart_fd0 = vec_ld(0,&x->irpart_fd[p][k][0]); vtemp1 = vec_madd(vtemp1,load_irpart[0],vzero); load_irpart = (vector float *) &x->irpart_fd[p][k][4]; virpart_fd4 = vec_ld(0,&x->irpart_fd[p][k][4]); vtemp3 = vec_madd(vtemp3,load_irpart[0],vzero); store_multbuf1 = vec_ld(0,&cursumbuf_fd[k][0]); store_multbuf2 = vec_ld(0,&cursumbuf_fd[k][4]); //vec_perm to line up the elements // irpart is fine // make vector of input_fd[0] [2] and [4] [6] //make vector of input_fd[1] [3] and [5] [7] // // permute only works on bytes so the first float is bytes 0,1,2,3 the second is 4,5,6,7 etc // // 0,1,2,3, 8,9,10,11, 16,17,18,19, 24,25,26,27 // // 4,5,6,7, 12,13,14,15, 20,21,22,23, 28,29,30,31 //vec_perm temp1 and temp3 into [0,2,4,6] permtemp0246 = vec_perm(vtemp1,vtemp3,perm_0246); //and [1,3,5,7] permtemp1357 = vec_perm(vtemp1,vtemp3,perm_1357); //vinput_fd[1,3,5,7] vtemp2 = vec_perm(vinput_fd0,vinput_fd4,perm_1357); //irpart[1,3,5,7] vtemp4 = vec_perm(virpart_fd0,virpart_fd4,perm_1357); //irpart[0,2,4,6] vtemp5 = vec_perm(virpart_fd0,virpart_fd4,perm_0246); //vec_nmsub input_fd[1,3,5,7] irpart[1,3,5,7] temp[0,2,4,6] vtemp6 = vec_nmsub(vtemp2,vtemp4,permtemp0246); //vec_madd input_fd[1,3,5,7] irpart[0,2,4,6] temp[1,3,5,7] vtemp7 = vec_madd(vtemp2,vtemp5,permtemp1357); //vec_madd all by scale - this is now done after the loop // vtemp6 = vec_madd(vtemp6,vscale,vzero); // vtemp7 = vec_madd(vtemp7,vscale,vzero); //vec_perm data back into place - tricky! //vec_perm nmsub_result[0,2,4,6] madd_result [1,3,5,7] // results will be [0,1,2,3] [4,5,6,7] vtemp1 = vec_perm(vtemp6,vtemp7,perm_0123); vtemp2 = vec_perm(vtemp6,vtemp7,perm_4567); //vec_st store_multbuf1 = vec_add(store_multbuf1,vtemp1); store_multbuf2 = vec_add(store_multbuf2,vtemp2); vec_st(store_multbuf1,0,&cursumbuf_fd[k][0]); vec_st(store_multbuf2,0,&cursumbuf_fd[k][4]); /* cursumbuf_fd[k][0] += ( x->input_fd[k][0] * x->irpart_fd[p][k][0] - x->input_fd[k][1] * x->irpart_fd[p][k][1]); cursumbuf_fd[k][1] += ( x->input_fd[k][0] * x->irpart_fd[p][k][1] + x->input_fd[k][1] * x->irpart_fd[p][k][0]);*/ } } x->curpart = p; // The convolution of the fresh block of input with the first partition of the IR // is the last thing that gets summed into the current sumbuf before it gets IFFTed and starts being output. // This happens during the first call of every cycle. if (x->curcall == 0) { // current sumbuf has been filled, so transform it (TD to FD). // Output loop will begin to read it and sum it with the last one fftwf_execute(x->sumbuf->plan); } // we're summing and outputting the first half of the most recently IFFTed sumbuf // and the second half of the previous one sumbuf1ptr = &(x->sumbuf->td[x->sumbuf->readpos]); sumbuf2ptr = &(x->sumbuf->prev->td[x->sumbuf->prev->readpos]); for (i = 0; i < n; i++) { *(out++) = (*(sumbuf1ptr++) + *(sumbuf2ptr++)) * x->scale; } x->sumbuf->readpos += n; x->sumbuf->prev->readpos += n; x->curcall++; return (w+5); } pd-bsaylor_0.1/mtosr.pd0000644000076500007650000000053011466373036013666 0ustar hanshans#N canvas 0 0 450 300 10; #X obj 38 57 mtof; #X obj 38 33 inlet; #X obj 38 82 expr \$1 / 261.626 * $f1; #X obj 38 106 outlet; #X text 74 249 creation argument: samplerate at middle C.; #X text 25 190 takes midi note value and converts to a samplerate for sample playback.; #X connect 0 0 2 0; #X connect 1 0 0 0; #X connect 2 0 3 0;