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

NAME

Music::GuitarChordDiagram - Draw Guitar Chord Diagrams

VERSION

version 0.0401

SYNOPSIS

  use Music::GuitarChordDiagram;

  my $dia = Music::GuitarChordDiagram->new(
    chord => 'x02220',
    font  => '/path/to/TTF/font.ttf',
  );

  $dia = Music::GuitarChordDiagram->new(
    chord    => '4442',
    position => 3,
    strings  => 4,
    frets    => 6,
    size     => 25,
    outfile  => 'ukulele-chord',
    font     => '/path/to/TTF/font.ttf',
    tuning   => [qw/A E C G/],
    verbose  => 1,
  );

  $dia->draw();

DESCRIPTION

A Music::GuitarChordDiagram object draws fretboard chord diagrams including neck position and chord name annotations.



ATTRIBUTES

chord

  $dia->chord('xx0232');
  $chord = $dia->chord;

A chord given in string format, where non-zero digits represent frets, x (or X) indicates a muted string and 0 (or o or O) indicates an open string. The default order of the strings is 654321 from lowest to highest.

Examples:

  C: x32010
  D: xx0232
  E: 022100
  F: xx3211
  G: 320003
  A: x02220
  B: x24442
 
  Cm: xx5543
  Dm: xx0231
  Em: 022000
  Fm: xx3111
  Gm: xx5333
  Am: x02210
  Bm: x24432
 
  C7: x32310
  D7: xx0212
  E7: 020100
  F7: xx1211
  G7: 320001
  A7: x02020
  B7: x21202

position

  $position = $dia->position;

The neck position of a chord to be diagrammed. This number is rendered to the left of the first fret.

Default: 1

strings

  $strings = $dia->strings;

The number of strings.

Default: 6

frets

  $frets = $dia->frets;

The number of frets.

Default: 5

size

  $size = $dia->size;

The relative size of the diagram.

Default: 30

outfile

  $outfile = $dia->outfile;

The image file name minus the (PNG) extension.

Default: chord-diagram

font

  $font = $dia->font;

The TTF font to use when rendering the diagram.

Default: /opt/X11/share/fonts/TTF/VeraMono.ttf

tuning

  $tuning = $dia->tuning;

An arrayref of the string tuning. The order of the notes is from highest string (1st) to lowest (6th). For accidental notes, use flat (b), not sharp (#).

Default: [ E B G D A E ]

fretboard

  $fretboard = $dia->fretboard;

A hashref of the string notes. This is a computed attribute.

verbose

  $verbose = $dia->verbose;

Monitor the progress of the diagram construction.

Default: 0

METHODS

new

  $dia = Music::GuitarChordDiagram->new(%arguments);

Create a new Music::GuitarChordDiagram object.

BUILD

Construct the fretboard attribute from the tuning.

draw

  $dia->draw;

Render the requested chord diagram as a PNG image.

SEE ALSO

Imager

List::MoreUtils

Moo

Music::Chord::Namer

Similar modules:

Music::Image::Chord

GD::Tab::Guitar

AUTHOR

Gene Boggs <gene@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2019 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.