Trying to play a random sample from a selection of 8+
So I'm working on a sampler where each button on a Wii Remote accesses a different bank of eight samples (32 in total). I'm trying to have it so that if I press Up, say, then it'll play a random sample from the eight that it can access. The problem is, I can't really work out how to do this. I've got a simple (and unimpressive) patch, but I'm almost certain I'm going about it the wrong way. Do I need to have 32 different buffers? Or is there a more efficient way I can do this? I've got a list of what I want the patch to do:
Bank of samples e.g. four groups of eight (1-32). Assigned to D-Pad on remote.
Bank A: Up. Plays random sample from 1-8
Bank B: Right. Plays random sample from 9-16
Bank C: Down. Plays random sample from 17-24
Bank D: Left. Plays random sample from 25-32
Best way to do this? Series of buffer~/groove~ objects into random selector?
A Button: Play/Pause
B Button: Reverse/Forwards?
Pitch: Pitch shift.
Roll: Sample Rate 0-1 -1-0
Second remote - Live sampling. Record live instruments into buffer(s). Store samples, have some kind of system of scrolling through them, playing and selecting what part of sample to play. Adjustable sample rate + fx?
And here's the patch I have so far:
Can anyone help? Been stuck on this for a fair while.
you need [polybuffer~] and [poly~]
inside the [poly~] use a [groove~] or [play~]
mastering these objects now will seriously seriously pay off in the future
if you are into this sort of thing
Thanks pid. Going to have a bash with poly~, but I'm guessing polybuffer~ is only in Max 6?
The polybuffer~ method is the most versatile, but you could also do it with four sfplay~ objects and one sflist~ object that's preloaded with 32 different cues.
I've tried that quickly with one sfplay~ and eight cues, although some of the files won't play. The Max window says "sfplay~ no open file". Why does it do that for some of the files and not others? Here's that specific part:
I'm thinking though that poly~ or polybuffer~ (is it a Max 6 object or an external?) will probably be better in the long run in terms of changing the sample rates etc. as the samples are playing?
There are a couple bugs in your patch.
1) Your "open test1.wav" message is connected to the wrong object. That's the cause of the "no open file" errors. When you give the sfplay~ a "1" message, it finds no open file.
2) You should add 2 to the random numbers, not 1. As it is, you're never playing cue 9, and you're playing "test1.wav" with both cues 1 and 2 (or would be if you opened the file correctly).
3) You don't really need the prepend object, because the sfplay~ is already associated with the sflist test because of its argument.
So, assuming your soundfiles all exist and are findable by Max, this should work:
That works like a charm, thanks Christopher! I have a couple of questions though.
On the patch, why are test2.wav and test8.wav both 'preload 3'? Also, I don't quite understand why I need to add 2 instead of 1.
Hi
I'm unable to view your patch as I'm not on my Max machine at the moment but..
take a look at the [sfplay~] helpfile; I believe this is because you are both opening and preloading files, so your 'second' file is preload or cue #2; there is no such thing as preload #1.
?
Brendan
ps keen to see your finished patch :)
@PhilSMaguire: Sorry, that's just a typo on my part. The last "preload 3" should be "preload 9". Doh!
n00b_meister is correct in pointing out that the 'open' message assigns a soundfile to cue 1, and the 'preload' message is only for cues 2 and greater. In my example, I chose just to ignore cue 1, and assign all 8 files to cues 2 through 9 the way you had done, so there's no need to use cue 1. Thus, by adding 2 to all your random numbers, you'll get numbers 2 through 9 which can be used directly as the cue numbers.
Ah, I see! Awesome :) Got part of it working close to how I want now. Hopefully have a rough version finished this week! Thanks for the help guys, I'll shout if I get stuck again.
Phil.
So all I did just now was change the files in the 'preload' message boxes, and I'm getting error messages. The first I get is that "test" on the sflist~ test object is already taken, and the second is that sflist~ test3 has 'no cue'. I don't understand what that means, or how I did it in the first place? Nothing is playing on sflist~ test, and only a few files are playing on sflist~ test3. All of the sound files are in the search path of the patch. The old ones are where they always have been, and the new ones are also in that folder.