From 3ef09ea5cf542f2443113e4004b0e3928f319567 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 12 Mar 2011 21:03:22 +0100 Subject: [PATCH] Midi: start test suite. --- GNUmakefile.in | 2 + input/regression/GNUmakefile | 2 +- input/regression/midi/GNUmakefile | 13 +++++ input/regression/midi/key-initial.ly | 79 +++++++++++++++++++++++++ input/regression/midi/key-option.ly | 75 ++++++++++++++++++++++++ input/regression/midi/rest.ly | 63 ++++++++++++++++++++ input/regression/midi/voice-2.ly | 70 ++++++++++++++++++++++ input/regression/midi/voice-4.ly | 86 ++++++++++++++++++++++++++++ make/lilypond-vars.make | 1 + make/midi-rules.make | 18 ++++++ make/midi-targets.make | 7 +++ make/midi-vars.make | 10 ++++ 12 files changed, 425 insertions(+), 1 deletion(-) create mode 100644 input/regression/midi/GNUmakefile create mode 100644 input/regression/midi/key-initial.ly create mode 100644 input/regression/midi/key-option.ly create mode 100644 input/regression/midi/rest.ly create mode 100644 input/regression/midi/voice-2.ly create mode 100644 input/regression/midi/voice-4.ly create mode 100644 make/midi-rules.make create mode 100644 make/midi-targets.make create mode 100644 make/midi-vars.make diff --git a/GNUmakefile.in b/GNUmakefile.in index f8e1d15e7c..3809d03ad3 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -254,6 +254,7 @@ test: @echo ' grep sourcefilename `grep -L systems.texi out/lybook-testdb/*/*log|sed s/log/ly/g`' @echo $(MAKE) -C input/regression out=test local-test + $(MAKE) -C input/regression/midi out=test local-test $(MAKE) -C input/regression/musicxml out=test local-test $(MAKE) -C input/regression/abc2ly out=test local-test $(MAKE) -C input/regression/lilypond-book out=test local-test @@ -265,6 +266,7 @@ test-baseline: $(MAKE) $(MAKE) test $(MAKE) out=test -C input/regression local-test-baseline + $(MAKE) out=test -C input/regression/midi local-test-baseline $(MAKE) out=test -C input/regression/musicxml local-test-baseline $(MAKE) out=test -C input/regression/abc2ly local-test-baseline $(MAKE) out=test -C input/regression/lilypond-book local-test-baseline diff --git a/input/regression/GNUmakefile b/input/regression/GNUmakefile index e0c023d667..cc769e7c2f 100644 --- a/input/regression/GNUmakefile +++ b/input/regression/GNUmakefile @@ -6,4 +6,4 @@ LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc include $(depth)/make/stepmake.make TITLE=LilyPond Regression Tests -SUBDIRS=musicxml abc2ly lilypond-book +SUBDIRS=midi musicxml abc2ly lilypond-book diff --git a/input/regression/midi/GNUmakefile b/input/regression/midi/GNUmakefile new file mode 100644 index 0000000000..682bf82db5 --- /dev/null +++ b/input/regression/midi/GNUmakefile @@ -0,0 +1,13 @@ +depth = ../../.. + +STEPMAKE_TEMPLATES=documentation texinfo tex +LOCALSTEPMAKE_TEMPLATES=lilypond ly lysdoc midi + +TEXI2HTML_FLAGS += --nomenu + +TMP = $(sort $(LY_FILES) $(TEXINFO_SOURCES) ) +COLLATED_FILES = ${TMP:%.ly=$(outdir)/%-midi.ly} + +include $(depth)/make/stepmake.make + +TITLE=MIDI test suite diff --git a/input/regression/midi/key-initial.ly b/input/regression/midi/key-initial.ly new file mode 100644 index 0000000000..c663dec07f --- /dev/null +++ b/input/regression/midi/key-initial.ly @@ -0,0 +1,79 @@ +% Lily was here -- automatically converted by ../../../scripts/midi2ly.py from out/initial-key.midi +\version "2.13.53" + +\layout { + \context { + \Voice + \remove "Note_heads_engraver" + \consists "Completion_heads_engraver" + \remove "Rest_engraver" + \consists "Completion_rest_engraver" + } +} + +% included from ./out/initial-key.header +\header { +texidoc="keys work in MIDI, this is a-minor" +options="" +} +% end + +trackAchannelA = { + + + \key a \minor + + % [SEQUENCE_TRACK_NAME] control track + + % [TEXT_EVENT] creator: + + % [TEXT_EVENT] GNU LilyPond 2.13.54 + + \time 4/4 + + \tempo 4 = 60 + +} + +trackA = << + \context Voice = voiceA \trackAchannelA +>> + + +trackBchannelA = \relative c { + + \set Staff.instrumentName = "trackB:voiceA" + a'4 b c d + | % 2 + e f gis a + | % 3 + +} + +trackB = << + \context Voice = voiceA \trackBchannelA +>> + + +trackCchannelA = { + + \set Staff.instrumentName = "trackB:" + + + \key a \minor + +} + +trackC = << + \context Voice = voiceA \trackCchannelA +>> + + +\score { + << + \context Staff=trackB \trackA + \context Staff=trackB \trackB + >> + \layout {} + \midi {} +} diff --git a/input/regression/midi/key-option.ly b/input/regression/midi/key-option.ly new file mode 100644 index 0000000000..175a7a8696 --- /dev/null +++ b/input/regression/midi/key-option.ly @@ -0,0 +1,75 @@ +% Lily was here -- automatically converted by ../../../scripts/midi2ly.py from out-www/option-key.midi +\version "2.13.53" + +\layout { + \context { + \Voice + \remove "Note_heads_engraver" + \consists "Completion_heads_engraver" + \remove "Rest_engraver" + \consists "Completion_rest_engraver" + } +} + +% included from ./out-www/option-key.header +\header { +texidoc="--key works in midi2ly this is F major" +options="--key=-1" +} +% end + +trackAchannelA = { + + + % [SEQUENCE_TRACK_NAME] control track + + % [TEXT_EVENT] creator: + + % [TEXT_EVENT] GNU LilyPond 2.13.54 + + \time 4/4 + + \tempo 4 = 60 + +} + +trackA = << + \context Voice = voiceA \trackAchannelA +>> + + +trackBchannelA = \relative c { + + \set Staff.instrumentName = "trackB:voiceA" + f'4 g a bes + | % 2 + c d e f + | % 3 + +} + +trackB = << + \context Voice = voiceA \trackBchannelA +>> + + +trackCchannelA = { + + \set Staff.instrumentName = "trackB:" + + +} + +trackC = << + \context Voice = voiceA \trackCchannelA +>> + + +\score { + << + \context Staff=trackB \trackA + \context Staff=trackB \trackB + >> + \layout {} + \midi {} +} diff --git a/input/regression/midi/rest.ly b/input/regression/midi/rest.ly new file mode 100644 index 0000000000..4013296015 --- /dev/null +++ b/input/regression/midi/rest.ly @@ -0,0 +1,63 @@ +% Lily was here -- automatically converted by ../../../scripts/midi2ly.py from out-www/rest.midi +\version "2.13.53" + +\layout { + \context { + \Voice + \remove "Note_heads_engraver" + \consists "Completion_heads_engraver" + \remove "Rest_engraver" + \consists "Completion_rest_engraver" + } +} + +% included from ./out-www/rest.header +\header { +texidoc="midi2ly identifies rests" +options="" +} +% end + +trackAchannelA = { + + % [SEQUENCE_TRACK_NAME] control track + + % [TEXT_EVENT] creator: + + % [TEXT_EVENT] GNU LilyPond 2.13.54 + + \time 4/4 + + \tempo 4 = 60 + +} + +trackA = << + \context Voice = voiceA \trackAchannelA +>> + + +trackBchannelA = \relative c { + r4 + \set Staff.instrumentName = "trackB:voiceA" + a r4 a + | % 2 + +} + +trackB = << + + \clef bass + + \context Voice = voiceA \trackBchannelA +>> + + +\score { + << + \context Staff=trackB \trackA + \context Staff=trackB \trackB + >> + \layout {} + \midi {} +} diff --git a/input/regression/midi/voice-2.ly b/input/regression/midi/voice-2.ly new file mode 100644 index 0000000000..e12345e56e --- /dev/null +++ b/input/regression/midi/voice-2.ly @@ -0,0 +1,70 @@ +% Lily was here -- automatically converted by ../../../scripts/midi2ly.py from out-www/voice-2.midi +\version "2.13.53" + +\layout { + \context { + \Voice + \remove "Note_heads_engraver" + \consists "Completion_heads_engraver" + \remove "Rest_engraver" + \consists "Completion_rest_engraver" + } +} + +% included from ./out-www/voice-2.header +\header { +texidoc="midi2ly maps two voices nicely on once staff as \voiceOne, \voiceTwo" +options="" +} +% end + +trackAchannelA = { + + % [SEQUENCE_TRACK_NAME] control track + + % [TEXT_EVENT] creator: + + % [TEXT_EVENT] GNU LilyPond 2.13.54 + + \time 4/4 + + \tempo 4 = 60 + +} + +trackA = << + \context Voice = voiceA \trackAchannelA +>> + + +trackBchannelA = \relative c { + \voiceOne + + \set Staff.instrumentName = ":1" + e''4 e e e + | % 2 + +} + +trackBchannelB = \relative c { + \voiceTwo + f' f f f + | % 2 + +} + +trackB = << + \context Voice = voiceA \trackBchannelA + \context Voice = voiceB \trackBchannelB +>> + + +\score { + << + \set Score.midiChannelMapping = #'voice + \context Staff=trackB \trackA + \context Staff=trackB \trackB + >> + \layout {} + \midi {} +} diff --git a/input/regression/midi/voice-4.ly b/input/regression/midi/voice-4.ly new file mode 100644 index 0000000000..23d87b7613 --- /dev/null +++ b/input/regression/midi/voice-4.ly @@ -0,0 +1,86 @@ +% Lily was here -- automatically converted by ../../../scripts/midi2ly.py from out-www/voice-4.midi +\version "2.13.53" + +\layout { + \context { + \Voice + \remove "Note_heads_engraver" + \consists "Completion_heads_engraver" + \remove "Rest_engraver" + \consists "Completion_rest_engraver" + } +} + +% included from ./out-www/voice-4.header +\header { +texidoc="midi2ly maps four voices nicely on once staff as \voiceOne, \voiceTwo, \voiceThree, \voiceFour" +options="" +} +% end + +trackAchannelA = { + + % [SEQUENCE_TRACK_NAME] control track + + % [TEXT_EVENT] creator: + + % [TEXT_EVENT] GNU LilyPond 2.13.54 + + \time 4/4 + + \tempo 4 = 60 + +} + +trackA = << + \context Voice = voiceA \trackAchannelA +>> + + +trackBchannelA = \relative c { + \voiceOne + + \set Staff.instrumentName = ":1" + 2 b + | % 2 + +} + +trackBchannelB = \relative c { + \voiceThree + c''4. d8 e4 f + | % 2 + +} + +trackBchannelC = \relative c { + \voiceFour + d'1 + | % 2 + +} + +trackBchannelD = \relative c { + \voiceTwo + c'4 c2 c4 + | % 2 + +} + +trackB = << + \context Voice = voiceA \trackBchannelA + \context Voice = voiceB \trackBchannelB + \context Voice = voiceC \trackBchannelC + \context Voice = voiceD \trackBchannelD +>> + + +\score { + << + \set Score.midiChannelMapping = #'voice + \context Staff=trackB \trackA + \context Staff=trackB \trackB + >> + \layout {} + \midi {} +} diff --git a/make/lilypond-vars.make b/make/lilypond-vars.make index d1c7cd2fea..cf1bc11203 100644 --- a/make/lilypond-vars.make +++ b/make/lilypond-vars.make @@ -22,6 +22,7 @@ export PYTHONPATH:=$(top-build-dir)/python/$(outconfbase):$(PYTHONPATH) the-script-dir=$(wildcard $(script-dir)) ABC2LY = $(script-dir)/abc2ly.py +MIDI2LY = $(script-dir)/midi2ly.py MUSICXML2LY = $(script-dir)/musicxml2ly.py CONVERT_LY = $(script-dir)/convert-ly.py LILYPOND_BOOK = $(script-dir)/lilypond-book.py diff --git a/make/midi-rules.make b/make/midi-rules.make new file mode 100644 index 0000000000..219eb262ce --- /dev/null +++ b/make/midi-rules.make @@ -0,0 +1,18 @@ +.SUFFIXES: .midi + +$(outdir)/%.ly: %.midi + $(PYTHON) $(MIDI2LY) -o $(outdir) $< + +$(outdir)/%.midi: %.ly $(LILYPOND_BINARY) + touch $(foreach f, $(HEADER_FIELDS), $(outdir)/$*.$f) + $(LILYPOND_BINARY) $(HEADER_FIELDS:%=-H %) -o $(outdir) $< + +$(outdir)/%-midi.ly: $(outdir)/%.midi $(MIDI2LY) + (echo '\header {'; for f in $(HEADER_FIELDS); do echo -n $$f'="'; cat $(outdir)/$*.$$f; echo '"'; done; echo '}') > $(outdir)/$*.header + $(PYTHON) $(MIDI2LY) $(shell cat $(outdir)/$*.options) --include-header=$(outdir)/$*.header -o $(outdir) $< + +$(outdir)/%.diff: %.ly $(outdir)/%-midi.ly + $(DIFF) -puN $(MIDI2LY_IGNORE_RES) $^ > $@ || cat $@ + +$(outdir)/midi.diff: $(OUT_DIFF_FILES) + cat $(OUT_DIFF_FILES) > $@ diff --git a/make/midi-targets.make b/make/midi-targets.make new file mode 100644 index 0000000000..e462465a9e --- /dev/null +++ b/make/midi-targets.make @@ -0,0 +1,7 @@ +default: + +##local-test: $(outdir)/midi.diff + +check: $(outdir)/midi.diff local-WWW-1 local-WWW-2 + +test: check diff --git a/make/midi-vars.make b/make/midi-vars.make new file mode 100644 index 0000000000..7b3a27613f --- /dev/null +++ b/make/midi-vars.make @@ -0,0 +1,10 @@ +MIDI_FILES = $(call src-wildcard,*.midi) +HEADER_FILES = $(call src-wildcard,*.header) +OUT_LY_FILES = $(sort ${MIDI_FILES:%.midi=$(outdir)/%.ly} ${LY_FILES:%.ly=$(outdir)/%-midi.ly} ) +OUT_FILES = $(OUT_LY_FILES) +HEADER_FIELDS = texidoc options +OUT_DIFF_FILES = ${LY_FILES:%.ly=$(outdir)/%.diff} +MIDI2LY_IGNORE_RES = -I 'Lily was here' -I '^\\version ' -I 'TEXT_EVENT.*GNU LilyPond' -I '^% included from' +DIFF = diff + +EXTRA_DIST_FILES += $(MIDI_FILES) $(HEADER_FILES) -- 2.39.2