Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import curses
- import sys
- sys.stdout.write("\x1b]2;G(uitar) Chords!\x07") # set the terminal window title
- myscreen = curses.initscr()
- #myscreen.box()
- myscreen.keypad(1)
- myscreen.refresh()
- maxheight,maxwidth = myscreen.getmaxyx()
- #myscreen.addstr(1,1,str(maxwidth)) # debug
- #myscreen.addstr(2,1,str(maxheight)) # debug
- curses.start_color()
- curses.use_default_colors()
- curses.noecho()
- curses.cbreak()
- curses.curs_set(0)
- curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
- curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLACK)
- # DEFINE DICTIONARIES
- note_type_1 = { # guitar_note_type = 1
- 1: 'C', 2: 'C#', 3: 'D', 4: 'D#', 5: 'E', 6: 'F', 7: 'F#', 8: 'G', 9: 'G#',
- 10: 'A', 11: 'A#', 12: 'B'}
- note_type_2 = { # guitar_note_type = 2
- 1: 'C', 2: 'Db', 3: 'D', 4: 'Eb', 5: 'E', 6: 'F', 7: 'Gb', 8: 'G', 9: 'Ab',
- 10: 'A', 11: 'Bb', 12: 'B'}
- pckeys = {
- 1: 'z', 2: 's', 3: 'x', 4: 'd', 5: 'c', 6: 'v', 7: 'g', 8: 'b', 9: 'h',
- 10: 'n', 11: 'j', 12: 'm'}
- subnotes = { # display this, this is purely for the display of the chord-name
- 1: 'M(ajor)', 2: 'm(inor)', 3: 'M6', 4: 'm6', 5: '7',
- 6: 'M7', 7: 'm7', 8: 'mM7', 9: '9', 10: 'M9', 11: 'm9',
- 12: 'mM9', 13: 'M11', 14: 'm11', 15: 'mM11',
- 16: 'M13', 17: 'm13', 18: 'mM13',
- 19: 'M-add9', 20: 'm-add9', 21: 'M6-add9', 22: 'm6-add9',
- 23: 'dom7', 24: 'dom9', 25: 'dom11', 26: 'dom13',
- 27: 'sus2', 28: 'sus4', 29: '6-sus4', 30: '7-sus4', 31: 'm7-sus4',
- 32: '9-sus4', 33: 'm9-sus4', 34: '7b5', 35: 'm7b5', 36: '7#5', 37: 'm7#5',
- 38: '7b9', 39: 'm7b9', 40: '7#9', 41: '7#5b9', 42: '9#11', 43: '9b13',
- 44: 'dim', 45: 'dim7', 46: 'add2', 47: 'add4', 48: '7-add4',
- 49: '5', 50: 'aug'}
- chord_formulas = { # use these, these are for calculating the chords
- 1: [1,3,5], 2: [1,'b3',5], 3: [1,3,5,6], 4: [1,'b3',5,6], 5: [1,3,5,'b7'],
- 6: [1,3,5,7], 7: [1,'b3',5,'b7'], 8: [1,'b3',5,7], 9: [1,3,5,'b7',9], 10: [1,3,5,7,9], 11: [1,'b3',5,'b7',9],
- 12: [1,'b3',5,7,9], 13: [1,3,5,7,9,11], 14: [1,'b3',5,'b7',9,11], 15: [1,'b3',5,7,9,11],
- 16: [1,5,7,9,11,13], 17: [1,'b3',5,'b7',9,11,13], 18: [1,'b3',5,7,9,11,13],
- 19: [1,3,5,9], 20: [1,'b3',5,9], 21: [1,3,5,6,9], 22: [1,'b3',5,6,9],
- 23: [1,3,5,'b7'], 24: [1,3,5,'b7',9], 25: [1,3,5,'b7',9,11], 26: [1,3,5,'b7',9,11,13],
- 27: [1,2,5], 28: [1,4,5], 29: [1,4,5,6], 30: [1,4,5,'b7'], 31: [1,4,5,7],
- 32: [1,4,5,'b7',9], 33: [1,4,5,7,9], 34: [1,3,'b5',7], 35: [1,'b3','b5','b7'],
- 36: [1,3,'#5','b7'], 37: [1,'b3','#5','b7'], 38: [1,3,5,'b7','b9'],
- 39: [1,'b3',5,'b7','b9'], 40: [1,3,5,'b7','#9'], 41: [1,3,'#5','b7','b9'],
- 42: [1,3,5,'b7',9,'#11'], 43: [1,3,5,'b7',9,'b13'], 44: [1,'b3','b5'],
- 45: [1,'b3','b5',6], 46: [1,2,3,5], 47: [1,3,4,5], 48: [1,3,4,5,'b7'],
- 49: [1,5], 50: [1,3,'#5']}
- # SET DEFAULTS
- #chord = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0} # default to no notes displayed
- current_window = 1 # default to notes_section
- ns_cursor_vpos = 1 # notes_section cursor vertical position
- ns_cursor_hpos = 1 # notes_section cursor horizontal position
- ss_cursor_vpos = 1 # subnotes_section cursor vertical position
- ss_cursor_hpos = 1 # subnotes_section cursor horizontal position
- guitar_show_what = 0 # default to showing no notes
- guitarnotes = note_type_1 # default to note-type A#
- global_guitar_notetype = 1
- current_note = 1 # default to first note
- current_subnote = 1 # default to first subnote
- scale = 1 # default to major scale
- global_tuning = {1: 'E', 2: 'B', 3: 'G', 4: 'D', 5: 'A', 6: 'E'}
- # THE GUITAR
- guitar_width = 64
- guitar_hpos = (maxwidth - guitar_width) / 2 - 4
- guitar = curses.newwin(8,guitar_width,0,guitar_hpos)
- guitar.box()
- guitar.refresh()
- def guitar_draw_body():
- vpos = 1
- for x in global_tuning:
- guitar.addch(vpos,0,str(global_tuning[x]),curses.A_NORMAL)
- vpos = vpos + 1
- guitar.vline(1,2,curses.ACS_VLINE,6) # nut
- guitar.vline(1,3,curses.ACS_VLINE,6) # nut
- fret_hpos = 7
- for fret in range(1,15):
- guitar.vline(1,fret_hpos,curses.ACS_VLINE,6)
- fret_hpos = fret_hpos + 4
- def guitar_draw_strings(): # takes a dict of 6 fretboard-positions
- string_vpos = 1
- for string in range(1,7):
- guitar.hline(string_vpos,4,'-',(guitar_width - 5))
- string_vpos = string_vpos + 1
- # BUILD THE NOTES ON THE NECK
- def build_necknotes(tuning):
- # build arrays of form [stringnumber,fretnumber,notename] inside a dict.
- note_count = 0
- string_count = 0
- count = 1
- neck_notes_list = {}
- for x in tuning:
- fret_count = 1
- string_count = string_count + 1
- for y in guitarnotes:
- if guitarnotes[y] == tuning[x]:
- note_count = y
- neck_notes_list[count] = [string_count,0,tuning[x]] # fret 0 holds the root-notes
- count = count + 1
- break
- for q in range(1,16):
- if note_count < 12:
- note_count = note_count + 1
- else:
- note_count = 1
- neck_notes_list[count] = [string_count,fret_count,str(guitarnotes[note_count])]
- fret_count = fret_count + 1
- count = count + 1
- return neck_notes_list
- global_necknotes = build_necknotes(global_tuning)
- # PRINT THE NOTES ON THE NECK
- def print_necknotes(necknotes):
- hpos = 5
- vpos = 1
- for i in necknotes:
- if necknotes[i][1] != 0: # don't print the root-notes
- guitar.addstr(vpos,hpos,necknotes[i][2])
- if hpos < 61:
- hpos = hpos + 4
- else:
- hpos = 5
- vpos = vpos + 1
- def draw_guitar(the_id,key):
- guitar.clear()
- global guitar_show_what
- global global_guitar_notetype
- if the_id == 0: # do nothing, just print the guitar
- send_return = 0
- guitar_draw_strings()
- if the_id == 2: # F2: notetype (A#/Bb)
- if key == 0:
- global_guitar_notetype = 1
- send_return = 1
- elif key == 1:
- global_guitar_notetype = 0
- send_return = 0
- elif the_id == 3: # F3: show/hide notes
- if key == 0:
- guitar_show_what = 1
- send_return = 1
- elif key == 1:
- guitar_show_what = 0
- send_return = 0
- guitar_draw_strings()
- if guitar_show_what == 1:
- print_necknotes(global_necknotes)
- guitar.box()
- guitar_draw_body()
- build_chord(current_note,current_subnote)
- guitar.refresh()
- return send_return # return changed value
- #draw_guitar(0,0)
- # SHORTHAND BOX
- shorthand = curses.newwin(8,6,0,(guitar_hpos + guitar_width + 1))
- shorthand.box()
- shorthand.refresh()
- def build_shorthand(notes):
- ()
- # NOTES SECTION
- def print_notes():
- notes = {}
- x = 1
- while (x <= 12):
- notes[x] = guitarnotes[x]
- x = x + 1
- notes_section.clear()
- note_hpos = 1
- for i in notes:
- notes_section.addstr(1,note_hpos,notes[i])
- note_hpos = note_hpos + len(notes[i]) + 2
- notes_section.refresh()
- notes_section_hpos = (maxwidth - 46) / 2 + 2
- notes_section = myscreen.derwin(3,46,8,notes_section_hpos)
- print_notes()
- myscreen.addstr(9,(notes_section_hpos - 9),'[Notes]',curses.A_BOLD)
- notes_section.chgat(1,1,2,curses.A_REVERSE)
- notes_section.refresh()
- # END OF NOTES SECTION
- # SUBNOTES SECTION
- def print_subnotes():
- column_width = 15
- subnote_hpos = 1
- subnote_vpos = 1
- sn = 1
- while (sn <= 50):
- sn_len = len(subnotes[sn])
- if subnote_vpos == (11): # if too high,
- subnote_hpos = subnote_hpos + column_width # jump to the right
- subnote_vpos = 1 # and start over at the top
- subnotes_section.addstr(subnote_vpos,subnote_hpos,subnotes[sn])
- subnote_vpos = subnote_vpos + 1
- sn = sn + 1
- subnotes_section.box()
- subnotes_section.addstr(0,5,'[Subnotes]')
- # determine horizontal position of the subnotes_section
- if maxwidth <= 75:
- subnotes_section_hpos = 3
- elif maxwidth > 75:
- subnotes_section_hpos = (maxwidth - 75) / 2
- subnotes_section = myscreen.derwin(12,75,11,subnotes_section_hpos)
- print_subnotes()
- subnotes_section.chgat(1,1,13,curses.A_REVERSE)
- subnotes_section.refresh()
- # END OF SUBNOTES SECTION
- # SCALE SECTION
- def build_scale(root,m):
- scale = {1: guitarnotes[root]}
- index = root
- scale_formula = [2,2,1,2,2,2,1,2,2,1,2,2,2] # Major scale
- if m == 1: # Major scale
- mjn = 'Major'
- scale_formula = [2,2,1,2,2,2,1,2,2,1,2,2,2]
- elif m == 2: # Natural Minor scale
- mjn = 'Natural Minor'
- scale_formula = [2,1,2,2,1,2,2,2,1,2,2,1,2]
- elif m == 3: # Harmonic Minor scale
- mjn = 'Harmonic Minor'
- scale_formula = [2,1,2,2,1,3,1,2,1,2,2,1,3]
- elif m == 4: # Melodic Minor scale
- mjn = 'Melodic Minor'
- scale_formula = [2,1,2,2,2,2,1,2,1,2,2,2,2]
- scaletext = mjn + ' scale of ' + scale[1] + ': '
- num = 2
- for i in scale_formula:
- if (index + i) <= len(guitarnotes):
- index = index + i
- else:
- index = (index + i) - len(guitarnotes)
- scale[num] = guitarnotes[index] # add to dictionary
- num = num + 1
- scale_section.clear() # erase the content of the scale section
- scale_hpos = len(scaletext) + 1 # start printing the scale
- count = 0
- for x in scale:
- if count < 7:
- scale_section.addstr(1,scale_hpos,scale[x])
- scale_hpos = scale_hpos + len(scale[x]) + 1
- count = count + 1
- scale_section.addstr(1,1,scaletext)
- #scale_section.box()
- scale_section.refresh()
- scale_section = myscreen.derwin(3,75,22,subnotes_section_hpos)
- def build_major_scale(root):
- scale = {1: guitarnotes[root]}
- key_reference = {1: root} # keeps a reference of the relation of scale-position to notes-position
- index = root
- scale_formula = [2,2,1,2,2,2,1,2,2,1,2,2,2] # Major scale
- num = 2
- for i in scale_formula:
- if (index + i) <= len(guitarnotes):
- index = index + i
- else:
- index = (index + i) - len(guitarnotes)
- scale[num] = guitarnotes[index] # add to dictionary
- key_reference[num] = index
- num = num + 1
- return scale,key_reference
- build_scale(current_note,scale)
- # END OF SCALE SECTION
- # CHORD SECTION
- def build_chord(root,chordtype):
- chord = []
- chord_formula = chord_formulas[chordtype]
- scale,key_reference = build_major_scale(root)
- global string_map
- string_map = []
- for z in chord_formula:
- if isinstance(z, int) == True: # if the formula holds an integer, fine
- chord.append(scale[z])
- string_map.append(key_reference[z])
- elif z[0] == 'b': # if the formula holds a 'b'-note, get 1 pianokey below that note in the scale
- key = int(z[1])
- if key_reference[key] > 1:
- note = str(guitarnotes[key_reference[key] - 1])
- string_map.append(key_reference[key] - 1)
- elif key_reference[key] == 1: # 1-1=12 (go back around)
- note = str(guitarnotes[12])
- string_map.append(12)
- chord.append(note)
- elif z[0] == '#': # if the formula has a '#'-note, get 1 pianokey above that note in the scale
- key = int(z[1])
- if key_reference[key] < 12:
- note = str(guitarnotes[key_reference[key] + 1])
- string_map.append(key_reference[key] + 1)
- elif key_reference[key] == 12: # 12+1=1 (go back around)
- note = str(guitarnotes[1])
- string_map.append(1)
- chord.append(note)
- chord_section.clear()
- chord_hpos = 2
- count = 0
- for y in chord:
- chord_space = (len(guitarnotes[root]) + len(subnotes[chordtype]) + 1)
- chord_section.addstr(1,1,guitarnotes[root] + ' ' + subnotes[chordtype] + ': ')
- chord_section.addstr(1,(1 + chord_space + chord_hpos),y)
- chord_hpos = chord_hpos + len(y) + 1
- #chord_section.box()
- chord_section.refresh()
- print_subnotes()
- #guitar_draw_strings()
- print_chord(chord,"regular")
- #chords_open = { # '': [[1,],[2,],[3,][4,],[5,],[6,]]
- #'C': [[1,0],[2,1],[3,0],[4,2],[5,3],[6,0]], 'D': [[1,2],[2,3],[3,2],[4,0],[5,'x'],[6,'x']], 'E': [[1,0],[2,0],[3,1][4,2],[5,2],[6,0]],
- #'F': [[1,'x'],[2,1],[3,2][4,3],[5,3],[6,'x']], 'G': [[1,3],[2,0],[3,0][4,0],[5,2],[6,3]], 'A': [[1,0],[2,2],[3,2][4,2],[5,0],[6,0]],
- #'B': [[1,2],[2,4],[3,4][4,4],[5,'x'],[6,'x']], 'Dm': [[1,1],[2,3],[3,2][4,0],[5,'x'],[6,'x']], 'Em': [[1,0],[2,0],[3,0][4,2],[5,2],[6,0]],
- #'Fm': [[1,4],[2,6],[3,5][4,3],[5,'x'],[6,'x']], 'Am': [[1,0],[2,1],[3,2][4,2],[5,0],[6,0]], 'Bm': [[1,2],[2,3],[3,4][4,4],[5,'x'],[6,'x']],
- #'C7': [[1,0],[2,1],[3,3][4,2],[5,3],[6,0]], 'D7': [[1,2],[2,1],[3,2][4,0],[5,'x'],[6,'x']], 'E7': [[1,0],[2,0],[3,1][4,0],[5,2],[6,0]],
- #'F7': [[1,'x'],[2,1],[3,2][4,1],[5,3],[6,'x']], 'G7': [[1,1],[2,0],[3,0][4,0],[5,2],[6,3]], 'A7': [[1,0],[2,2],[3,0][4,2],[5,0],[6,'x']],
- #'B7': [[1,2],[2,0],[3,2][4,1],[5,2],[6,'x']], 'D#': [[1,3],[2,4],[3,3][4,1],[5,'x'],[6,'x']], 'F#': [[1,6],[2,7],[3,6][4,4],[5,'x'],[6,'x']],
- #'C6': [[1,0],[2,1],[3,0][4,2],[5,0],[6,0]], 'D6': [[1,2],[2,3],[3,2][4,4],[5,'x'],[6,'x']], 'E6': [[1,0],[2,2],[3,1][4,2],[5,2],[6,'x']],
- #'F6': [[1,'x'],[2,1],[3,2][4,0],[5,'x'],[6,1]], 'G6': [[1,'x'],[2,3],[3,4][4,2],[5,'x'],[6,3]], 'A6': [[1,2],[2,2],[3,2][4,2],[5,0],[6,'x']],
- #'B6': [[1,4],[2,4],[3,4][4,4],[5,'x'],[6,'x']], 'Cm7': [[1,'x'],[2,1],[3,3][4,1],[5,3],[6,'x']], 'Dm7': [[1,1],[2,1],[3,2][4,0],[5,'x'],[6,'x']],
- #'Em7': [[1,0],[2,0],[3,0][4,0],[5,2],[6,0]], 'Fm7': [[1,1],[2,1],[3,1][4,1],[5,'x'],[6,'x']], 'Gm7': [[1,3],[2,3],[3,3][4,3],[5,'x'],[6,'x']],
- #'Am7': [[1,0],[2,1],[3,0][4,2],[5,0],[6,'x']], 'Bm7': [[1,2],[2,3],[3,2][4,0],[5,2],[6,'x']], 'Asus2': [[1,0],[2,0],[3,2][4,2],[5,0],[6,'x']]}
- chords_barre = {}
- # PRINT THE CHORD ON THE NECK/FRETBOARD
- def print_chord(newchord,var): # takes the chord-array and a variation (regular, barre, all, etc)
- # global necknotes = [string,fret,note]
- chord_on_neck = []
- for x in global_necknotes:
- if global_necknotes[x][2] in newchord:
- chord_on_neck.append(global_necknotes[x])
- if var == "all":
- for q in chord_on_neck:
- if q[1] != 0:
- hpos = 1 + (q[1] * 4)
- guitar.chgat(q[0],hpos,len(q[2]),curses.A_REVERSE)
- if var == "regular":
- count = 1
- chord_check = []
- from operator import itemgetter
- chord_on_neck.sort(key=itemgetter(0))
- for p,sublist in enumerate(chord_on_neck):
- if count == sublist[0]: # iterate over all strings
- shorthand.addstr(count,2,str(sublist[1])) # add fretnumbers on stringpositions in shorthand-box
- chord_check.append(sublist[2]) # build a list of the chords that were found
- if sublist[1] != 0: # unless the note has been found on an open string:
- hpos = 1 + (sublist[1] * 4) # get the correct fret
- guitar.chgat(sublist[0],hpos,len(sublist[2]),curses.A_REVERSE) # make the position bold
- count = count + 1
- # check for missing notes:
- missing = []
- count_chk = 1
- for i in newchord:
- if i not in chord_check:
- missing.append(i)
- # if we are indeed missing something:
- if len(missing) > 0:
- for m in missing:
- for z,sublist in enumerate(chord_on_neck):
- myscreen.addstr(41+count_chk,1,str(sublist))
- if m == sublist[2] and sublist[1] < 5:
- #missing.remove(m)
- shorthand.addstr(count_chk,2,str(sublist[1]))
- hpos = 1 + (sublist[1] * 4)
- guitar.chgat(sublist[0],hpos,len(sublist[2]),curses.A_REVERSE)
- break
- # STILL NOT WORKING, TRY AM9 or something like that.
- myscreen.addstr(30,1,str(chord_on_neck))
- myscreen.addstr(40,1,str(chord_check))
- myscreen.addstr(41,1,str(missing))
- guitar.refresh()
- shorthand.refresh()
- #print_chord(chord,0)
- chord_section = myscreen.derwin(4,75,24,subnotes_section_hpos)
- draw_guitar(0,0)
- #build_chord(current_note,current_subnote)
- print_subnotes()
- subnotes_section.chgat(1,1,13,curses.A_REVERSE)
- subnotes_section.refresh()
- # END OF CHORD SECTION
- # NAVIGATION
- def tab(win,vpos,hpos): # function for tabbing between notes and subnotes sections
- if win == 1: # current window = notes_section
- subnotes_section.chgat(vpos,hpos,13,curses.A_REVERSE)
- subnotes_section.addstr(0,5,'[Subnotes]',curses.A_BOLD) # bold title
- myscreen.addstr(9,(notes_section_hpos - 9),'[Notes]',curses.A_NORMAL) # unbold title
- notes_section.refresh()
- subnotes_section.refresh()
- return 2
- elif win == 2: # current window = subnotes_section
- notes_section.chgat(vpos,hpos,2,curses.A_REVERSE)
- subnotes_section.addstr(0,5,'[Subnotes]',curses.A_NORMAL) # unbold title
- myscreen.addstr(9,(notes_section_hpos - 9),'[Notes]',curses.A_BOLD) # bold title
- notes_section.refresh()
- subnotes_section.refresh()
- return 1
- def navigate_notes_section(vpos,hpos,note,key):
- if key == 'up' or key == 'down':
- () # can't go up or down from the notes section
- elif key == 'right':
- if note < 12:
- hpos = hpos + 2 + len(guitarnotes[note])
- note = note + 1
- else:
- note = 1
- hpos = 1
- elif key == 'left':
- if note > 1:
- note = note - 1
- hpos = hpos - 2 - len(guitarnotes[note])
- else:
- note = 12
- hpos = 39
- notes_section.clrtoeol() # erase the content, then redraw it
- print_notes()
- notes_section.chgat(vpos,hpos,2,curses.A_REVERSE)
- notes_section.refresh()
- return vpos,hpos,note
- def navigate_subnotes_section(vpos,hpos,subnote,key): # function for moving between values
- attr = curses.A_BOLD
- if key == 'up':
- if vpos > 1: # if we can still go up
- vpos = vpos - 1 # go up
- subnote = subnote - 1 # go one subnote back
- else: # if we cannot go up
- vpos = 10 # go to column bottom...
- if hpos > 15: # check to see if we're in the 1st column
- hpos = hpos - 15 # move a column back
- subnote = subnote - 1 # move a subnote back
- else: # if we're in the first column
- hpos = 61 # jump to last column
- subnote = 50 # jump to last subnote
- elif key == 'down':
- if vpos < 10: # if we can still go down
- vpos = vpos + 1 # go down
- subnote = subnote + 1 # go one subnote forward
- else: # if we cannot go down
- vpos = 1 # go to column top
- if hpos < 61: # if we're note in the last column
- hpos = hpos + 15 # move a column forward
- subnote = subnote + 1 # move a subnote forward
- else: # if we're in the last column
- hpos = 1 # jump to first column
- subnote = 1 # jump to first subnote
- elif key == 'left':
- if hpos > 15: # if we're not in the first column
- hpos = hpos - 15 # move a column back
- subnote = subnote - 10
- else: # if we're in the first column
- hpos = 61 # jump to last column
- subnote = subnote + 40 # jump to last subnote in last column
- elif key == 'right':
- if hpos < 61: # if we're not in the last column
- hpos = hpos + 15 # move a column to the right
- subnote = subnote + 10
- else:
- hpos = 1 # jump to first column
- subnote = subnote - 40 # jump to first subnote
- elif key == 'refresh':
- if current_window == 1:
- attr = curses.A_NORMAL
- else:
- attr = curses.A_BOLD
- subnotes_section.clrtobot() # erase the content, then redraw it
- print_subnotes()
- subnotes_section.addstr(0,5,'[Subnotes]',attr)
- subnotes_section.chgat(vpos,hpos,13,curses.A_REVERSE)
- subnotes_section.refresh()
- return vpos,hpos,subnote
- # END OF NAVIGATION
- # CAPTURE KEYPRESSES
- while True:
- key = myscreen.getch()
- if key == ord('q'): break # 'q' = quit
- elif key == ord('\t'): # TAB: move between notes_section and subnotes_section
- if current_window == 1:
- current_window = tab(current_window,ss_cursor_vpos,ss_cursor_hpos)
- elif current_window == 2:
- current_window = tab(current_window,ns_cursor_vpos,ns_cursor_hpos)
- elif key == curses.KEY_UP:
- if current_window == 1:
- ns_cursor_vpos,ns_cursor_hpos,current_note = navigate_notes_section(ns_cursor_vpos,ns_cursor_hpos,current_note,'up')
- elif current_window == 2:
- ss_cursor_vpos,ss_cursor_hpos,current_subnote = navigate_subnotes_section(ss_cursor_vpos,ss_cursor_hpos,current_subnote,'up')
- elif key == curses.KEY_DOWN:
- if current_window == 1:
- ns_cursor_vpos,ns_cursor_hpos,current_note = navigate_notes_section(ns_cursor_vpos,ns_cursor_hpos,current_note,'down')
- elif current_window == 2:
- ss_cursor_vpos,ss_cursor_hpos,current_subnote = navigate_subnotes_section(ss_cursor_vpos,ss_cursor_hpos,current_subnote,'down')
- elif key == curses.KEY_LEFT:
- if current_window == 1:
- ns_cursor_vpos,ns_cursor_hpos,current_note = navigate_notes_section(ns_cursor_vpos,ns_cursor_hpos,current_note,'left')
- elif current_window == 2:
- ss_cursor_vpos,ss_cursor_hpos,current_subnote = navigate_subnotes_section(ss_cursor_vpos,ss_cursor_hpos,current_subnote,'left')
- elif key == curses.KEY_RIGHT:
- if current_window == 1:
- ns_cursor_vpos,ns_cursor_hpos,current_note = navigate_notes_section(ns_cursor_vpos,ns_cursor_hpos,current_note,'right')
- elif current_window == 2:
- ss_cursor_vpos,ss_cursor_hpos,current_subnote = navigate_subnotes_section(ss_cursor_vpos,ss_cursor_hpos,current_subnote,'right')
- elif key == ord('\n'): # ENTER
- draw_guitar(0,0)
- build_scale(current_note,scale)
- ss_cursor_vpos,ss_cursor_hpos,current_subnote = navigate_subnotes_section(ss_cursor_vpos,ss_cursor_hpos,current_subnote,'refresh')
- elif key == curses.KEY_F2: # F2: switch notetype (A#/Bb)
- caller_id = 2 # the caller-id for this function
- if guitarnotes == note_type_1:
- guitarnotes = note_type_2
- global_necknotes = build_necknotes(global_tuning)
- global_guitar_notetype = draw_guitar(caller_id,0)
- elif guitarnotes == note_type_2:
- guitarnotes = note_type_1
- global_necknotes = build_necknotes(global_tuning)
- global_guitar_notetype = draw_guitar(caller_id,1)
- print_notes()
- navigate_notes_section(ns_cursor_vpos,ns_cursor_hpos,current_note,'up') # to refresh the notes section
- build_scale(current_note,scale)
- build_chord(current_note,current_subnote)
- ss_cursor_vpos,ss_cursor_hpos,current_subnote = navigate_subnotes_section(ss_cursor_vpos,ss_cursor_hpos,current_subnote,'refresh')
- elif key == curses.KEY_F3: # F3: toggle display of notes on/off
- caller_id = 3
- guitar_show_what = draw_guitar(caller_id,guitar_show_what)
- # _TODO: make it resizable.
- curses.endwin()
Advertisement
Add Comment
Please, Sign In to add comment