attached is a tcl scripting example for reading a soundfile from a directory in shuffle mode by selecting first characters

Le 12/02/2016 17:15, Claude Heiland-Allen a écrit :
On 12/02/16 16:04, Alexandros Drymonitis wrote:
[readsf~] outputs a bang out its right outlet when the current sample it's playing has finished. You can send that bang to [random] (the argument of which will be the number of your samples) and the output of [random] to a
message [open ./samples/P$1.wav, 1(
I don't think that you can use 01, 02, etc., but 1, 2, etc. If you really
want to name your samples like that, your message could be [open
./samples/P0$1.wav, 1(, but any sample greater than 9 would have to be
named P010.wav. There should be a work around that though.

Easiest to have files that are named with numbers rather than a number plus some extra sample-specific name. Otherwise you really do need a way to get a list of existing filenames into Pd somehow, either by a text file that you prepare beforehand, or a more complicated system with externals.

For leading 0 with fixed number of digits (here 2):

[nbx\
 |
[makefilename P%02d.wav]
 |
[open $1, 1(

In this example there's a directory called "samples" in the directory of
the patch.

On Fri, Feb 12, 2016 at 5:31 PM, Pagano, Patrick <[email protected]>
wrote:

​you need a folder playlist object attached to a file player

i suggest the browser/folder from the MTL abstractions and the player~
external from Eric lyon Potpourri




*Patrick Pagano B.S, M.F.A*
Audio and Projection Design Faculty
Digital Worlds Institute
University of Florida, USA
(352)294-2020
------------------------------
*From:* Pd-list <[email protected]> on behalf of Spyros
Polychronopoulos <[email protected]>
*Sent:* Thursday, February 11, 2016 6:50 PM
*To:* [email protected]
*Subject:* [PD] loading random samples

Hi list,

I have a question if you could enlighten me:

I would like to make a patch that loads randomly a sample from a folder
(if I can make it open randomly any file begging with P01 ie. P01*.wav) and
when the sample ends loads automatically another sample randomly (ie.
P02*.wav).

thank you in advance
--
Spyros Polychronopoulos
Music Composer / BSc / PhD
www.spyweirdos.com

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





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



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

#N canvas 494 189 885 373 10;
#X obj 88 208 r ranFile;
#X obj 88 235 print;
#X obj 435 245 sys_gui;
#X obj 435 216 r sys_gui;
#X msg 72 112 \; sys_gui set wav_dir [tk_chooseDirectory];
#X obj 72 87 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
-1;
#X obj 217 155 r ranFile;
#X obj 218 316 readsf~ 2 1e+06;
#X obj 218 338 dac~;
#X msg 218 241 open \$1 0 0 2 2 b \, 1;
#X text 68 65 choose directory;
#X text 439 13 choose extension to be played;
#X obj 217 177 route aif wav;
#X text 67 13 play a stereo soundfile randomly from a directory with
tcl scripting using [hc/sys_gui];
#X obj 446 64 list append wav;
#X msg 572 42 aif;
#X msg 486 37 P01;
#X msg 445 37 a;
#X msg 439 89 \; sys_gui set l [glob -nocomplain -directory $wav_dir
\$1*.\$2] \, if [expr [llength $l] > 0] [list pdsend [list ranFile
\$2 symbol [lindex $l [expr int(floor(rand()*[llength $l]))]]]];
#X connect 0 0 1 0;
#X connect 3 0 2 0;
#X connect 5 0 4 0;
#X connect 6 0 12 0;
#X connect 7 0 8 0;
#X connect 7 1 8 1;
#X connect 9 0 7 0;
#X connect 12 0 9 0;
#X connect 12 1 9 0;
#X connect 14 0 18 0;
#X connect 15 0 14 1;
#X connect 16 0 14 0;
#X connect 17 0 14 0;
_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to