Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

new meta display - :m length

  • Loading branch information...
commit 33d433157dd0686043dbb15826b23e11c97a7f11 1 parent 4e6860b
@pstiasny authored
View
1  doc/index.md
@@ -325,6 +325,7 @@ bar
* `:m meter` display bar meter
* `:m number` display bar numbers
* `:m label` display labels
+* `:m length` display note lengths
`:m` with no argument cycles through available options.
View
2  vitabs/commands.py
@@ -517,7 +517,7 @@ def enable_continuous_playback(ed, params):
@map_command('m')
def set_visible_meta(ed, params):
- possible_meta = ['meter', 'number', 'label']
+ possible_meta = ['meter', 'number', 'label', 'length']
if len(params) == 1:
try:
View
4 vitabs/editor.py
@@ -156,6 +156,9 @@ def draw_bar(self, y, x, bar):
for i in chord.strings.keys():
if x < screen_width:
stdscr.addstr(y+i, x, str(chord.strings[i]), curses.A_BOLD)
+ # should it really be here?
+ if self.visible_meta == 'length':
+ stdscr.addstr(y - 1, x, music.len_str(chord.duration))
width = int(chord.duration / gcd)
x = x + width*2 + 1
if x + 1 < screen_width:
@@ -219,6 +222,7 @@ def redraw_status(self):
# position indicator
self.status_line.addstr(0, width - 8,
'{0},{1}'.format(self.tab.cursor_bar, self.tab.cursor_chord))
+ # note length indicator
self.status_line.addstr(0, width - 16,
str(self.tab.get_cursor_chord().duration))
# meter incomplete indicator
View
17 vitabs/music.py
@@ -13,10 +13,20 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from fractions import Fraction
+
notes = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B']
standard_E = [76, 71, 67, 62, 57, 52]
+length_names = {
+ 1 : 'W',
+ Fraction('1/2') : 'H',
+ Fraction('1/4') : 'Q',
+ Fraction('1/8') : 'E',
+ Fraction('1/16') : 'S'
+ }
+
def midi_to_note_name(note_num):
return notes[(note_num - 24) % len(notes)] + \
str((note_num - 24) / len(notes))
@@ -25,3 +35,10 @@ def tuning_str(tuning):
if tuning == standard_E:
return 'Standard E'
return ' '.join(reversed([midi_to_note_name(n) for n in tuning]))
+
+def len_str(length):
+ try:
+ return length_names[length]
+ except KeyError:
+ return str(length)
+
Please sign in to comment.
Something went wrong with that request. Please try again.