Building a sampler, but problems arise...

3 replies [Last post]
newmiracle's picture
newmiracle
Offline
Joined: 02/02/2010
Building a sampler, but problems arise...

So I'm building a sampler.  Nothing fancy, just bare bones.  I've starting going through the Max tutorials and I've whipped something up.  What I needed was a sampler that had a 'toggle' function.  Send a note to start the sample, send another to stop it.
 
My dream is to put this device inside the Drum Rack, so you can toggle loops from within it.  This is a specific need of mine for my new setup.  The regular sampler didn't have a 'toggle' feature that would work for me.
 
Alas!  I've whipped the little guy up.  Works dandy, as much as I can hope.  I can toggle the function for Looping, and I can toggle the function for Toggle, and I can trigger the sample with any MIDI note sent to the instrument (another particularity of mine).  
 
Here's where it all goes wrong...
Any time I use multiple instances of this device- it winds up using the same sample for ALL instances.  So if I have four instances of my little sampler, and I drop four unique samples on each one- they will all play the most recently assigned sample.  This applies within the Drum Rack instrument, and outside of it as well.
 
I have some other issues with my project, but this one is the biggest deal.  I'm definitely new to Max and M4L, so I've got alot to learn- but I do have programming experience.  Perhaps it's an issue with variable names, and loading the sample info?  Just an idea.
 
Does anyone know why this would be happening?  Any help is greatly, greatly appreciated! 
 
 
Also, I couldnt upload my device.  But, it is based off of this device I found online- which has the same bug:
http://www.maxforlive.com/library/device.php?id=185
Perhaps that will help in the debugging process.

newmiracle's picture
newmiracle
Offline
Joined: 02/02/2010

So, I just did more digging and found my problem. I added "---" to the beginning of my variable name and it made all the instances unique. Just the fix I needed.

Also, digging deeper into the documentation I've found more tutorials that are way more helpful to me. I got so excited reading through the Max section of the Help/Tutorials, that I started whipping up my project before reading the MSP section- which has examples on how to build samplers and basically everything I've been looking for.

Glad I could fix my own problem, but it's pretty obvious that I'll be returning here for more help in no time! :-p

Anonymous

Oh my goodness!
That's a fantastic fix! I've been struggling for the past hour or two with the same problem but for a different device - I have a device which rigs follow actions for the next clip, and using this on several channels caused me many headaches. Thank you! You've caused me to stay sane!

mchenetz's picture
mchenetz
Offline
Joined: 09/17/2009

I am glad you found that... Yeah, that makes each instance unique. It's exactly the way you should do it.

Mike