From eb0c8399c37d7d58c904622fc7947b34ee245b9d Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 17 Oct 2001 23:44:39 +0200 Subject: [PATCH] patch::: 1.5.17.jcn5 1.5.17.jcn5 - aka: `pgwit! Ah, dacht dat-i zo wel aardig was.' --- CHANGES | 5 +++- VERSION | 2 +- input/test/midi-scales.ly | 62 +++++++++++++++++++-------------------- scripts/midi2ly.py | 42 ++++++++++++++++++++++---- 4 files changed, 72 insertions(+), 39 deletions(-) diff --git a/CHANGES b/CHANGES index b89700fb6f..8dc35c4df8 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -1.5.17.jcn4 - aka: `pgwit! Ah, dacht dat-i zo wel aardig was.' +1.5.17.jcn5 - aka: `pgwit! Ah, dacht dat-i zo wel aardig was.' =========== * Some more hacking at midi2ly.py: @@ -11,6 +11,9 @@ - don't include empty staffs in score - print relative pitches by default - don't repeat duration by default + - bugfix: allow 8th notes too + - include new version of input/test/midi-scales.ly + - added barchecks * Shorter MIDI creation texts. diff --git a/VERSION b/VERSION index 99f7b2e514..74e93a0f36 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=5 PATCH_LEVEL=17 -MY_PATCH_LEVEL=jcn4 +MY_PATCH_LEVEL=jcn5 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/midi-scales.ly b/input/test/midi-scales.ly index 9a31e5231f..1383129387 100644 --- a/input/test/midi-scales.ly +++ b/input/test/midi-scales.ly @@ -2,98 +2,98 @@ texidoc="MIDI and midi2ly test file. Diff between this and midi2ly.py (experimental, 1.5.17) should be minimal" } -scales = \notes { +scales = \notes \relative c { % [INSTRUMENT_NAME] bright acoustic \key c \major % sharp-major - c4 d4 e4 f4 g4 a4 b4 c4 + c' d e f g a b c \key g \major - g4 a4 b4 c4 d4 e4 fis4 g4 + g a b c d e fis g \key d \major - d4 e4 fis4 g4 a4 b4 cis4 d4 + d, e fis g a b cis d \key a \major - a4 b4 cis4 d4 e4 fis4 gis4 a4 + a b cis d e fis gis a \key e \major - e4 fis4 gis4 a4 b4 cis4 dis4 e4 + e, fis gis a b cis dis e \key b \major - b4 cis4 dis4 e4 fis4 gis4 ais4 b4 + b cis dis e fis gis ais b \key fis \major - fis4 gis4 ais4 b4 cis4 dis4 eis4 fis4 + fis, gis ais b cis dis eis fis \key cis \major - cis4 dis4 eis4 fis4 gis4 ais4 bis4 cis4 + cis, dis eis fis gis ais bis cis \key a \minor % sharp-minor - a4 b4 c4 d4 e4 f4 gis4 a4 + a b c d e f gis a \key e \minor - e4 fis4 g4 a4 b4 c4 dis4 e4 + e, fis g a b c dis e \key b \minor - b4 cis4 d4 e4 fis4 g4 ais4 b4 + b cis d e fis g ais b \key fis \minor - fis4 gis4 a4 b4 cis4 d4 eis4 fis4 + fis, gis a b cis d eis fis \key cis \minor - cis4 dis4 e4 fis4 gis4 a4 bis4 cis4 + cis, dis e fis gis a bis cis \key gis \minor - gis4 ais4 b4 cis4 dis4 e4 fisis4 gis4 + gis ais b cis dis e fisis gis \key dis \minor - dis4 eis4 fis4 gis4 ais4 b4 cisis4 dis4 + dis, eis fis gis ais b cisis dis \key ais \minor - ais4 bis4 cis4 dis4 eis4 fis4 gisis4 ais4 + ais bis cis dis eis fis gisis ais \key f \major % flat-major - f4 g4 a4 bes4 c4 d4 e4 f4 + f, g a bes c d e f \key bes \major - bes4 c4 d4 ees4 f4 g4 a4 bes4 + bes c d ees f g a bes \key ees \major - ees4 f4 g4 aes4 bes4 c4 d4 ees4 + ees,, f g aes bes c d ees \key aes \major - aes4 bes4 c4 des4 ees4 f4 g4 aes4 + aes, bes c des ees f g aes \key des \major - des4 ees4 f4 ges4 aes4 bes4 c4 des4 + des,, ees f ges aes bes c des \key ges \major - ges4 aes4 bes4 ces'4 des4 ees4 f4 ges4 + ges, aes bes ces des ees f ges \key ces \major - ces'4 des4 ees4 fes4 ges4 aes4 bes4 ces'4 + ces,, des ees fes ges aes bes ces \key d \minor % flat-minor - d4 e4 f4 g4 a4 bes4 cis4 d4 + d, e f g a bes cis d \key g \minor - g4 a4 bes4 c4 d4 ees4 fis4 g4 + g, a bes c d ees fis g \key c \minor - c4 d4 ees4 f4 g4 aes4 b4 c4 + c,, d ees f g aes b c \key f \minor - f4 g4 aes4 bes4 c4 des4 e4 f4 + f, g aes bes c des e f \key bes \minor - bes4 c4 des4 ees4 f4 ges4 a4 bes4 + bes,, c des ees f ges a bes \key ees \minor - ees4 f4 ges4 aes4 bes4 ces'4 d4 ees4 + ees, f ges aes bes ces d ees \key aes \minor - aes4 bes4 ces'4 des4 ees4 fes4 g4 aes4 + aes, bes ces des ees fes g aes } \score { diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index 2709adacc4..aadc17f24d 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -74,7 +74,7 @@ from lilylib import * class Duration: - allowed_durs = (1, 2, 4, 16, 32, 64, 128) + allowed_durs = (1, 2, 4, 8, 16, 32, 64, 128) def __init__ (self, clocks): self.clocks = clocks if clocks <= 0: @@ -88,7 +88,7 @@ class Duration: dur = 0; num = 1; den = 1; g = gcd (clocks, clocks_per_1) - if g and g > clocks / g: + if g: (dur, num) = (clocks_per_1 / g, clocks / g) if not dur in self.allowed_durs: dur = 4; num = clocks; den = clocks_per_4 @@ -242,7 +242,12 @@ class Time: self.num = num self.den = den + def bar_clocks (self): + return clocks_per_1 * self.num / self.den + def dump (self): + global time + time = self return '\n ' + '\\time %d/%d ' % (self.num, self.den) + '\n ' class Tempo: @@ -352,6 +357,7 @@ scale_steps = [0,2,4,5,7,9,11] clocks_per_1 = 1536 clocks_per_4 = 0 key = 0 +time = 0 reference_note = 0 start_quant = 0 start_quant_clocks = 0 @@ -585,10 +591,23 @@ def dump_chord (ch): reference_note = r return s +def dump_bar_line (last_bar_t, t, bar_count): + s = '' + bar_t = time.bar_clocks () + if t - last_bar_t >= bar_t: + bar_count = bar_count + (t - last_bar_t) / bar_t + + if t - last_bar_t == bar_t: + s = '|\n %% %d\n ' % bar_count + last_bar_t = t + return (s, last_bar_t, bar_count) + + def dump_channel (thread, skip): - global key, reference_note + global key, reference_note, time key = Key (0, 0, 0) + time = Time (4, 4) # urg LilyPond doesn't start at c4, but # remembers from previous tracks! # reference_note = Note (clocks_per_4, 4*12, 0) @@ -612,19 +631,26 @@ def dump_channel (thread, skip): chs.append ((last_e[0], ch)) t = 0 last_t = 0 - + last_bar_t = 0 + bar_count = 1 + lines = [''] for ch in chs: + t = ch[0] + i = string.rfind (lines[-1], '\n') + 1 if len (lines[-1][i:]) > LINE_BELL: lines.append ('') - t = ch[0] if t - last_t > 0: lines[-1] = lines[-1] + dump_skip (skip, t-last_t) elif t - last_t < 0: errorport.write ('BUG: time skew') - + + (s, last_bar_t, bar_count) = dump_bar_line (last_bar_t, + t, bar_count) + lines[-1] = lines[-1] + s + lines[-1] = lines[-1] + dump_chord (ch[1]) clocks = 0 @@ -633,6 +659,10 @@ def dump_channel (thread, skip): clocks = i.clocks last_t = t + clocks + + (s, last_bar_t, bar_count) = dump_bar_line (last_bar_t, + last_t, bar_count) + lines[-1] = lines[-1] + s return string.join (lines, '\n ') + '\n' -- 2.39.5