Random sound file players

Eardrum Nibbler's icon

Hello,

I am a big Brian Eno fan.

I therefore enjoy experimenting with probability and random sequencers.

I mostly work in Ableton and try to create structured chaos there.

I saw an interview with Brian Eno on YouTube where he used an app to play 3 or 4 randomly selected files together from a folder of sound files.

These sound files were organized by the scale in which they were created, so that they matched musically when played together.

So, I would like to create something myself using Max MSP where I could execute the same principle as described above.

What are the functions of the Patch I want to create:

- 3 or 4 sound file players

- These players share a common start and stop knob

- Each player is assigned to a file folder from which it randomly selects a sound file and starts playing it. - When a file finishes, the player randomly selects another sound file from the assigned folder and plays it.

- I would also like to see the name of the sound file that each player is currently playing, as well as the "filepath" where this file can be found.

- If a really nice combination of files were to arise while playing the random files, I would like a function where, with the press of a single button, the filename and "filepath" of the sound files currently playing are saved so that I can play them together again later or import them into a DAW to create a song.

I am fairly new to programming patches myself.

I have already discovered the "Sf Play" module, which I believe could be the appropriate sound file player.

But that is where my knowledge ends.

The following problems/questions come to mind:

- How do I assign a folder containing sound files to the "sf play" module?

- How do I make it select a random file from the assigned folder and play it? -At the end of the file, how do I ensure that "Sf Play" immediately starts playing another random file from the folder?

-How can I ensure that I can always see the filepath of the file being played, as well as the file name?

-How can I save the current files with a single button press to play them again later? (Perhaps a list of these could be created?)

As you can see, a lot of questions/problems…

Who can or wants to help me further with this?

Once I am finished with the patch, I will gladly share it with the community!

Let me know!

Kind regards,

Jeroen

Source Audio's icon

I posted this example to answer ever-repeating similar question a while ago

Max Patch
Copy patch and select New From Clipboard in Max.

you can extend it to as many play instances as you want.

just connect new instances exactly as first 2.

4 file paths are collected , you need to decide

what kind of storage you want,

how many presets, should a preset verify if recalled file exists,

if you want also to store folder paths ?

and many other questios you will face once you get this partly running.

if you want that players run through folders without playing repetitions,

replace random with urn, but reset urn after all files had been played once.

Eardrum Nibbler's icon

Hello,

I just opened the patch, this is exactly what I was looking for.

A nice foundation to learn from and develop further.

As you indicated, there will be quite a few questions and decisions along the way.

If I get stuck, I will let you know ;-)

Thanks in advance!

Kind regards

Jeroen

Source Audio's icon

You are welcome.

Max is not easy to start with, there are so many objects and

functions inside, which makes traditional way of learning something

not so cool.

One wants to get something up and running immediatelly,

simply because it is possible.

Don't hesitate to ask before you loose too much time trying to

check which objects could do this or the other thing for you.

More important is to have a clear idea about what you want,

then it is easy to help.

Eardrum Nibbler's icon

Hello,

I have already developed the base patch into a patch with 4 random file players.

Random File Player 0-004.maxpat
Max Patch

During the process, a few questions came to mind.

-Is it possible to add the selection for which I save the filepaths to a sort of playlist where I can listen to the combinations of files I have saved at a later time? Perhaps using a Umenu where I have a preset for each saved combination. And a play button to start the selected preset and stops the 4 random fileplayers.

-Is it possible to save the audio files from a preset together in another location with the press of a button, making it easier to import them into a DAW? Something like "save to this map"

Kind regards

Jeroen

Source Audio's icon

to store lists of 4 current files should be no problem.

but as files do not start at same time,

(unless they are all exactly same length)

what you'll hear when you start all 4 at same time

could differ from playing positions that you had when storing the list.

If that is important, one could also store that into presets.

Umenu could be ok to look at files,

but to store paths you need something else,

something that can export filepaths as plain text .

What would be handy for you in terms of selecting files from the list

and importing that into your DAW ?

I ask because there are many ways of storing something like that.

To copy audio files from one location to another

will need some extra work, and that depends on which system you work,

mac or windows.

Eardrum Nibbler's icon

The files saved as presets may simply be played from the beginning of the file, even if the files have different lengths.

What can I use to save presets of the file paths?

Can I control the presets in the "filepath list" with a Umenu?

In my opinion, this seems practical as a User Interface Object.

I work on a Windows computer.

Source Audio's icon

It is not a problem to place a list with presets into umenu,

but it would be unpractical to show that long paths in one line.

one could reduce paths to file names for display, or simply number the presets.

more of a question is how do you read one preset outside of Max,

in order to use one of many collected presets in some DAW ?

Also if you copy 4 files into one folder, what should prevent you to

copy more files in there, and so loose relation one folder = 4 files, all clear.

As you see it is more a logical question, when you have a clear idea,

it will be easy to get it done.

to resume - you can store many presets (4 file paths) into

some of max object ( pattr, coll,preset, dict ...)

and store that as single external file.

Or you store each preset into one text document in dedicated Presets folder.

in both options, you can either show presets from one file,

or list collected text files in umenu and pick them in Max for playback.

But you would need to extract 4 file paths without Max in order to use them in another DAW.

it is up to you to decide.

Eardrum Nibbler's icon
Hello,

I had also noticed that the filepath is a bit long to use as a preset name.
This can easily be a number in a Umenu.
In the list, I think the track name is sufficient; it doesn't need to be the full filepath.

For saving the 4 files in a folder, a folder per preset seems like the best solution to me. Perhaps it could be an option to name the folder after the preset name that corresponds to the Umenu.

For saving the presets, it might be useful to have one text file containing all the presets. That way, I have an overview of all created presets.

And for playback, it can be saved in a Umenu to start the presets from there.
I don't know if both options are necessary or if the Umenu alone is sufficient.

To add the 4 files to a DAW, I suggest simply copying the relevant tracks into a folder separately.
Or is this pointless or overkill?
Source Audio's icon

No, nothing is overkill.

As you have potentially 4 audio file names, one can not use all to name a preset.

definitelly not if they are names like that:

"Bass loop 4 (128bpm).wav" "Crash 2.wav" "Synth loop 6 (128bpm).wav" "808 hho 6.wav"

With preset name I mean something that makes it selectable for recalling.

when you hit store preset one could open dialog to give it a name,

or use something automatic, like adding a timestamp.

like 120626-170422 which is date and time now.

naming a preset can be a bit of a problem if name allready exists,

using only a number to recall a preset is maybe not informative enough

to pick a preset for whatever reason.

Umenu is ok to display something, but not to store something.

And you have to store 4 full paths , otherwise no way to recall the files.

I am not yet sure what is best option, must give it a thought.

Also copying of that 4 files , do you want to do that every time you store a preset ?

If yes, then one could create a folder having preset name, copy files in there

and only use a folder as loader for 4 files.

all added folders could populate umenu with their names for recalling.

there would be no need for presets file.

........

now something else - you must wipe all traces of loaded folders and files when storing the patch.

otherwise you have leftovers , paths which maybe don't exist any more.

Also if you recall a preset.

maybe you have 4 files playing and recall next preset with only 2 audio files.

so you need to stop all playback, remove files from sfplayers

using fclose message, then load new preset.

and all that with fades to avoid clicks.

next thing: you added playbar to 4 players, which have own play, pause, stop, jump

loop etc functions.

and want also master play, stop and also loop .

if players loop they can't select next file.

did you think about that ?

Eardrum Nibbler's icon

To me, it might be interesting to add the timestamp when saving a preset.

Or the combination of the timestamp and a self-chosen name, to which one could perhaps convey the atmosphere. E.g.: "Dark Melodic + timestamp" "Dreamy + timestamp"

This could make the process of listening to/searching for it again later much more practical.

Regarding copying the 4 files, I just realized that this should perhaps be an extra option that can be done with the press of a button. So that files are only copied when one is actually going to continue working with them, and thus use less disk space.

So if I understand correctly, every time I save the patch, I first have to remove all paths from sfplay with the "fclose" message?

How can I add the fades when I press stop or save?

I only added the 4 playbars as a test. Just to see where the file is located in its total length.

I would use the loop function when I feel that a few files might have the potential to form a preset together.

Or perhaps two of the four files that have potential, and let the other two players run, playing random new files until a nice new combination presents itself. Then, one could potentially put the next player into the loop as well.

When I have a global loop, this could perhaps be used to listen to which files really fit together when I find a nice combination. There might be one file in there that doesn't belong, but one cannot tell at first glance which file it is. Using the fader, one can select the file that one does not want included. Then the player in question can be taken out of the loop again and can continue playing random files in search of a nice new combination together with the players already placed in the loop.

I really appreciate sharing thoughts and ideas in this way!

Source Audio's icon

to wipe leftovers- it is not sfplayers - they don't remember anything.

it is umenus and prefix for umenus.

that is the message clear, prefix >none>

doing that before saving the patch leaves it clean.

But maybe you want to store paths to 4 folders ?

To be able to reuse them when you start the patch next time ?

sfplayers need to be cleared when loading a preset that has less files populated then 4.

otherwise you will have a file playing that has nothing to do with that preset.

that brings another question:

are there going to be any slots that are not loaded ?

probably not, unless you don't populate all umenus.

Whatever is seen in 4 umenus gets stored into preset, no matter if files play or not.

Unless you also store play status, loop status, play position etc into a preset.

which I understand you don't want to.

next question, what do you do with 4 populated menus when you load a preset

listing 4 files that have nothing to do with loaded folders ?

how do you play them, do they remove loaded folder paths ?

how should they interact with random auto-netxt file play ?

maybe use 4 separate players for that, and simply stop 4 players with the menus ?

you have so many things to decide before one starts to construct the patch.

applying fades to stop is done by fading out the output and then stop.

length of fade might depend on material, but minimum 5-10ms.

you dont need a fade-in in normal cases, only if audio fies have

clicky start.