Multiple Stereo Files to Mono

Hi all,

I’ve loaded a folder full of stereo files into separate buffers using

~fileSamples = SoundFile.collectIntoBuffers("/Users/...*", s);

However, I would like all these buffers to be mono. I know there is a readChannel method like this:

b = Buffer.readChannel(s, pathToAudioFile, channels: [3]);

But I don’t know how to iterate ~fileSamples into Buffer.readChannel.
Any tips appreciated!

Many thanks!


I’m using this strategy to iterate over a bunch of directories and shove them into appropriately named dictionaries:
First, I wrote an extension to the SoundFile class in order to load only one channel from a file:

+ SoundFile {
    *collectIntoBuffersMono { | path = "sounds/*", server |
        server = server ?? { Server.default };
        if (server.serverRunning) {
            .collect { | sf |
                Buffer(server, sf.numFrames, 1)
                .allocReadChannel(sf.path, channels: [0])
        } {
            "the server must be running to collect soundfiles into buffers".error

Next, I call it from the project like this:

var bufCount=0;
~buf =;
    ~buf[folder.folderName.asSymbol] = SoundFile.collectIntoBuffersMono(folder.asAbsolutePath+/+"*");
    bufCount = bufCount + 1; 
"% folders loaded\n".postf(bufCount);

Hope this’ll give you some ideas to work with!

Edit: just a bit of background for using SoundFile: when working with a large number of files (more than 700 or so) I found loading with other methods a bit hit and miss. SoundFile has worked consistently for me for a long time now, without ever missing any files, having to insert s.sync into the mix, or having to split the loading process into several batches.