The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

MIDI::Chord::Guitar - MIDI pitches for guitar chord voicings

VERSION

version 0.0400

SYNOPSIS

  use MIDI::Chord::Guitar;

  my $mcg = MIDI::Chord::Guitar->new;

  my $chords = $mcg->transform('D3', 'dim7');
  # [ [41, 47, 50, 56], [50, 56, 59, 65, 68] ]

  my $chord = $mcg->transform('D3', 'dim7', 0);
  # [41, 47, 50, 56]

  # MIDI:
  #$score->n('wn', @$chord);

  my $voicings = $mcg->voicings('dim7');
  # [ [51, 57, 60, 66], [48, 54, 57, 63, 66] ]

  $voicings = $mcg->voicings('dim7', 'ISO');
  # [ [D#3 A3 C4 F#4], [C3 F#3 A3 D#4 F#4] ]

DESCRIPTION

MIDI::Chord::Guitar provides MIDI pitches for common chord voicings of an E A D G B E tuned guitar.

Here is a handy diagram of ISO MIDI pitches laid out on a guitar neck:

And here is a companion diagram of MIDI pitch numbers laid out on a guitar neck:

ATTRIBUTES

voicing_file

The CSV file with which to find the MIDI numbered chord voicings.

If not given, File::ShareDir is used.

chords

  $chords = $mcg->chords;

Computed attribute available after construction.

The known chord names are as follows:

  '' (major)
  aug
  dim
  dim7
  m (minor)
  m6
  m7
  m7b5
  m7b5#9
  m9
  m11
  maj7
  maj7#11
  maj9
  sus2
  sus4
  6
  6(9)
  7
  7#5
  7#9
  7b13
  7b5
  7b9
  7b9b13
  9
  9sus4
  11
  13

METHODS

transform

  $chord = $mcg->transform($target, $chord_name, $variation);
  $chords = $mcg->transform($target, $chord_name);

Find the chord given the target, chord_name and an optional variation.

The target must be in the format of an ISO note (e.g. on the guitar, a C note is represented by C3, C4, C5, etc).

If no chord_name is given, major is used.

If no variation is given, all transformed voicings are returned.

For example, here are the open major chord specs for each note in the key of C:

  'C3', '', 0
  'D3', '', 4
  'E2', '', 3
  'F2', '', 3
  'G2', '', 2
  'A2', '', 1
  'B2', '', 1

voicings

  $mcg->voicings($chord_name);
  $mcg->voicings($chord_name, $format);

Return all the voicings of a given chord_name in the key of C.

The default format is midinum but can be given as ISO or midi to return named notes with octaves.

The order of the voicing variations of a chord is by fret position. So, the first variations are at lower frets. Please use the above diagrams to figure out the exact neck positions.

Here is an example of the voicing CSV file which can be found with the voicing_file attribute:

  C,48,52,55,60,,
  C,48,55,60,64,67,
  C,48,52,55,60,64,72
  C,48,55,60,64,67,72
  C,60,67,72,76,,
  C7,48,52,58,60,64,
  C7,48,55,58,64,67,
  C7,48,55,58,64,67,72
  C7,48,52,55,60,64,70
  C7,60,67,70,76,,
  ...

Check out the link in the "SEE ALSO" section for the chord shapes used to create this.

SEE ALSO

The t/01-methods.t and eg/autumn_leaves files in this distribution

File::ShareDir

List::Util

Moo

Music::Note

Text::CSV_XS

https://www.guitartricks.com/chords/C-chord shapes

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020 by Gene Boggs.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.