Assigning Keys with ASCII
Hello guys! I've been making an experimental drum machine using a keyboard, utilising the amount of keys pressed down to trigger the sample played, however, I realised that by doing it this way, no matter what key or combination of keys I press down, only the same 3 samples can be triggered.
Is there a way I can keep the function where the quantity of keys pressed down trigger a specific sample and velocity, whilst also using the keys ASCII values to trigger different samples depending on -what- key is being pressed?
(Example: If I press down, 'A' it will trigger the lowest velocity Snare, I press down 'ASD' it will trigger the highest velocity Snare. But if I go and then press down 'J', it will trigger the lowest velocity Hi-Hat, and if I press down 'JKL' it will trigger the highest velocity Hi-Hat.)
I hope this explanation makes sense and any help would be greatly appreciated, I will attach my patch below so you can see what I've got so far.
if you're literally just using the central row of the keyboard to trigger, e.g., 3 different samples at 3 different velocities, you could just swap out [zl.len] for [zl.sum] and then use the nine (conveniently different) sums in [sel]
Hey! No I plan to use the entire keyboard for different samples and velocities!
Is there any way of doing that?
Well, you could use multiple [routepass] objects or something, to filter the incoming key presses into groups of three (like [routepass 97 115 100] for A S D) and then stick with what you already had below that...
That would also solve the problem of what happens if you want to play more than one sample at once.
Maybe worth pointing out that your keyboard will only register 6 simultaneous key presses, so you'll be limited in what you can trigger whatever you patch...
Yeah, I limited it to three simultaneous key presses just to make it simpler for myself.
I’ll look into using routepass objects in that case! Thanks for the help and apologies for the bother😭
I’m super new to these kind of things and I unfortunately have to do it for a school project😭
I would use numeric keys to set 10 velocity ranges,
and the rest for notes on/off
Wouldn't something like this correspond to what you described ?

I sorted keys values in alphabetical order, because I realized I didn't always pressed keys in the same order, then used coll to assign corresponding soundfiles and open them.
You will have to define each and every combinations in coll of course. The "time factor" (i.e. max allowed time to press the keys) is important too, and depends on how you intend to play. I used 200 ms here.
Edited using QWERTY keyboard.
Edit : alternatively ("cleaner" ?) :

1- that is too slow to play drum machine, or ?
2- some key combintions can not be used as group of 3 keys.
if DAMI agrees, I can post example of what I mean,
but I won't loose time if he wants to stick with multikey trigger.
First, thanks for all the replies guys, it is greatly appreciated!
But yes, SOURCE might be right, as it is being used as a prototype keyboard drum machine, 200ms of delay maybe a little too much, some research showed me that after I think about 30ms the human ear begins to perceive latency. Could I see what you are suggesting SOURCE?
Also, SÉBASTIEN, I want to enquiry how exactly you embedded those sound files, did you just use the refer soundfiles message or is the object below it connected to it completely separate?
Sorry if these questions seem dumb! I don't have access to MAX at this very minute but I plan on going to my universities computer lab in a few hours.
Soundfiles names are simply stored in [coll soundfiles] :

Sending (refer collname) message to [jit.cellblock] is just an easy way to visualize a [coll collname] content (btw I forgot to add a [loadbang] on top of it here).
Indeed 200 ms may be too long. But I have no clear idea of what a prototype keyboard drum machine is and how you want to use it. Reducing this value is possible (20 ms works as well) but reducing it too much may of course increase the risk of having [thresh] capturing ineffective/wrong keys combinations if you press the keys very fast ! ;-)
I see 2 options :
1- to use keys to set notes, then trigger held one(s)
using numeric keys which use velocity values
like 1 = 30, 2 = 40 etc till 0 = 127.
2- select velocity using numeric keys, but trigger notes using keys.
It simply depens on what is better for your hands.
Here is variation 1, pure midi example, keys are US layout
35 keys starting wih q ... ending with / produce 35 chromatic midi notes, starting with 35.
output is 10 ms short notes for oneshot samples

computer keyboards can be quite confusing: some keys may be pressed 4 at a time), others only 2 at a time.
even worse, it depends on the keys pressed already: for example [b n m ,] gives you all 4, but [n m , .] only gives you 2.
if you are okay with 4, use [q w e r]?