Lukas-Fabian Moser <l...@gmx.de> writes: >> is there a way of automagically adding some volume increase >> ("accent") in MIDI output to any note that happens to start on the >> first beat in a bar? >> >> It seems a well-defined enough request to me so that it should be >> perfectly possible to do this in scheme, but I'm afraid this exceeds >> my very limited LilyPond-scheme abilites... >> >> Slight complication (maybe): In my scores, the metre changes all the >> time, so one really would have to use the actual timing of a note. > > Ok, so I tried to boldly dive into the hitherto unknown realm of > engraver construction and came up with the following: > > \version "2.19.82" > > #(define (measure-position-from-context context) > (ly:moment-main (ly:context-property context 'measurePosition))) > > accent_downbeat_engraver = > #(lambda (ctx) (make-engraver > (listeners > ((note-event engraver event) > (if (eq? 0 (measure-position-from-context ctx)) > (ly:broadcast (ly:context-event-source ctx) > (ly:make-stream-event > (ly:make-event-class 'articulation-event) > (list > (cons 'midi-extra-velocity 20) > (cons 'articulation-type "accent")))))))))
> This works fine in that it adds accents to any notes happening to > start a new measure. But - and this would be crucial for my > application - the accents do not survive in the MIDI output. (At first > I thought that \consist'ing the engraver to the Voice context in the > \midi might help, but alas...) Well, it creates the engraver. But in \midi, only performers are called. There are no scheme-defined MIDI performers. > My guess is that I'm broadcasting an articulation event that suffices > for the articulation being printed, but is either not "connected" to > the actual note or is for some other reason missed by the MIDI > performers. > > How could I proceed? Your idea is good. The infrastructure is not there. We probably should have something like make-translator for stuff that just translates events and/or meddles with context properties. So you probably need to work on the music expressions for now similar to how articulate.ly does things. -- David Kastrup _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user