On 2018-05-24 15:03, Joe White wrote:
Hey Oliver,

This is a neat trick, however for my purposes [soundfle_info] was
being used to extract both the sample rate and sample length to
calculate the duration of the file.

Looks like in order to switch to [soundfiler] I'd have to load the
whole file to memory regardless, as the `-skip 1` flag means the left
outlet (sample length) of [soundfiler] only outputs '1'.

have a look again.

in the middle of the patch, i use soundfiler's right outlet (available since PD 0.48, so make sure you are using this !) to get the file's samplerate, even though it is just reading 1 sample of it. so, no need to load the whole thing.

the left part of the patch gives you the file's length in samples, which you can then re-calculate (using the file's samplerate) to ms or whatever you need.

yes, the left outlet always only puts out 1 or 0, which i use to narrow down the last valid sample position, which is then the file's length in samples (endpoint).

i send the patch again to illustrate what i mean (unless i misunderstood something)

best

oliver


Cheers,
Joe

On 12 May 2018 at 19:37, Alexandre Torres Porres <[email protected]>
wrote:

a new flag for [soundfiler] will make this easier without the need
of a dummy buffer

see https://github.com/pure-data/pure-data/pull/193 [1]

2018-05-12 14:06 GMT-03:00 oliver <[email protected]>:

Joe White wrote:
Hi all,

I recently spent a bit of time tracking down why a patch wasn't
loading a couple of externals in a windows application that embeds
libpd.

The patch was using /vbap/ [0] and /soundfile_info/ from iemlib [1].

hi,

just the other night i was hacking together a [sound_file] info
alternative with purely vanilla objects WITHOUT loading an entire
file into RAM.

the method is basically to use [soundfiler] to load 1 sample of a
file into a table with a -skip message, and recalculate the skip
position until [soundfiler]'s left outlet outputs 1 (instead of 0).

all of [soundfile_info]'s other values are also output from
[soundfiler]'s right outlet as of PD version 0.48.

it takes a tad longer than [soundfile_info] to output the
soundfile's length, but it's acceptable imho. plus you can use .aiff
too !

best

oliver

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list [2]

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management ->
https://lists.puredata.info/listinfo/pd-list [2]



Links:
------
[1] https://github.com/pure-data/pure-data/pull/193
[2] https://lists.puredata.info/listinfo/pd-list
#N canvas 89 106 924 751 10;
#X obj 91 583 cnv 15 220 25 empty empty length_in_samples 80 12 0 14
-261682 -66577 0;
#X obj 406 478 cnv 15 170 25 empty empty samplerate 80 12 0 14 -261234
-66577 0;
#X obj 80 274 soundfiler;
#X obj 50 138 table test 1;
#X obj 50 189 t f f, f 8;
#X obj 80 321 f;
#X obj 80 296 sel 0 1, f 58;
#X msg 398 410 1;
#X obj 80 376 list prepend;
#X obj 252 325 f;
#X obj 252 383 list append;
#X obj 80 348 t f f;
#X obj 252 348 t f f;
#X obj 80 489 t f f f;
#X obj 98 517 !=, f 4;
#X obj 50 517 spigot;
#X obj 98 563 f;
#X obj 98 539 sel 0;
#X floatatom 398 578 10 0 0 0 - - -, f 10;
#X obj 717 195 soundfile_info;
#X obj 398 556 realtime;
#X obj 717 120 t b b, f 7;
#X floatatom 756 307 10 0 0 0 - - -, f 10;
#X obj 756 284 realtime;
#X obj 799 260 t b;
#X obj 717 93 bng 20 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X floatatom 98 648 10 0 0 0 - - -, f 10;
#X floatatom 685 371 10 0 0 0 - - -, f 10;
#X obj 80 400 t l l;
#X msg 107 423 \$2 \$1;
#X obj 107 445 -;
#X obj 107 466 * 0.5;
#X obj 80 466 +;
#X msg 80 423 \$1, f 2;
#X msg 379 353 \$1;
#X msg 685 222 \$3 \$1;
#X obj 685 243 /;
#X obj 322 331 soundfiler;
#X obj 379 376 t b b f;
#X msg 322 261 read \$1 test;
#X msg 80 250 read -skip \$1 \$2 test;
#X obj 238 187 t s s, f 11;
#X obj 80 225 pack 0 s, f 25;
#X obj 98 624 /, f 5;
#X floatatom 418 484 10 0 0 0 - - -, f 10;
#X msg 379 439 5e+008;
#X obj 238 55 openpanel;
#X obj 238 15 bng 30 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 278 120 list trim;
#X msg 238 145 symbol 
D:/#audio/hotelzimmerverwuestung/hotelzimmerverw_4_remaster.wav
;
#X obj 238 99 t b s;
#X obj 238 76 symbol;
#X obj 278 99 list prepend set symbol;
#X text 450 432 highest possible number (~ 188 minutes at 44100 khz)
, f 30;
#X text 429 409 lowest possible number (1 sample);
#X msg 717 172 read \$1;
#X obj 717 150 symbol;
#X text 167 646 <- length in milliseconds;
#X text 684 388 length in milliseconds;
#X text 728 222 samples / samplerate;
#X text 140 623 samples / samplerate;
#X text 280 20 load soundfile to calculate its length;
#X text 51 33 slower but vanilla:;
#X text 714 68 faster but needs [iemlib]:;
#X text 396 595 calc duration;
#X text 754 322 calc duration;
#X text 431 326 for some strange reason \, the samplerate has to be
calculated seperatedly first \, or else it doesn't arrive in time for
the final length calculation ..., f 32;
#X floatatom 98 589 10 0 0 0 - - -, f 10;
#X connect 2 0 6 0;
#X connect 4 0 42 0;
#X connect 4 1 5 1;
#X connect 4 1 9 1;
#X connect 5 0 11 0;
#X connect 6 0 5 0;
#X connect 6 1 9 0;
#X connect 7 0 8 1;
#X connect 7 0 14 1;
#X connect 8 0 28 0;
#X connect 9 0 12 0;
#X connect 10 0 28 0;
#X connect 11 0 8 0;
#X connect 11 1 10 1;
#X connect 12 0 10 0;
#X connect 12 1 8 1;
#X connect 13 0 15 0;
#X connect 13 1 14 1;
#X connect 13 2 14 0;
#X connect 13 2 16 1;
#X connect 14 0 15 1;
#X connect 14 0 17 0;
#X connect 15 0 4 0;
#X connect 16 0 67 0;
#X connect 17 0 16 0;
#X connect 17 0 20 1;
#X connect 19 0 35 0;
#X connect 20 0 18 0;
#X connect 21 0 56 0;
#X connect 21 1 23 0;
#X connect 23 0 22 0;
#X connect 24 0 23 1;
#X connect 25 0 21 0;
#X connect 28 0 33 0;
#X connect 28 1 29 0;
#X connect 29 0 30 0;
#X connect 30 0 31 0;
#X connect 31 0 32 1;
#X connect 32 0 13 0;
#X connect 33 0 32 0;
#X connect 34 0 38 0;
#X connect 35 0 36 0;
#X connect 36 0 27 0;
#X connect 36 0 24 0;
#X connect 37 1 34 0;
#X connect 38 0 45 0;
#X connect 38 1 7 0;
#X connect 38 1 20 0;
#X connect 38 2 43 1;
#X connect 38 2 44 0;
#X connect 39 0 37 0;
#X connect 40 0 2 0;
#X connect 41 0 39 0;
#X connect 41 1 42 1;
#X connect 42 0 40 0;
#X connect 43 0 26 0;
#X connect 45 0 4 0;
#X connect 46 0 51 0;
#X connect 47 0 46 0;
#X connect 48 0 49 0;
#X connect 49 0 41 0;
#X connect 50 0 49 0;
#X connect 50 1 52 0;
#X connect 51 0 50 0;
#X connect 51 0 56 1;
#X connect 52 0 48 0;
#X connect 55 0 19 0;
#X connect 56 0 55 0;
#X connect 67 0 43 0;
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list

Reply via email to