There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Hi Gene.
Indeed - when I stick this in Music::Chord, it'll have strict and warnings plastered all over it...but I was playing golf :) I too am a fan of Sean's MIDI Modules, but not of 'As' and 'Af' - I've been reading / writing real music for too long now. Again, if/when I 'modulise' this, and once we've sorted out a common standard for note interchange, this will probably sort itself out. The 'parsing gymnastics' though would seems to consist of s/s$/#/ and s/f$/b/ :) Anyway, here are some answers. 1. 'f' stands (in my head) for 'final values'. It's just an array that stores the note counts. Yes, I could have called it '@final_values'. 2. ($n + $_) %12 represents adding a numerical note value ($n) to an interval ($_) and doing a modulus 12 on the result, to remain within the 0-11 note range. 3. These are harmonics. Indeed, the link describes the algorithm, and explains what the values meant, but briefly, the idea is to take the 1st 8 *sub*-harmonics (8va,5th,8va,3rd,5th,7th etc., but *downwards*) of each note in the chord, then do a popularity count on each note - the most popular is/are the root. The original algorithm misses out all octave equivalents, (doubled root + 5th), but I found that this gives wrong results for minor chords, so added them back in. This gives us a semitone-interval list of (0, -12, -19,-24...), but I didn't bother with working out all the big negative numbers, as this is just functionally equivalent to (0,0,5,0,8,5,10,0,2), ordered how you like - in my case, sorted numerically cos it looked nicer :) Hope this answers the questions. Ben. In reply to Re: Re: Chord root
by benn
|
|