Multiples audio files loading in RNBO

Mathieu LENGAGNE's icon

polyrythm.maxpat
Max Patch

Hello !

I'm trying to recreate the patcher below in RNBO. It's basically a drum sequencer with conditional triggering, but it uses polybuffer~ to trigger random sounds from a loaded folder of any length . I use this patch a lot, so it makes sense for me to try to send this one first to RNBO world, as I would love to have it in hardware version with Raspeberry Pi. I am a huge noob with RNBO.

I looked at the Exp Polyphony Drum Sampler here : https://rnbo.cycling74.com/explore/exp-polyphony-drum-sampler that does almost the same thing, but it seems to be setup for only six files and uses a polybuffer from the Max patcher which, if I'm not mistaking, will no be available once I export my patch to a VST or AU target for example. Is there a way to say to the export target : load a folder, and make a list with all the files paths in it, and then use those paths to dynamically change the buffers content ?

Also, I tried to export the Exp Polyphony Drum Sampler to AU in order to test it with Logic Pro but even if it's properly installed and recognized by Logic I cannot load it. Is this due to sample depencies ?

Thanks a lot for you time :)
Have a nice day

Mathieu LENGAGNE's icon

Little up post, cause I'm still struggling with finding a good solution for that type of process in RNBO.

Alex Norman's icon

Hi Mathieu,

We don't yet have this feature but I think it could be valuable to many people so I've put in a feature request to track it, though I don't have any sort of timeline to give you for this.

In the mean time, maybe you could write a script that concatenates all your files in each directory into a single file where each chunk is the same length, then after you load you can simply use offsets within the buffer to select the individual pieces?

Mathieu LENGAGNE's icon

Hi Alex,

Thanks a lot for you response and for taking the time to put a feature request.

Unfortunately I'm really bad with codebox, as my coding knowledge is very limited but I will ask around me and try this solution!

I asked Chatgpt to make one, just for fun. He gave me that :

#include <iostream>

#include <fstream>

#include <vector>

#include <string>

#include <filesystem>

namespace fs = std::filesystem;

void concatenateAudioFiles(const std::string& folderPath) {

std::vector<std::ifstream> audioStreams;

for (const auto& entry : fs::directory_iterator(folderPath)) {

const std::string filePath = entry.path().string();

const std::string fileExtension = entry.path().extension().string();

if (fileExtension == ".mp3" || fileExtension == ".wav" || fileExtension == ".flac" || fileExtension == ".aiff") {

audioStreams.emplace_back(filePath, std::ios::binary);

}

}

std::ofstream outputFile(folderPath + "/concatenated_audio.mp3", std::ios::binary);

for (const auto& audioStream : audioStreams) {

outputFile << audioStream.rdbuf();

}

std::cout << "Concatenated audio file saved at: " << folderPath + "/concatenated_audio.mp3" << std::endl;

}

int main() {

std::string folderPath;

std::cout << "Enter the folder path containing audio files: ";

std::getline(std::cin, folderPath);

concatenateAudioFiles(folderPath);

return 0;

}

Could that work?

For now I will do a version with fixed buffers and limited audio files.

Thanks again

Mathieu

Alex Norman's icon

that will not work, audio data cannot simply be concatenated like that without being decoded and then re-encoded.

dwingus's icon

Any updates on dynamically loading many sound files in RNBO? It is a real need for sample based improvisation, etc. Hand coding each filename into its own buffer remains quite tedious! I was really hoping this would be addressed in Max 9. Hopefully I missed it. Thanks!

Mathieu LENGAGNE's icon

Yes indeed this is something I am very much hoping for ! I'm sure there is some kind of workaround in C, but I'm too bad with it to find it.