From: Jan Nieuwenhuizen Date: Tue, 22 Mar 2011 20:20:43 +0000 (+0100) Subject: Midi2ly: if --duration-quant == first note, still write duration. Fixes #1575. X-Git-Tag: release/2.13.56-1~10^2~7 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0731fb9689967fd00afc28e2e530d9c7f0887b46;p=lilypond.git Midi2ly: if --duration-quant == first note, still write duration. Fixes #1575. Reported my Martin Tarenskeen. --- diff --git a/input/regression/midi/quantize-duration-2.ly b/input/regression/midi/quantize-duration-2.ly new file mode 100644 index 0000000000..1944b2d4ae --- /dev/null +++ b/input/regression/midi/quantize-duration-2.ly @@ -0,0 +1,59 @@ +% Lily was here -- automatically converted by out/bin/midi2ly from /home/janneke/testmidi.mid +\version "2.13.53" + +\layout { + \context { + \Voice + \remove "Note_heads_engraver" + \consists "Completion_heads_engraver" + \remove "Rest_engraver" + \consists "Completion_rest_engraver" + } +} + +\header { +texidoc="midi2ly @code{--duration-quant} preserves first note length (16)" +options="--duration-quant=16" +} + +trackAchannelA = { + + + \key a \major + + % [TEXT_EVENT] Nokia Tune + + \tempo 4 = 120 + + + \key a \major + + \time 3/8 + +} + +trackA = << + \context Voice = voiceA \trackAchannelA +>> + + +trackBchannelB = \relative c { + e'''4*41/192 r4*7/192 d4*41/192 r4*7/192 fis,4*89/192 r4*7/192 gis4*89/192 + r4*7/192 + | % 2 + cis4*41/192 r4*7/192 b4*41/192 r4*7/192 d,4*89/192 r4*7/192 e4*89/192 +} + +trackB = << + \context Voice = voiceA \trackBchannelB +>> + + +\score { + << + \context Staff=trackB \trackA + \context Staff=trackB \trackB + >> + \layout {} + \midi {} +} diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index 82cfa963de..60a2febde0 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -111,8 +111,6 @@ class Duration: allowed_durs = (1, 2, 4, 8, 16, 32, 64, 128) def __init__ (self, clocks): self.clocks = clocks - if clocks <= 0: - self.clocks = duration_quant_clocks (self.dur, self.num, self.den) = self.dur_num_den (clocks) def dur_num_den (self, clocks): @@ -140,8 +138,7 @@ class Duration: s = '%d*%d/%d' % (self.dur, self.num, self.den) global reference_note - if reference_note: # debugging - reference_note.duration = self + reference_note.duration = self return s @@ -663,7 +660,6 @@ def dump_chord (ch): for i in notes[1:]: s = s + i.dump (dump_dur=False) s = s + '>' - s = s + notes[0].duration.dump () + ' ' reference_note = r return s