You can implement the same thing with Pd only. I've attached a patch that creates the same waveform as the one you're loading, plus adds the three guard points for the cubic interpolation.
On Thu, Apr 10, 2014 at 3:48 AM, David <dfket...@gmail.com> wrote: > Thanks again to everyone that replied. I looked at the examples, but to be > honest I didn't really understand them completely, and I got a few error > messages when I tried to run them. I have pd-extended installed, but maybe > I'm missing some externals used by the examples. Anyway, I decided to go > with plan B, and use another software package to generate sound files and > then load them into PD. I'm using Octave, an open-source math program that > is mostly compatible with Matlib. It has some built-in functions to read > and write audio files (mono only), but I can generate audio files in just a > few lines of code, like this: > > x = linspace(0,2*pi,1024); > y = sin(cos(sin(x) * pi) * pi); > plot(x,y); > title('y = sin(cos(sin x) * pi) * pi)'); > wavwrite(y,44100,16,'C:\\Data\\Octave\\sincossin.wav'); > > The first two lines generate the data (1024 samples in length), the next > two lines draw a graph in a separate window, and the last line writes the > data to a file. I really recommend it if you want to generate audio samples > using math functions. > > Then I load the file into PD with the attached patch. Since I know my > files are 1024 samples long, I can just allocate an array of the correct > size and not have to worry about complications. > > I attached my patch and a sample file (generated using the code above) if > you're interested. > > David. > > >
#N canvas 175 55 969 565 10; #N canvas 0 22 450 278 (subpatch) 0; #X array wave 1027 float 2; #X coords 0 1 1027 -1 200 140 1; #X restore 584 390 graph; #X obj 36 138 until; #X obj 36 181 f; #X obj 63 181 + 1; #X msg 51 160 0; #X obj 114 302 pi; #X obj 55 319 sin; #X obj 55 341 *; #X obj 114 324 t f f; #X obj 55 363 cos; #X obj 55 385 *; #X obj 55 407 sin; #X obj 55 429 tabwrite wave; #X msg 266 267 resize \$1; #X obj 251 311 until; #X obj 251 353 f; #X obj 345 425 + 1; #X obj 251 375 t f f f; #X msg 385 194 3; #X obj 385 216 until; #X obj 385 261 f; #X obj 411 261 + 1; #X msg 400 240 0; #X obj 479 310 moses 1; #X obj 518 387 +; #X obj 404 340 +; #X obj 266 245 + 3; #X obj 278 353 - 1; #X obj 266 332 - 1; #X obj 385 168 sel 0; #X obj 404 317 moses 1; #X obj 251 223 t f f f f f b; #X obj 251 196 arraysize wave; #X obj 266 289 s wave; #X obj 270 398 tabread wave; #X obj 270 450 tabwrite wave; #X obj 404 379 tabread wave; #X obj 404 404 tabwrite wave; #X floatatom 584 175 5 0 0 0 - - -; #X obj 584 350 dac~; #X obj 104 115 s wave; #X obj 36 484 sel; #X obj 36 116 t f b f; #X obj 36 203 t f f f; #X obj 51 461 - 1; #X obj 584 328 tabread4~ wave; #X obj 584 196 phasor~; #X obj 584 282 *~ 1024; #X obj 584 304 +~ 1; #X msg 104 93 resize \$1; #X obj 36 76 t f f f; #X floatatom 36 41 5 0 0 0 - - -; #X obj 623 240 arraysize wave; #X obj 623 262 - 3; #X obj 623 218 sel 2; #X obj 385 293 t f f f; #N canvas 405 223 696 526 divisor 0; #X obj 56 346 / 8; #X obj 56 368 t f f; #X obj 83 390 / 4; #X obj 56 429 +; #X obj 212 285 f; #X obj 238 285 + 1; #X msg 227 263 1; #X obj 212 97 until; #X obj 212 141 f; #X obj 238 141 + 1; #X msg 227 119 1; #X obj 212 163 swap 2; #X obj 212 196 pow; #X obj 212 218 ==; #X obj 212 240 sel 0 1; #X obj 212 72 t b b b f; #X obj 212 307 + 1; #X obj 56 33 inlet; #X obj 56 55 t f f; #X obj 56 451 outlet; #X obj 212 351 swap 2; #X obj 212 373 pow; #X obj 212 395 * 3; #X obj 212 329 - 10; #X text 260 176 this loop determines what power 2 the table's size is; #X obj 83 412 +; #X text 258 384 It seems to give the desired result; #X text 259 329 and this algorithm makes sure we get the correct divisor. e.g. for 1024 we need to divide by 163 \, which is ((1024 / 8) + 32) + 3 \, for 2048 we divide by 326 ((2048 / 8) + 64) + 6 etc.; #X connect 0 0 1 0; #X connect 1 0 3 0; #X connect 1 1 2 0; #X connect 2 0 25 0; #X connect 3 0 19 0; #X connect 4 0 5 0; #X connect 4 0 16 0; #X connect 5 0 4 1; #X connect 6 0 4 1; #X connect 7 0 8 0; #X connect 8 0 9 0; #X connect 8 0 11 0; #X connect 9 0 8 1; #X connect 10 0 8 1; #X connect 11 0 12 0; #X connect 11 1 12 1; #X connect 12 0 13 0; #X connect 13 0 14 0; #X connect 14 0 4 0; #X connect 14 1 7 1; #X connect 15 0 7 0; #X connect 15 1 10 0; #X connect 15 2 6 0; #X connect 15 3 13 1; #X connect 16 0 23 0; #X connect 17 0 18 0; #X connect 18 0 0 0; #X connect 18 1 15 0; #X connect 20 0 21 0; #X connect 20 1 21 1; #X connect 21 0 22 0; #X connect 22 0 25 1; #X connect 23 0 20 0; #X connect 25 0 3 1; #X restore 90 181 pd divisor; #X obj 55 227 /; #X text 84 226 this is x; #X text 81 351 this is y; #X text 261 146 this algorithm creates the guard points; #X text 580 60 we play the waveform with [tabread4~] instead of [tabosc4~] cause when we create a new table size we first set it to a power of (not a power of two plus three) and then add the three guard points. before we add the guard points \, if we use [tabosc4~] \, Pd will complain that the table is not of a size of a pwer of two plus three \, but with [tabread4~] this won't happen; #X text 72 38 set a size for the table (should be a power of 2 \, otherwise Pd will crash); #X connect 1 0 2 0; #X connect 2 0 3 0; #X connect 2 0 43 0; #X connect 3 0 2 1; #X connect 4 0 2 1; #X connect 5 0 8 0; #X connect 6 0 7 0; #X connect 7 0 9 0; #X connect 8 0 7 1; #X connect 8 1 10 1; #X connect 9 0 10 0; #X connect 10 0 11 0; #X connect 11 0 12 0; #X connect 13 0 33 0; #X connect 14 0 15 0; #X connect 15 0 17 0; #X connect 15 0 27 0; #X connect 16 0 35 1; #X connect 17 0 29 0; #X connect 17 1 34 0; #X connect 17 2 16 0; #X connect 18 0 19 0; #X connect 19 0 20 0; #X connect 20 0 21 0; #X connect 20 0 55 0; #X connect 21 0 20 1; #X connect 22 0 20 1; #X connect 23 0 37 1; #X connect 23 1 24 0; #X connect 24 0 37 1; #X connect 25 0 36 0; #X connect 26 0 13 0; #X connect 27 0 15 1; #X connect 28 0 15 1; #X connect 29 0 18 0; #X connect 30 0 25 0; #X connect 30 1 36 0; #X connect 31 0 14 0; #X connect 31 1 26 0; #X connect 31 2 28 0; #X connect 31 3 25 1; #X connect 31 4 24 1; #X connect 31 5 22 0; #X connect 32 0 31 0; #X connect 34 0 35 0; #X connect 36 0 37 0; #X connect 38 0 46 0; #X connect 41 0 32 0; #X connect 42 0 1 0; #X connect 42 1 4 0; #X connect 42 2 44 0; #X connect 43 0 41 0; #X connect 43 1 57 0; #X connect 43 2 12 1; #X connect 44 0 41 1; #X connect 45 0 39 0; #X connect 45 0 39 1; #X connect 46 0 47 0; #X connect 47 0 48 0; #X connect 48 0 45 0; #X connect 49 0 40 0; #X connect 50 0 42 0; #X connect 50 1 56 0; #X connect 50 2 49 0; #X connect 51 0 50 0; #X connect 52 0 53 0; #X connect 53 0 47 1; #X connect 54 0 52 0; #X connect 55 0 54 0; #X connect 55 1 30 0; #X connect 55 2 23 0; #X connect 56 0 57 1; #X connect 57 0 6 0;
_______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list