How to use sflist~ with sfplay~ (+preload/cues)

Dec 22, 2009 at 9:12am

How to use sflist~ with sfplay~ (+preload/cues)

I am using buffer & play for my short files and for rhythmic things where timing is mucho important.

But i also have some long blobs of sound i want to trigger with sfplay~ I know that you can improve timing by preloading files, etc. that you can also use cues (2 through 9 only?)

But just using preload and the cues is pretty limited if you have a bunch of files. So my impression is that sflist~ is meant to address this, essentially (somehow) you can have “banks” of preloaded sounds (?) or do i misunderstand that?

Anyway… I have a bunch of sound file “families”, separated into directories and I want to be able to play from one list for a while, and then switch and play from another list for a while, etc. So maybe i have 15 sound cues to play for the first 5 minutes and then i have 15 different cues for the end of the piece, etc.

I think that this is what sflist~ is for… but i can’t quite get my head around it.

I think that the cues can be triggered with the numbers 2-9… (0 and 1 are reserved) … what if you have more than 7 files to preload/cue?

Does anyone have an example that illustrated the use of sflist~ with sfplay~ & cues/preload? Toot 16 doesn’t seem to cover it.

#47344
Dec 22, 2009 at 7:52pm
– Pasted Max Patch, click to expand. –
#170381
Dec 23, 2009 at 12:39am

Oh. I thought it was just 9 because they were tied to the number keys.

Then what exactly is sflist~ for?

#170383
Dec 23, 2009 at 8:25am

Here is the first sentence of sflist~.maxhelp:
sflist~ stores a list of preloaded cues for sound files that can be accessed by multiple sfplay~ objects.

Note that you can change the playlist sfplay~ with the set message.

#170384
Dec 23, 2009 at 9:45am

yes but *how* it stored a list of preloaded clues (and how sfplay~ accessed them and how this was different than just using open and preload) was not obvious to me. I figured it out by just hacking at stuff and hitting buttons and looking at the refs for both objects. The key is what you have there in bold (which was in the sfplay~ docs actually) that it can be accessed by multiple named sfplay~ objects (and through set). You now send the open and preload messages to the named sflist~ (not sfplay~ as you ordinarily would) and then set for sfplay~, or name set the arg (which got tripped up on as i had the args wrong)

(open foo.aif) & (preload 2 foo.aif) –> [sflist~ foobar1]

[sfplay~ foobar1] *alternately, as you note, you can set the playlist for sfplay with set

I was confused about how this worked and example in a single patcher or as part of the toots would have made it a tad clearer but I got it now.

#170385
Dec 23, 2009 at 10:12am

(open foo.aif) & (preload 2 foo.aif) –> [sflist~ foobar1]

You don’t need the open message if you give the file name as argument in the preload message.
open is usefull to set the current file and/or if you need to define several cues (with several preload) within the same sound file.

I figured it out by just hacking at stuff and hitting buttons and looking at the refs for both objects

This is the best way to learn Max/MSP!

p

#170386
Dec 23, 2009 at 10:21am

I did not know that. I am not playing parts of files only triggering the whole thing. So i disconnected the open message and low and behold it did still play. That is great as it makes the patch much smaller.

I am loading a bunch of cues to sflist~ and the message box is HUGE. So at least i could get rid of the open message which cuts that in half.

thanks

#170387
Dec 23, 2009 at 10:31am

If you have a lot of files to load, I suggest you to use a coll with all preload messages, and then dump it.

– Pasted Max Patch, click to expand. –

The coll file looks like this:

2, preload 2 luo001-a001-b01l.aif;
3, preload 3 luo002-a001-b02l.aif;
4, preload 4 luo003-a002-a01l.aif;
5, preload 5 luo004-a002-a02l.aif;
6, preload 6 luo005-a002-b03l.aif;
7, preload 7 luo006-a002-b04l.aif;
8, preload 8 luo007-a002-b05r.aif;
9, preload 9 luo008-a002-b06l.aif;
10, preload 10 luo009-a003-a01l.aif;
11, preload 11 luo010-a003-b02l.aif;
12, preload 12 luo011-a003-b03r.aif;

The good thing with coll files is that they are abstracted from the patch, so you can change the cues without changing the patch (or the standalone).

If you don’t define cues with start/stop time, if all files are in the same folder, it is quite easy under OSX to create this coll file automatically. Using folder is also an option.

p

#170388
Dec 23, 2009 at 1:01pm

Yeah I thought about something like that. That is awesome. I can prolly whip up a shell script to generate the coll, then when i generate more soundfiles it is a snap to reuse use the same patch with different sources or even load and swap multiple colls on the fly.

Or i could even do the script in max somehow i bet. …. i’d have to think on that…. I have something like that for buffers (using a CNMAT object) … but not yet for sfplay~

thanks~

#170389
Dec 23, 2009 at 2:08pm

Here is some dirty perl code I did years ago:



#!/usr/bin/perl

$currentDir =  pwd;
chop ($currentDir);

open(FILE, '>' .$ENV{HOME}.'/preloadFile.txt') or die "cannot create file";

#$ENV{HOME}

print "Reading directory " . $currentDir . " and saving the [coll] file to ". $ENV{HOME} . ".n";

$i = 2;	# first index

@filenames = ls;

foreach $filename (@filenames)
{
	chomp($filename);
	printf FILE $i .", " . "preload " . $i . " " . $filename . " ;n ";
	$i++;
	}

close (FILE);

print "Done.n";

p

#170390
Dec 23, 2009 at 3:53pm

yeah i do the same thing in python (quick and dirty):

import os

count = 2 # 0 & 1 are reserved
pth1 = ‘/Users/kp8/snd/01/flutter’
samples = [os.path.join(pth1, f) for f in os.listdir(pth1) if f.endswith('.aif')]
for item in samples:
print count, ‘,’ ‘ preload’, count, item, ‘;’
count = count+1

#170391
Dec 23, 2009 at 5:48pm

Here is a simple solution that I use with my students all the time. We use umenu to construct the list of all the sound file in a subfolder (relative to the patch), and store the name of the sounds in a coll. Then to play the sound file we just need to set the name of the sound file which is converted into the cue number by the coll object.

– Pasted Max Patch, click to expand. –
#170392
Dec 23, 2009 at 6:43pm

Emmanuel,

Thanks for posting that. There is a huge benefit, of course, to doing it all completely from within max/msp. That is very handy indeed. Thanks!

what are the message boxes up top for? (the ones that say play mysg.aiff)?

cheers

-kp–

#170393
Dec 23, 2009 at 10:21pm

basically this is the message to start to play the sound file called mysf.aiff. Instead of asking sfplay~ to play a specific cue number (which might change if you add a sound file to the directory) you specify it by sending the name of the sound file and use the coll object to convert the name into the cue which corresponds to that sound file.

#170394

You must be logged in to reply to this topic.