|
From: | Gianmaria Lari |
Subject: | Re: Separate dynamics from notes |
Date: | Wed, 3 May 2023 18:46:34 +0200 |
\version "2.25.4"
%%%%%%%%%%%%%%%%%%
convertToSkips =
#(define-music-function (music) (ly:music?)
(music-map
(lambda (m)
(if (or (music-is-of-type? m 'rest-event)
(music-is-of-type? m 'note-event))
(make-music 'SkipEvent m)
m))
music))
%%%%%%%%%%%%%%%%%%music = { r2\p <e' d'> c'4( d')\ff s4 r4 }music = { r2\p <e' d'> c'4( d')\ff s4 r4 }\score {\music}
\displayLilyMusic \convertToSkips \music
Starting lilypond.exe 2.25.4 [Untitled]...
Processing `C:/Users/gianm/AppData/Local/Temp/frescobaldi-4jzfn8zf/tmpigq7hcux/document.ly'
Parsing...
Interpreting music...
Preprocessing graphical objects...
Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Converting to `document.pdf'...
{ s2\p < s s >2 s4( s4)\ff s4 s4 }
Success: compilation successfully completed
Completed successfully in 0.6".
If not too late, here is an example, based on Jeans code in https://lists.gnu.org/archive/html/lilypond-user/2021-09/msg00209.html
%%%%%%%%%%%%%%%%%%
convertToSkips =
#(define-music-function (music) (ly:music?)
(music-map
(lambda (m)
(if (or (music-is-of-type? m 'rest-event)
(music-is-of-type? m 'note-event))
(make-music 'SkipEvent m)
m))
music))
\convertToSkips { r2\p <e' d'> c'4( d)\ff s4 r4 }
%%%%%%%%%%%%%%%%%%
Take care with things that ar still interpreted, like Scripts.
> 26 apr. 2023 kl. 22:55 skrev Leo Correia de Verdier <leo.correia.de.verdier@gmail.com>:
>
> You can do like this if it’s useful to you, removing the engravers that read what you don’t want at a specific place.
> %%%%%%%%%%%%%%%%%%
> \version "2.25.1"
>
> rh = \fixed c' {c4\pp d\p e\f f\ff}
>
> \score {
> <<
> \new Voice \with {
> \remove Dynamic_engraver }
> \rh
> \new Dynamics %Dynamics context doesn’t have the Note_Heads_Engraver anyway
> \rh
>>>
> }
> %%%%%%%%%%%%%%%%%%
>
> Otherwise it is possible to create music functions that replace notes and rests with spacers or remove dynamics, but I can’t do that for you at the moment. While they’re not difficult functions they’re not ”built-in”.
>
> The second question is also probably not too hard to write a function for, but you’ll probably need to be a little more specific about the use case, perhaps also supply example code.
>
> Best wishes
> /Leo
>> 26 apr. 2023 kl. 22:23 skrev Gianmaria Lari <gianmarialari@gmail.com>:
>>
>> First question
>> Suppose I wrote this score:
>>
>> \version "2.25.2"
>> rh = \fixed c' {c4\pp d\p e\f f\ff}
>>
>> \score {
>> \new Staff \rh
>> }
>>
>> Is there any "automatic" way to extract the dynamics in the score (maybe assigning it to a variable)?
>> At the end I would like to easily transform the previous code in the following one:
>>
>> \version "2.25.2"
>> rh = \fixed c' {c4 d e f}
>> dy = {s4\pp s4\p s4\f s4\ff}
>> \score {
>> <<
>> \new Staff \rh
>> \new Dynamics \dy
>>>>
>> }
>>
>> Second question
>> Sometimes I copy a long score without the dynamic and add them separately later. For this operation I need to establish the dynamic location in the score counting and adding the notes length. This is tedious and error prone. Is there any way to make it?
>>
>> Thanks,
>> Gianmaria
>
[Prev in Thread] | Current Thread | [Next in Thread] |