Is there a more clever way of doing this...?

richhop's icon

So I've built this patch to play a chord with one note from a midi device, i've started experimenting with the midiformat and midi parse.

It turns the chord on when the value is equal to C and has a higher velocity than 0, and when the velocity is 0 turns the chord off.

It works fine, but I assume there's a more astute way of approaching this, as there are some issues with my approach.

Can anyone suggest any ideas or pointers to help make this patch more effective?

Thanks in advance!

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

`

Peter Castine's icon

Take a look at [notein], [noteout], [select].

There are loads of unnecessary button objects in your patch, but if they help you understand what you're doing, fine.

In your complicated subpatch, if the chord is fixed you can simply write the note numbers into a message box, separating the numbers with commas. Then a bang to the message box will send out each number individually.

Also note that values received in "cold" outlets are buffered until they're overwritten by a new value. So, for instance, you only need to send the velocity to a noteout object once, then send however many note numbers to noteout's left inlet and they will all generate MIDI noteon events with the same velocity.

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

I enclose a solution that gets down to seven objects. I haven't tested it, so take with several grains of salt. Also, there are some scenarios where it may not do what you want. (What, for instance, if the player is holding down one of the notes of the chord before he plays middle C, then releases middle C? The patch will terminate the note the player was holding down. May or may not be desirable.) Other problems left as an exercise for the reader.

richhop's icon

ahh cheers man thank you so much for replying I will have a tinker with it now.

Yeah there is a reason why the subpatch is a little complicated, i'm not just using one chord in the final set up, there are quite a few different chords, ie minor, major, and all the 9's and 7th etc, the idea is to trigger each chord from it's relevant root note, ie C 48 would trigger C I major, D would trigger II minor. It's complicated sub patch is to allow for modularity of key, but the interval relationship remains fixed inside the chords. So C48 would always trigger a major 1 chord in a specified key.

Also velocity triggers chord voicing, so over 64 is voice B, under 64 triggers voice A. everything on this page has been made with this algorithm I've been writing to give you an example of what it sounds like: https://soundcloud.com/irichop

I'm just trying to make it fool proof, and cleaner, so I'm starting again and trying to get rid of my bad habits like my over use of midi flush after every note off from xnotein.

richhop's icon

ok thank you very much for your help, that patch is awesome that really does help smarten up the approach here.

I've had a play and put another chord in and set the global key, with annotation so you can get an idea.

So my knowledge of list manipulation is pretty primitive, and like you said I do use the bangs and message boxes to help see what is going on.

So here's the problem now, I'm not sure how to switch off hanging notes when changing key, i know it's the borax object, but i have no idea how to keep track of the notes for storing/switching off pairs.

So this is where I've googled the heck out of borax and tried to understand and looked for tutorials but I just can't visualise what's going on so finding a really frustrating to understand how to use it.

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

`

richhop's icon

So this is one way to solve the problem, but does exactly the thing I want to avoid*, which is over complicating things and having to replicate the same things over and over.

Is there a more concise way of approaching this, other than duplicating each transposition table for each chord?

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

`

EDIT: *Also can't use it this way because of the way the root note is used in the rest of the algorithm, basically messes everything else that relies on knowing the chosen chords root note.

richhop's icon

Damn so here's where I've got to with using borax to solve this problem, but still haven't made it work, the chord notes hang when the key changed at the same time as holding down a note, there's no corresponding note off.

I'm not entirely sure how to make this borax object work in the way I want. I know it's only a couple of connections away arrghh!

here's what it looks like if anyone fancies answering my prayers:

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

`

edit: or should the chords be going into the borax object before?

richhop's icon

Made it so the chords go into borax first then to noteout. I have the same problem of the notes hanging when changing key and a note is held down.

Does anyone know the right signal path out of borax to switch off held down notes when the key is changed?

I don't need velocity information coming through either. Just a static velocity is what I'm trying to achieve.

I need a book or teacher or a friend, damn.

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

`

richhop's icon

OK no one worry flush seems to have solved all my problems, I just feel slightly sketchy using it for some reason!