Skip to content

Commit

Permalink
Maps a fingering to notes in a non-OO way
Browse files Browse the repository at this point in the history
  • Loading branch information
zimolzak committed Jul 5, 2014
1 parent afb2084 commit 1434488
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ukulele
=======

Iterate all fingerings and decode to chord names
Iterate through all fingerings and decode to chord names.

The idea is to also have fun with Python and OOP.
26 changes: 26 additions & 0 deletions ukulele.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env python
Maxfret = 12
Tuning = ['g', 'c', 'e', 'a']
Pitches = ['c', 'c#', 'd', 'eb', 'e', 'f', 'f#', 'g', 'g#', 'a', 'bb', 'b']
from itertools import *

NumChords=0
for p in product(range(0,Maxfret+1), repeat=4):
NumChords += 1
print NumChords

def fing2notes(fing):
notes=[None]*len(fing)
for i in range(len(fing)):
notes[i]=Pitches[Pitches.index(Tuning[i]) + fing[i]]
return notes

#### tests

f_fing=[2,0,1,0]
dm_fing=[2,2,1,0]
gm_fing=[0,2,3,1]

assert fing2notes(f_fing) == ['a', 'c', 'f', 'a']
assert fing2notes(dm_fing) == ['a', 'd', 'f', 'a']
assert fing2notes(gm_fing) == ['g', 'd', 'g', 'bb']

0 comments on commit 1434488

Please sign in to comment.