Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Home

darth10 edited this page · 4 revisions
Clone this wiki locally

Frets is a lightweight library for creating, manipulating and printing guitar chord diagrams.

You can create chords by using a Guitar object, which can have 6, 7 or 8 strings. A Guitar also has a tuning, represented by the Tuning property.
The Tuning is shown only when chords are printed.

Guitar g = new Guitar(GuitarMode.SevenString);
g.Tuning = TuningMode.ATuning_7String;

List<Chord> lChords = new List<Chord>();
lChords.Add(g.PlayChord(ChordFlags.None, ChordFamily.E, ChordType.Major));
lChords.Add(g.PlayChord(ChordFlags.None, ChordFamily.DSharp, ChordType.Major));
lChords.Add(g.PlayChord(ChordFlags.None, ChordFamily.E, ChordType.Major));
lChords.Add(g.PlayChord(ChordFlags.None, ChordFamily.E, ChordType.Minor)); 

String chordDiagram = g.PrintChords(lChords, 8); //8 is line length

In the above example, chordDiagram will have the following value. The extra line break characters are not shown.

A[---0-------0---0----------------]
D[---0-------0---0----------------]
G[---2---1---2---2----------------]
C[---2---1---2---2----------------]
F[---1---3---1---0----------------]
A[---0---4---0---0----------------]
D[---0---3---0---0----------------]

Similarly, you can create chords by optionally specifying the individual strings played.
Chords also support different ChordFlags, such as PalmMute. Special strings, such as HammerDown and SlideUp can also be provided, by using the SpecialStrings class.

Chord c = new Chord(ChordFlags.PalmMute, 8, 0, 0, 3, 3, 2, 0, 1, 0);
String sChord = c.ToString();   // [0,0,3,3,2,0,1,0](PM)

The FretMap class can also be used to print chords. Phase printing is also supported, and phrase is represented by a Phrase object. A phrase is essentially just a list of chords.

Phrase p = new Phrase();
p.Add(new Chord(ChordFlags.None, 7, 4, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 0, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 0, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 1, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 0, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 0, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 3, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 0, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 3, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, 1, -1, -1, -1, -1, -1, -1));
p.Add(new Chord(ChordFlags.None, 7, SpecialStrings.FullBend, -1, -1, -1, -1, -1, -1));

List<Phrase> lPhrases = new List<Phrase>();
lPhrases.Add(p);

String sPhrases = FretMap.PrintChords(lPhrases, TuningMode.ATuning_7String, 16);

The above example produces the following value in sPhrases.

A[---4---0---0---1---0---0---3---0---3---1b-----------------------]
D[----------------------------------------------------------------]
G[----------------------------------------------------------------]
C[----------------------------------------------------------------]
F[----------------------------------------------------------------]
A[----------------------------------------------------------------]
D[----------------------------------------------------------------]

The FretControl user control can be used to visually create chords.

Something went wrong with that request. Please try again.