Skip to content

Commit

Permalink
Merge pull request #115 from jstma/support-drums
Browse files Browse the repository at this point in the history
  • Loading branch information
aspiers authored May 20, 2023
2 parents baddaf4 + a258042 commit 4b026ec
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
35 changes: 35 additions & 0 deletions ly2video/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,33 @@ def writeSpaceTimeDumper():
(+ 0.0 (ly:moment-main time) (* (ly:moment-grace time) (/ 9 40)))
file line char))))
#(define (dump-spacetime-infod grob)
(let* ((extent (ly:grob-extent grob grob X))
(system (ly:grob-system grob))
(x-extent (ly:grob-extent grob system X))
(left (car x-extent))
(right (cdr x-extent))
(paper-column (grob-get-paper-column grob))
(time (ly:grob-property paper-column 'when 0))
(cause (ly:grob-property grob 'cause))
(origin (ly:event-property cause 'origin))
(location (ly:input-file-line-char-column origin))
(file (list-ref location 0))
(line (list-ref location 1))
(char (list-ref location 2))
(column (list-ref location 3))
(drum-type (ly:event-property cause 'drum-type))
(pitch (ly:assoc-get drum-type midiDrumPitches))
(midi-pitch (if (ly:pitch? pitch) (+ 0.0 (ly:pitch-tones pitch)) "no pitch")))
(if (not (equal? (ly:grob-property grob 'transparent) #t))
(format #t "\nly2video: (~23,16f, ~23,16f) pitch ~d:~a:~a @ ~23,16f from ~a:~3d:~d"
left right
(ly:pitch-octave pitch)
(ly:pitch-notename pitch)
(ly:pitch-alteration pitch)
(+ 0.0 (ly:moment-main time) (* (ly:moment-grace time) (/ 9 40)))
file line char))))
#(define (dump-spacetime-info-barline grob)
(let* ((extent (ly:grob-extent grob grob X))
(system (ly:grob-system grob))
Expand All @@ -1359,6 +1386,14 @@ def writeSpaceTimeDumper():
))))
\layout {
\context {
\DrumVoice
\override NoteHead #'after-line-breaking = #dump-spacetime-infod
}
\context {
\DrumStaff
\override BarLine #'after-line-breaking = #dump-spacetime-info-barline
}
\context {
\Voice
\override NoteHead #'after-line-breaking = #dump-spacetime-info
Expand Down
28 changes: 28 additions & 0 deletions test/regressions/drumvoice/input.ly
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
\version "2.20.0"

music = {
\new DrumStaff {
\set Staff.instrumentName = #"drums"
\new DrumVoice {
\drummode {
\time 4/4
\tempo 4 = 84
<<
{ cymr8 cymr8 \tuplet3/2{hh16 hh hh} hh8 \tuplet3/2{tomh16 tomh tomh} \tuplet3/2{tomh16 tomh toml} \tuplet3/2{tomh16 tomfh tomh} tomfh8 }
\\
{ bd8 bd8 s4 s2 }
>>
}
}
}
}

\score {
\music
\layout { }
}

\score {
\music
\midi { }
}

0 comments on commit 4b026ec

Please sign in to comment.