-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maps a fingering to notes in a non-OO way
- Loading branch information
Showing
2 changed files
with
29 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] |