Recall last (note) value?

Ad.Ross's icon

Hello everyone,

I'm looking for a way in max that will store a set of values so that when the last is reversed or removed, the previous will trigger instead and so on until it is back to nothing.

A good example would be the [kslider] connected to a midi keyboard. If set to polyphonic and 3 keys are played in succession,when the last note is released then the one before it will trigger. I looked at [borax] which is useful (it even shows event number but I'm not sure how to use that to store the key at the time?) and tried [if] objects to store to message boxes and then trigger using borax' "notes active", but this only works if keys are released in the order they were played in so reduces freedom. Also, it would be ideal if as each note is released on the keyboard, the note on the kslider would release to allow a visual reference,without sending 0 vel to all notes, this is a problem I had. If stripnote is present I can stop the 0 vel values but it also stops the keys on [kslider] lifting.

I'll paste an example of what I mean. I looked at [coll] but either missed out on what it can do or it's of no use in this case.

Max Patch
Copy patch and select New From Clipboard in Max.

If anyone can help, I'd be grateful.

broc's icon

I'm trying to understand your problem with a simple example:

- note C is triggered (note on)
- while C is playing, note E is triggered (note on)
- while C is still playing, note E is released (note off)

At this point, do you want that C is re-triggered?

Ad.Ross's icon

Hi,

That's correct, but throughout a longer chain. What you just described using two notes is easy to do, what I have written accomplishes this, but not beyond that. If three notes are played in succession, they will only trigger correctly if released in the opposite order they were played. If three were played at say, 36 - 37 -38, then releasing 37 first plays the note instead of going to 38, then of course releasing 36 has the same effect, when now it would only be 38 still held and the one that *should* be playing.

I may have missed out something totally obvious but I have been though the MAX tutorials and read many object help files, hopefully I'm not blind to a simple solution.

Cheers.

broc's icon

So I guess it can be solved with [poly] and [coll].
Notice that the voice number of [poly] corresponds to the order in which the notes were played.

Ad.Ross's icon

That's true, I can see the same output coming from [borax] that comes from [poly] and that was my initial idea, I just can't figure out how to use [coll] with it to store each value and then output the nearest available value needed as keys are released.

AaronMButler's icon

Are you meaning a last-note priority kind of thing?

Does [ddg.mono] accomplish what you need? Sounds like it might. Sorry if I misinterpreted what you're meaning.

Ad.Ross's icon

Well I tried [coll] and sure enough can get note values stored with an index assigned according to voice number. However, so far it's less effective than sending values to message boxes in that as soon as a note is lifted, it will send that value out and hence play it,regardless of order. I tried to see if then I could use it to trigger held notes on the [kslider], but this is inaacurate in several ways too. I've tried various messages into the [coll],such as delete, goto, remove and nth (which for some reason crashes max and needs a reboot...) but nothing seems to do the trick. If anyone can give a pointer on correctly making a start with it I would be seriously appreciative.

Chris Muir's icon

There was a thread about this a few months back:
https://cycling74.com/forums/monophonic-note-stack

Ad.Ross's icon

Thanks for your replies, both are useful (that thread did not show in my searches even though "borax" was present). ddg.mono behaves very much like how I needed in the first place, the "last note priority" in particular, although I would still like to trigger note-offs to the kslider as each key is released. I think I'll try and sort that out myself though and keep searching for a way to write the whole thing myself eventually (learning curve/cliff).Thanks again.

seejayjames's icon
Max Patch
Copy patch and select New From Clipboard in Max.

not sure if it helps, but here's a little patch that lets you build a list and then chop off the end value one-by-one. Maybe with the right patching around it to and from your note-ons and note-offs, you could get something to work: