Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Guitar Shift 0.1
- # This program displays the same note on all the strings of the guitar.
- from sys import argv
- usage = """
- Usage: python guitar_shift.py [string] [fret]
- Example: python guitar_shift.py 1 3 -- first string, third fret
- """
- # Standard tuning: E B G D A E
- tuning = {
- 1: 5,
- 2: 12,
- 3: 8,
- 4: 3,
- 5: 10,
- 6: 5,
- }
- # Number of frets on the guitar
- frets = 24
- try:
- given_string = int(argv[1])
- given_fret = int(argv[2])
- except (TypeError, ValueError, IndexError):
- exit(usage)
- if not tuning.has_key(given_string):
- exit('Error: unknown string.')
- if not (0 <= given_fret <= frets):
- exit('Error: no such fret.')
- given_note = tuning[given_string] + given_fret
- while given_note >= 12:
- given_note -= 12
- for string in tuning:
- # first position on the string -- could be negative, not used if so
- fret = given_note - tuning[string]
- if fret >= 0:
- string_frets = [(given_note - tuning[string])]
- else:
- string_frets = []
- while fret <= (frets - 12):
- fret += 12
- string_frets += [fret]
- print "%i:" % (string), string_frets
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement