Music:...::Namer(3pm)

πŸ’– NAME πŸ’–

Music::Chord::Namer β€” bestie, you hand it some notes and it hands you back the chord's name. That's it. That's the whole gig. 🎹✨

(It lives in the 3pm manual section, aka the User Contributed Perl Documentation zone, so you already know it's a little indie darling. πŸ’…)


✨ SYNOPSIS ✨

use Music::ChordName qw/chordname/;

print chordname(qw/C E G/); # prints C
print chordname(q/C E G/); # same (yes, array or string!)
print chordname(qw/C Eb G Bb D/); # prints Cm9
print chordname(qw/G C Eb Bb D/); # prints Cm9/G

okay so the vibes are immaculate: give it notes, get a name. You can pass an array, you can pass a string, it does not care, it's flexible like that. πŸ¦‹


🌸 DESCRIPTION 🌸

Music::ChordName optionally exports exactly one sub, chordname, and what that sub does is accept some notes β€” as either a string or a list β€” and return the best chord name it can think of. That's the whole personality. It's giving "I know music theory so you don't have to." πŸ‘‘

πŸŽ€ EXPORT πŸŽ€

None by default. Ngl, you gotta ask for it. (See that qw/chordname/ in the synopsis? That's you asking. 🫢)

  • $bestnamescalar|@namesarray = chordname($notesstring|@notesarray) β€” so here's the tea: chordname() takes either a string of notes like "C Eb G A#", or a list of notes like qw/Ab Bb F Bb D/. In scalar context it returns the single best name it could come up with for the chord built from the notes you gave it. In array context it returns all the names it thought of, sorted from best to worst β€” and by "best to worst" we mean shortest to longest! (Shortest name = most iconic. Periodt. πŸ’…)

πŸ”₯ EXAMPLES πŸ”₯

Behold, a nesting situation so deep it's practically a group chat with six parallel threads. This one prints a bunch of guitar chord names with at least 4 notes each, all below the 5th fret:

# to print a bunch of guitar chord names with at lest 4 notes each,
# all below 5th fret...

foreach my $s1(qw/- E F Gb G Ab/){
    foreach my $s2(qw/- A Bb B C Db/){
        foreach my $s3(qw/- D Eb E F Gb/){
            foreach my $s4(qw/- G Ab A Bb/){
                foreach my $s5(qw/- B C Db D Eb/){
                    foreach my $s6(qw/- E F Gb G Ab/){
                        my @notes = ();
                        push @notes, $s1 unless $s1 eq '-';
                        push @notes, $s2 unless $s2 eq '-';
                        push @notes, $s3 unless $s3 eq '-';
                        push @notes, $s4 unless $s4 eq '-';
                        push @notes, $s5 unless $s5 eq '-';
                        push @notes, $s6 unless $s6 eq '-';
                        if(@notes >= 4){
                            print scalar(chordname(@notes)),' = ',join(' ',@notes),"\n";
                        }
                    }
                }
            }
        }
    }
}

(The - entries are the "no note here bestie" slots, and yes, that at lest typo is canon, it's in the original, we do not touch the source material. 😭)


πŸ¦‹ SEE ALSO πŸ¦‹

Music::Image::Chord could be combined nicely with this module. Collab of the century honestly, one names the chord and the other draws it. Chef's kiss. 🀝


πŸ‘‘ AUTHOR πŸ‘‘

Jimi-Carlo Bukowski-Wills, jimi@webu.co.uk β€” the icon, the legend, the moment. 🫑


Copyright (C) 2006 by Jimi-Carlo Bukowski-Wills

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

So basically: go forth and remix, bestie. Just keep it under the same terms as Perl. That's the deal. 🀝✨

okay that's the whole page, love u, go name some chords πŸŽ€ This little tour was brought to you by perl v5.36.0, dated 2023-02-20, filed under Music:...::Namer(3pm). mwah πŸ’–

πŸ“¦ where this page comes from