# Chord Shape Generator

, 20 Sep 2012
 Rate this:
Using number systems in statistics

## Introduction

You may find this project useful if you're planning to create a chord chart or a complete database of chord voicings for the guitar.

The code enumerates all possible lowest position moveable chord shape combinations within the first 5 frets. The resulting shapes may then be easily slid or transposed to other frets like barre chords.

Approximately 31,000 distinct shapes are produced for a 6 string guitar while 201,811 shapes are produced for a 7 string guitar. Processing time may take about 1 to 3 minutes depending on the number of strings selected.

For now, the app still generates awkward chord shapes or wide stretches which may be impossible to press on a real instrument. Exceptional open string possibilities have been excluded from the calculation.

After all combinations have been found, the shapes are then sorted according to their intervallic structure. I've used binary numbers and decimal numbers to represent and abbreviate the intervals of conventional chord formulas. Here are a few examples:

 DECIMAL BINARY CONVENTIONAL MUSIC FORMULA CHORD/SCALE 4095 111111111111 1-b2-2-b3-3-4-b5-5-#5-6-b7-7 Chromatic scale 2773 101011010101 1-x-2-x-3-4-x-5-x-6-x-7 Major scale 2192 100010010000 1-x-x-x-3-x-x-5-x-x-x-x major chord 2320 100100010000 1-x-x-b3-x-x-x-5-x-x-x-x minor chord

## Table of Upper Ranges

 Fretspan5 Fretspan4 Fretspan3 Fretspan2 Fretspan1 Base6 Base5 Base4 Base3 Base2 4 string 1295 624 255 80 15 5 string 7775 3124 1023 242 31 6 string 46655 15624 4095 728 63 7 string 279935 78124 16383 2186 127

## Code Excerpts

I would suggest that you download the entire .zip file which contains the supporting procedures. Here is one function I've used:

```Function NumberSystemEquivalent(ByVal DecimalInput As Long, BaseNumber As Integer) As String
Dim Exponent As Integer
Dim Num As Long

Num = DecimalInput
Exponent = 0

Do
If Num < BaseNumber ^ Exponent Then
Exit Do
End If
Exponent = Exponent + 1
Loop

Exponent = Exponent - 1

If Exponent < 0 Then
Exponent = 0
End If

Dim y As Integer, PositionalValue As Long

For y = Exponent To 0 Step -1
PositionalValue = BaseNumber ^ y
If (Num \ PositionalValue) >= 1 Then
NumberSystemEquivalent = NumberSystemEquivalent & (Num \ PositionalValue)
Num = Num Mod PositionalValue
ElseIf (Num \ PositionalValue) < 1 Then
NumberSystemEquivalent = NumberSystemEquivalent & "0"
End If
Next y

End Function
// The base number used by the function above varies
// depending on the fret span selected by the user:
Select Case lstFretSpan.ListIndex
Case 0
BaseN = 5
Case 1
BaseN = 6
End Select

// ... and the way the shapes are extracted can be quickly summarized in this way:

Sub ExtractChordShapes()
Dim x As Long
Dim ReturnValue As String
Dim FormatResult As String
Dim TABFormat As String, ChordNumber As Integer
Dim ctr As Long

Erase mChordNumber_Shape

ctr = -1
For x = 1 To Range
ReturnValue = NumberSystemEquivalent(x, BaseN)

FormatResult = Format(ReturnValue, String(NumberofStrings, "0"))
If InStr(FormatResult, "1") <> 0 Then // << This statement ensures that no duplicate shapes
// occur and that the shapes are in the
// lowest position
TABFormat = Replace(FormatResult, "0", "x")
ctr = ctr + 1

ReDim Preserve mChordNumber_Shape(ctr)

ChordNumber = DecimalEquivalent(BinaryFormula(TABFormat))
mChordNumber_Shape(ctr) = ChordNumber & " = " & TABFormat
End If

Next x
Call Alphabetize(mChordNumber_Shape)
txtCount.Text = ctr + 1
End Sub```

## Points of Interest

For the guitar tuning arrays found in the other supporting procedures not shown above: C4 would correspond to Middle C or MIDI Note Number 60.

The code contained in the zip file is already quite self-documenting in itself and a very detailed explanation of the code would make this introduction very lengthy. I've used descriptive variable declarations and labels to make it easier to visualize how the code works. This may become more apparent once you've gone through the code and if you're quite familiar with the basic VB syntax.

Feel free to make use of or alter the code in case you might have similar applications.

## History

• Revised: 9-20-2012

## You may also be interested in...

Philippines
No Biography provided

 First Prev Next
 Where is the solution of this project? Menelaos Vergis 19-Sep-12 22:49
 Re: Where is the solution of this project? ha_asgag 19-Sep-12 22:54
 Re: Where is the solution of this project? ha_asgag 22-Sep-12 20:22
 Last Visit: 31-Dec-99 18:00     Last Update: 29-Aug-14 1:29 Refresh 1