lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MIDI: Automatic accent on notes starting bars


From: David Kastrup
Subject: Re: MIDI: Automatic accent on notes starting bars
Date: Mon, 11 Feb 2019 22:23:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Lukas-Fabian Moser <address@hidden> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]