Storing samples inside "buffer~" object

SonOfAGlitch's icon

Hi all,
I'm working on a patch that includes "buffer~" and "groove~" objects to playback samples.
My goal is to store one sample into a specific "buffer~", so that whenever I open the patch the sample is already inside the corresponding "buffer~".
I tried two ways:
1. sending a ["loadmess" object + read + exact name of the sample] into the inlet of each "buffer~"
2. sending a message to "buffer~" stating [read + exact name of the sample]
Both ways didn't lead to positive results.
Can anybody spot the reason why it doesn't work?
Thanks :)

Jean-Francois Charles's icon

Any error message in your Max console when you use the "read" message?
If you give just the file name, then the file needs to be in the same folder as your patch (or in your search path).
Once this is solved, consider using the 'replace' message instead of 'read' (see the difference in the help file and/or Reference).

SonOfAGlitch's icon

Hey Jean-Fançois,
thank you for your answer, it got me closer to the solution;

1. I get what I want by placing the sample and the patch in the same exact folder - it works both with [read + sample name] and [loadmess + read + sample name] -. *

2. the problem is that I don't want to keep the patch and the samples together due to the high amount of samples (wanna keep everything tidy). Therefore I tried by following this guide in the Help Documentation.
I managed to add the folder containing the two subfolders that host the patch and the samples (separated) to "File Prefernces" and marked the column on the right; however, in this case the "buffer~" cannot read the sample. I also tried sending a ["replace" message + sample name] without positive results.

*I found out that step 1 only works on the new patch that I've created to try out. This method still doesn't work on the official patch!
The Max Console keeps saying "FX - can't open"; the weird thing is that FX is only a small part of the full sample name (FX - HH 1.wav). I tryed by removing the spaces in between the characters but nothing seems to change.

Do you have any clue?

Roman Thilenius's icon


if there is no error message, maybe it simply could not be opened because you call too many at once.

loadbang -> file in/out can fail easily from the disk beeing slower than required when you call to open 20 files at once.

loadbang
t b b b b
del 100 del 200
defer defer
"read ... " "read ... "

is fishy code, but at least stands in practice.

if the samples are always the same, you could also write those into a single file - and eventually even use a single buffer.

SonOfAGlitch's icon

There is an error, saying "FX can't open".
Also, it can't be overloaded beacuse I tried it out with only one sample and it doesn't work.
No worries thanks for your help; I'll store all the samples in the same folder of the patch and make it work that way :)

Source Audio's icon

You are not providing exact details about loading the samples.
You are probably making some simple mistake, but without details, no one can help you with that stuff
check object filepath search help file.

P.S. and dn't forget that once you try to make max standalone app , all would change again, so only reliable solution at least for me are absolute paths

SonOfAGlitch's icon

I have read a bit on the internet about this file path but somehow I can't manage to get it working.
First of all, I have tried moving the folder storing the samples into "/Documents/Max8" folder, as the documentation about the "search Patch" suggests. However, the buffer can't load the sample when receiving a message stating [read + exact sample name].
At this point, I have tried to insert the folder storing the samples inside the File Preferences. Following this guide and other posts on this forum, I proceeded in the following order:
1. open the "Options" menu
2. select "File Preferences"
3. add folder + select the correct folder
4. give it a name tag
This method doesn't work either.
This is the basics of the patch (simply reading the sample within the buffer)

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


Source Audio's icon

if that is what you are really implementing in you patch,
then despite any possible search path problems,
main mistake is to NOT enclose file name with quotation marks

read FX - HH 1.wav
must be
read "FX - HH 1.wav"
------
Then you can go and solve your path problems.

SonOfAGlitch's icon

It worked! Thank you very much for your help :)
I'll recap briefly for those who're gonna need an answer in the future:
1. add the sample folder to "/Documents/Max8" folder in your computer
2. add the sample folder to your file preferences; first open the "Option" window, second open "File Preferences". Then select add + choose folder
3. when writing the argument of the read message, type quotation marks around the sample name e.g. "FX - HH 1.wav" istead of FX - HH 1.wav
4. Have fun!

Source Audio's icon

Glad that you are happy with the result, just to avoid confusion :
only if there are spaces in file name or path one needs to enclose it with quotation marks.
Same can be done by inserting tosymbol, between message and read $1.

Path to files and folders ...
That is interesting topic, and there are many options.
I trust only absolute path to read or write files in Standalones.
If you know exactly where the Samples folder will be, that you can combine
path with file names to create absolute path to each file.
I you prefer to use only file names and trust App to find them
than try filepath search to add it to Standalone paths, but it will not work immediately,
only after first relaunch, when stored path preferences get read in and get active.
There are numerous other options to deal with such things, depending where you want
to place Folders and Files to look for.
One option being in same folder as App itself (or patch while developling)
where you need to combine path to patch or path to app itself with Folder Name and then file names.
Great for portability - you provide folder with app, all media needed etc,
and don't need to bother where user places it.
Or if you prefer some user folder like Documents, in which case you get absolute path using
for example gestalt to report user name and so path to documents folder

Jean-Francois Charles's icon

Another idea is drag & drop your sound folder onto umenu:

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