Forums > MaxMSP

Conditionals with MIDI Chords

Jun 20 2011 | 7:04 pm

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.

Jun 20 2011 | 7:10 pm

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].

Jun 20 2011 | 7:49 pm

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

Jun 20 2011 | 10:48 pm

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. --

Jun 20 2011 | 10:50 pm

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. --

Jun 21 2011 | 9:06 am

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.


Jun 21 2011 | 3:42 pm

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?

Jun 21 2011 | 4:49 pm

Do the predefined chords have the same number of notes?

Jun 21 2011 | 5:05 pm

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…

Jun 21 2011 | 5:50 pm

-- Pasted Max Patch, click to expand. --

Jun 22 2011 | 9:27 am

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. --

Jun 22 2011 | 10:37 pm

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!)

Jun 25 2011 | 12:32 am

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!

Viewing 13 posts - 1 through 13 (of 13 total)

Forums > MaxMSP