]> git.donarmstrong.com Git - lilypond.git/commitdiff
Midi2ly: if --duration-quant == first note, still write duration. Fixes #1575.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 22 Mar 2011 20:20:43 +0000 (21:20 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 22 Mar 2011 20:21:52 +0000 (21:21 +0100)
Reported my Martin Tarenskeen.

input/regression/midi/quantize-duration-2.ly [new file with mode: 0644]
scripts/midi2ly.py

diff --git a/input/regression/midi/quantize-duration-2.ly b/input/regression/midi/quantize-duration-2.ly
new file mode 100644 (file)
index 0000000..1944b2d
--- /dev/null
@@ -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 {}
+}
index 82cfa963de6ec40d7e4cff438e741cccd7b5b96b..60a2febde0b583fb7e3cf0a776594660167f0663 100644 (file)
@@ -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