Conditionals with MIDI Chords

Jun 20, 2011 at 7:04pm

Conditionals with MIDI Chords

Hi All,

Very new to max and trying to make a video art project of sorts using a simple piano prelude and some video clips. I’m wanting to get some input on how to get conditionals (i.e, if/else statements) in max to trigger various video clips to play based on specific chords.

The particular part I’m stuck on is trying to structure the correct conditional or switch statement. This is basically going to be a pretty hefty switch in a traditional programming sense with a variety of chords to listen to. Any tips or suggestions would be great. I’ve attached the patch in progress.

#57692
Jun 20, 2011 at 7:10pm

to switch statements there are at least two ways, you can use scripting to re-create
a new [if] object, or you can use [gate 1 2 3 4 5 6 7 8 9 10].

#206747
Jun 20, 2011 at 7:49pm

What about determining the type of chords that were played? For example, if someone played C2-E2-G2, how could I recognize that?

#206748
Jun 20, 2011 at 10:48pm

This patch recognizes C major and C minor triads. It can easily be extended.

(note: save and close the patch once to cause initialization)

– Pasted Max Patch, click to expand. –
#206749
Jun 20, 2011 at 10:50pm

Maybe reduce the note names to number values and pop some common chords into a [coll] to get you started, here’s a little example that I had floating around.

– Pasted Max Patch, click to expand. –
#206750
Jun 21, 2011 at 9:06am

it is quite some work to determine certain chords, given the number of possible
different chords.

when i remember right my patch for finding C-minor were using something like this:

if ($i1%12)==(0) && ($i2%12)==(4) && ($i3%12)==(7) then 1 else 0

you could use variables for the matches:

if ($i1%12)==($i4) && ($i2%12)==($i5) && ($i3%12)==($i6) then 1 else 0

this way it is still limited to chords of exactly 3 notes of 3 different keys.

the more extras you want, the more mindfuck is involved.

-110

#206751
Jun 21, 2011 at 3:42pm

Thanks for the help everyone. I will have a predefined set of chords to listen to as triggers for other actions. I’ve already started by packing a list of 4 numbers from the chord values (e.g., C2-E2-G2-C3 would create a list of 48 52 55 60). At this point, I would need to create a filtering mechanism to basically check if a list matches a predefined list. Luke, your patch looks the closest to what I’m trying to achieve, however I couldn’t get it to work. Could anyone point me in the right direction as to how I could create a handful of comparisons to check if the values in a MIDI-generated list match that of a predefined set?

#206752
Jun 21, 2011 at 4:49pm

Do the predefined chords have the same number of notes?

#206753
Jun 21, 2011 at 5:05pm

Yes, they will all have 4 note chords—I’m using a poly 4 to listen and compile a list. Seems like I will need to use some combination of zl compare and a collection object as a repository of pre-defined chords. The issue I have with the collection is that defining an index value of a root note of a chord will be difficult since the order of the notes in the list will change depending on how the chord is played…

#206754
Jun 21, 2011 at 5:50pm
– Pasted Max Patch, click to expand. –
#206755
Jun 22, 2011 at 9:27am

So I think Chris provided a great general solution.

Alternatively, here is a simple solution that should also work in your case.
Just fill the [coll] with your specific chords.

– Pasted Max Patch, click to expand. –
#206756
Jun 22, 2011 at 10:37pm

Try patching a [notein] in place of the “keys” subpatch right at the very beginning. That’s just a stand in to turn my laptop keyboard keys into a pretend midi instrument for convenience. It should work OK-ish then, but it is just a sketch and could do with some expansion (inversions definitely need some work!)

#206757
Jun 25, 2011 at 12:32am

Guys, thanks so much—I’ve been able to piece together what I needed for this project (and what I didn’t need serves as a great proof of concept for some other ideas I have in mind!)

Thanks again!

#206758

You must be logged in to reply to this topic.