YuckFoo - Thanks for the critique - lots of good points. To take them in order....

OK - guilty as charged. My 're-ordering' of the array could be confusing to anyone wanting to understand this algorithm...it was sheerly a side effect of experimentation ("I wonder what happens if I stick an extra '0' in there..."), but I'm sorry and I won't do it again :) (Oh, and the missing '0' too was simply the result of experimentation.)

Originally, I did implement the algorithm exactly as stated, checking for existence in all columns. And indeed, it worked beautifully for major chords - but not for minor ones, for exactly the reason you describe. So, being a hacker by nature, I played around with it until it worked for both.

You say it "seems" to work. I'm not pretending that I understand why sticking the 'redundancy' back in and switching from a column-based count to a simple frequency count works, but it does - certainly for all the examples I've played around with. The original algorithm, given "a c e" produces a root of 'D', which is...well, I hesitate to say "plain wrong", because I suppose it could be considered a D9 with no root or 3rd, but I prefer to spell that 'A minor'. This version produces 'A', which is, in my eyes, better. The 'Tristan' example gives *both* the C#9 spelling *and* the G#m6 spelling - also 'correct'.

I'd love to see a proof of why this works (or not, as the case may be) - I *only just* understood why the original worked, and this version is simply the result of a few hours idly hacking around. I may have jumped to a number of erroneous conclusions - but I'm happy with the result - while the original algorithm doesn't handle minor chords, this one does. Again, don't ask me *why* (my best guess is something to do with relative minors), but it certainly works for every 3/4 note chord I've tried, (other than a 4-note diminished, which understandably confuses the hell out of it :) ).

Cheers,
Ben.


In reply to Re: Re: Chord root by benn
in thread Chord root by benn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.