Extract the root note of a chord ?

chapelier fou's icon

Hi ! does anyone know an algorithm or, better, a patch that finds the root note in a chord ?

i am looking to do a patch that generates a bass line based on a chord played on top, if anyone has ideas or know some patches !

thanks !

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

as it happens, I made this while teaching a Max class last year:

Roman Thilenius's icon

you can build that around [minimum]

daddymax's icon

Marcel - your patch is brilliant, thanks so much for sharing that.

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

A much simpler way to obtain the lowest note in a chord:

Getting a root note isn't that straightforward, and for most chords there is more than one proper solution.

Marcel Wierckx's icon

Nice patch AK, I had forgotten about the bag object. There's a problem if you start by playing just one note though.

And indeed, finding the root of a chord instead of just the lowest note would be an interesting exercise!

chapelier fou's icon

Thank you all, but i am interested in finding the root note. The lowest note is indeed not a problem.

i think i might need to reduce the choice to a few combinations of intervals and apply different rules to different combinations. Not as elegant as a global algo, but could be at least working.

broc's icon

I would analyse the intervals to find the chord position. Then the root note can be derived.
Example for major triads:
intervals (4,3) -> root position -> lowest note
intervals (3,5) -> 1. inversion -> highest note
intervals (5,4) -> 2. inversion -> middle note

ak's icon

@Marcel Yes indeed, it chokes on the first note (or any subsequent single note higher than played before). [prepend list] before [minimum] solves the issue. Thank you for pointing out.

@OP Worth looking up: V.J.Manzo's Modal Object Library (http://www.eamir.org/developers/modal-object-library), and PC tools in Bach library (http://bachproject.net).

chapelier fou's icon

Thanks.
Broc, that's the way i'm going. Extract the intervals into a list, then compare with several lists and apply one scenario for each matching list.

Roman Thilenius's icon

if you really want to limit your horizon to traditional chords^^... i would suggest to collect their structure in a table, this seems more appropiate than building a complex expression.

look for lowest note, then transpose all members so that the lowest note is"0", then compare the chord with stored presets. (in a second branch you will store and compare the key, i.e. an offset factor between 0 and 11). thats how i am doing it in my processors.

0 4 7
4 7 11
7 11 15

0 3 7
...

Peter McCulloch's icon

This is not Max-specific, but you might also check out Robert Rowe's book "Machine Musicianship". It presents and explains several algorithms for these types of symbolic listening tasks.

Jdudeo's icon

I haven't had a chance yet to look at the patches posted here, but I made this Max for Live device that does exactly what you're describing, the way it works is similar to what Roman offered.

It relies on a database of chord voicings (there's most definitely a better way to search and append to a database than the way I used, it just wasn't that important for me at the time).

I'll admit I thought it would be a much simpler task than it ended up being, having to account for inversions, adding/subtracting of notes etc.

JGJP-RootBass20.amxd
amxd