Hallo,
ich arbeite noch immer sehr gut mit dieser Lösung, möchte jetzt aber zusätzlich die MIDI Erzeugung nun nicht nur pro Takt, sondern pro Zeile ausgeben.
Das geht sozusagen in die Richtung, die Takte definieren zu können. So wie ich es im Titel dieses Posts ursprünglich erwähnte. Bisher war das nicht nötig. Jetzt erstelle ich Übungen, bei denen es sinnvoll wäre, auch die gesamte Zeile als eine MIDI Datei auszugeben, da eine Zeile einer vollständigen Übung entspricht.
Hier ein Beispielcode für diese Übungen:
\version "2.18.2"
midiOut =
#(define-void-function (parser location m)(ly:music?)
(let* ((elts (ly:music-property m 'elements)))
; (display-scheme-music elts)
(if (null? elts)
;; do nothing if elts are empty
#f
(let (;; make a midi from every entry of elts
(scores
(map
(lambda (e) #{ \score { \new DrumStaff $e \midi {\tempo 4 = 120} } #})
elts)))
;; return them, each as a new book
(for-each
(lambda (score name)
(let* ((my-new-book
(ly:make-book
$defaultpaper
$defaultheader
score)))
(ly:book-process
my-new-book
$defaultpaper
$defaultmidi
;; add increasing numbers to the name
(format #f "~a-test" name))))
scores
(iota (length elts) 1 1))))))
#(define counter 1)
my-staff-count-mod =
\with {
instrumentName = "1"
shortInstrumentName = ""
\override InstrumentName.after-line-breaking =
#(lambda (grob)
(ly:grob-set-property! grob 'text
(format #f "~5a" (number->string counter)))
(set! counter (1+ counter)))
%% Ausrichten und Positionieren der Handsatz Markierung
\override TextScript.padding = 4
%%\once \textLengthOn
%%\once \override TextScript.X-offset = #-0.4
}
%% Schlagzeugvorlage
%%#(set-default-paper-size "a4" 'landscape)
\header { tagline = ##f }
\layout {
indent = #0
line-width = #160
%%\set Score.currentBarNumber = #
}
\paper {
fonts = #
(make-pango-font-tree
"Calibri"
"Calibri"
"sans"
(/ (* staff-height pt) 2.5))
print-page-number = ##f
%% Definition von Rändern und Abständen
#(define left-margin (* 3.5 cm))
#(define top-margin (* 1.5 cm))
#(define bottom-margin (* 1.5 cm))
%% Abstände zwischen den Systemen & Verhindern eines weißen Randes am Seitenende
system-system-spacing = #'((padding . 0.4) (basic-distance . 12))
%%page-count = #10 (Seitenzahl kann erzwungen werden - optional)
systems-per-page = #2 %% (Systeme pro Seite können erzwungen werden - optional)
%%ragged-last-bottom = ##f
%%ragged-bottom = ##f
}
AoBtvPdN= {\drummode { <tomh bd> 8^"L" tommh8^"R" <tomml bd hhp> 8^"R" tomh8^"L" <tomh bd> 8^"L" tomh8^"L" <sn bd hhp> 8^"L" tommh8^"R" } }
wmYmsIVY= {\drummode { <sn bd> 8^"L" tomml8^"R" <tomml bd hhp> 8^"R" tomh8^"L" <sn bd> 8^"L" tomh8^"L" <tomh bd hhp> 8^"L" tomml8^"R" } }
PIIqmtbv= {\drummode { <sn bd> 8^"L" tommh8^"R" <tomml bd hhp> 8^"R" sn8^"L" <sn bd> 8^"L" sn8^"L" <sn bd hhp> 8^"L" tommh8^"R" } }
xfOnhjHj= {\drummode { <tomh bd> 8^"L" tommh8^"R" <tommh bd hhp> 8^"R" tomh8^"L" <tomh bd> 8^"L" tomh8^"L" <tomh bd hhp> 8^"L" tommh8^"R" } }
PMYqyUVM= {\drummode { <tomml bd> 8^"R" tomml8^"R" <tomml bd hhp> 8^"R" tomml8^"R" <sn bd> 8^"L" tomml8^"R" <sn bd hhp> 8^"L" tomml8^"R" } }
sDfKRgPb= {\drummode { <tommh bd> 8^"R" tomml8^"R" <tomml bd hhp> 8^"R" tomml8^"R" <tomh bd> 8^"L" tomml8^"R" <sn bd hhp> 8^"L" tomml8^"R" } }
iRwcFQLr= {\drummode { <tommh bd> 8^"R" tommh8^"R" <tomml bd hhp> 8^"R" tommh8^"R" <tomh bd> 8^"L" tommh8^"R" <tomh bd hhp> 8^"L" tommh8^"R" } }
kKHhLMPF= {\drummode { <tomml bd> 8^"R" tomml8^"R" <tommh bd hhp> 8^"R" tomml8^"R" <sn bd> 8^"L" tomml8^"R" <tomh bd hhp> 8^"L" tomml8^"R" } }
AoBtvPdN= { \repeat unfold 1 { \AoBtvPdN } }
wmYmsIVY= { \repeat unfold 1 { \wmYmsIVY } }
PIIqmtbv= { \repeat unfold 1 { \PIIqmtbv } }
xfOnhjHj= { \repeat unfold 1 { \xfOnhjHj } \break }
PMYqyUVM= { \repeat unfold 1 { \PMYqyUVM } }
sDfKRgPb= { \repeat unfold 1 { \sDfKRgPb } }
iRwcFQLr= { \repeat unfold 1 { \iRwcFQLr } }
kKHhLMPF= { \repeat unfold 1 { \kKHhLMPF } \break }
drumnotes = {
\AoBtvPdN
\wmYmsIVY
\PIIqmtbv
\xfOnhjHj
\PMYqyUVM
\sDfKRgPb
\iRwcFQLr
\kKHhLMPF
}
\score {
\new DrumStaff
\with {
\consists "Parenthesis_engraver"
instrumentName = #"1"
\numericTimeSignature
\stemUp
\my-staff-count-mod
}
%% Hier werden die eigentlichen Noten eingefügt. Also die oben definierten Drumnotes.
<<
\time 4/4
\drumnotes
>>
% Notendruck
\layout {}
% MIDI Erzeugung
\midi {\tempo 4 = 120}
}
%% midis
\midiOut \drumnotes
Wie gewünscht werden dabei die Takte 1 bis 8 als MIDI generiert. Ist es auch möglich, zwei MIDI Dateien zu erzeugen? Also in dem Beispiel pro Zeile eine MIDI Datei Nr. 1 mit den Takten 1 bis 4 und Nr. 2 mit den Takten 5 bis 8?