Play items from [umenu]?

123ndy's icon

Hi,

I am relatively new to MaxMSP. Im trying to make a patch that plays random files from a folder.
So I am using a [opendialog fold] to [folder] to [umenu], but how do I play the files from the [umenu]?

Regards 123ndy

Tim Lloyd's icon
Max Patch
Copy patch and select New From Clipboard in Max.

My first thought is to store all the filenames into a [coll ], then you could send a random index number to coll to output the path of the chosen file into [sfplay~ ] (or just send a random number to umenu to spit out the filename for sfplay~). One problem is that [sfplay~ ] probably won't be able to load and play the file immediately, so you may have to plan for some "lag". But you could work around this, it shouldn't be a big issue. You'll also have to set the search path of the patch to include the selected folder, otherwise [sfplay~] won't be able to load the files. Something like this might help with that:

Another option is to load all the files into buffers (for playback via groove~), it would avoid the potential loading time lag problem, but would take up loads more RAM.

pdelges's icon

< blockquote>One problem is that [sfplay~ ] probably won't be able to load and play the file immediately< /blockquote>

That's why there is a preload method.

Beside the RAM waste, using a buffer won't work well with long sounds (there are plenty of post on this topic), you'll then need to use hr. objects.

123ndy's icon

Thanks for answers, but...

(or just send a random number to umenu to spit out the filename for sfplay~).

How do I do this? How do I play a file directly from umenu trough sfplay? (do umenu need to consist of the whole path of the file, or just the file name.aiff/wav etc?)

Samuel Freeman's icon
Max Patch
Copy patch and select New From Clipboard in Max.

perhaps prefix + autopopulate method of umenu will help here:

123ndy's icon

Thanks! It was exactly what I was looking for :)
But why do you use route and autopopulate?

I got one more question, how do I make another sound start 10 seconds before the other sound ends?

Edmond Dowl's icon

How could i send the selected audio file to the buffer? I try to send the sfplay tilda to a record tilda but it does not seems to work!

Simons's icon

thanks Samuel Freedman, from 6 years in the future.
I spent most of today looking for that answer, how to auto populate umenu with a folder of samples.