Permalink
Browse files

pretty-print slides and hammers/pulls

  • Loading branch information...
1 parent 6729cc4 commit 63970df574fa5f0b2b6113f6bc43ea0a2125f9ac Dmitry Jemerov committed Dec 18, 2011
Showing with 19 additions and 2 deletions.
  1. +2 −0 gtpfile.py
  2. +17 −2 gtpprint.py
View
@@ -9,6 +9,8 @@ def __init__(self):
self.fret = None
self.string = None
self.duration = None
+ self.hammer = False
+ self.slide = False
def __str__(self):
result = "note("
View
@@ -1,13 +1,28 @@
from gtpfile import *
+def effect_character(note, bar, beat, string):
+ if not note.slide and not note.hammer: return "-"
+ if beat < len(bar.beats)-1:
+ next_beat = bar.beats[beat+1]
+ next_note = next_beat.note_at_string(string)
+ if not next_note: return "-"
+ if note.slide:
+ if next_note.fret > note.fret: return "/"
+ if next_note.fret < note.fret: return "\\"
+ if note.hammer:
+ if next_note.fret > note.fret: return "h"
+ if next_note.fret < note.fret: return "p"
+ return "-"
+
+
def print_string_in_bar(bar, string, min_duration):
result = "--"
- for beat in bar.beats:
+ for i, beat in enumerate(bar.beats):
duration_delta = min_duration - beat.duration
extra_dashes = 2 ** duration_delta
note = beat.note_at_string(string)
if note:
- result += "%d-" % note.fret
+ result += "%d" % note.fret + effect_character(note, bar, i, string)
else:
result += "--"
if duration_delta: result += "-" * extra_dashes

0 comments on commit 63970df

Please sign in to comment.