\version "2.19.83" %{ Mes variables et fonctions d'aide à l'encodage %} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% variables diverses myArpeggioBracket = %%%%%%%%% pour crochets sur plusieurs notes { \revert Arpeggio.X-extent \override Arpeggio.stencil = #(lambda (grob) (ly:stencil-rotate (ly:arpeggio::brew-chord-bracket grob) (if (eq? LEFT (ly:grob-property grob 'direction LEFT)) 0 180) 0 0)) } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% fonction de durées répétitives sur une note ou plusieurs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% #(define (extract-all-durations music) (map! (lambda (m) (ly:music-property m 'duration)) (extract-music music (lambda (m) (ly:duration? (ly:music-property m 'duration)))))) applyRhythm = #(define-music-function (parser location rhythm music) (ly:music? ly:music?) (let* ((r-elements (ly:music-property rhythm 'elements)) (m-elements (ly:music-property music 'elements)) (m (if (null? m-elements) (ly:music-deep-copy (make-sequential-music (make-list (length r-elements) music))) music)) (durations (extract-all-durations rhythm)) (l durations)) (for-some-music (lambda (n) (and (pair? l) (if (ly:duration? (ly:music-property n 'duration)) (begin (set! (ly:music-property n 'duration) (car l)) (set! l (cdr l)) (if (null? l) (set! l durations)) #t) #f))) m) m)) str = #(define-music-function (parser location music) (ly:music?) #{ \applyRhythm {s4. s4 s8} $music #}) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%% fin de fonction %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ùù %%%%%%%%%%%%%%% \< \! ou \> \! entre parentheèses %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% hairpinBetweenText = #(define-music-function (parser location leftText rightText) (markup? markup?) #{ \once \override Hairpin #'stencil = #(lambda (grob) (let* ((orig (ly:grob-original grob)) (siblings (if (ly:grob? orig) (ly:spanner-broken-into orig) '())) (hairpin-stencil (ly:stencil-aligned-to (ly:hairpin::print grob) Y CENTER)) (left-addition (ly:stencil-aligned-to (grob-interpret-markup grob leftText) Y CENTER)) (right-addition (ly:stencil-aligned-to (grob-interpret-markup grob rightText) Y CENTER))) (if (or (null? siblings) (eq? grob (car siblings))) (set! hairpin-stencil (ly:stencil-combine-at-edge left-addition X RIGHT hairpin-stencil 0))) (if (or (null? siblings) (eq? grob (car (reverse siblings)))) (set! hairpin-stencil (ly:stencil-combine-at-edge hairpin-stencil X RIGHT right-addition 0.6))) hairpin-stencil)) #}) parenthesizedHairpin = \hairpinBetweenText \markup \fontsize #3 "( " \markup \fontsize #3 ")" %adapter fontsize en fonction des goûts %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%% fin de fonction %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% \cresc \! , \decr \! ou \dim \! entre parenthèses %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fCresc = #(define-event-function (parser location) () #{ \tweak bound-details.left.text \markup\concat { \lower #.1 "(" "cresc." } \tweak bound-details.right-broken.text ##f \tweak bound-details.left-broken.text ##f \tweak bound-details.right.text \markup \lower #0.5 " )" \cresc #}) fCrescCourt = #(define-event-function (parser location) () #{ \tweak bound-details.left.text \markup \concat { \lower #.1 "(" "cresc." \lower #.5 ")" } \tweak bound-details.right-broken.text ##f \tweak bound-details.right-broken.text ##f \cresc #}) pCresc = #(define-event-function (parser location) () #{ \tweak bound-details.left.text \markup\concat { \lower #.1 "(" "cresc." } \tweak bound-details.right-broken.text ##f \tweak bound-details.left-broken.text ##f \tweak bound-details.right.text \markup \lower #.5 " )" \cresc #}) pDresc = #(define-event-function (parser location) () #{ \tweak bound-details.left.text \markup\concat { \lower #.1 "(" "decresc." } \tweak bound-details.right-broken.text ##f \tweak bound-details.left-broken.text ##f \tweak bound-details.right.text \markup \lower #.5 " )" \decresc #}) pDim = #(define-event-function (parser location) () #{ \tweak bound-details.left.text \markup\concat { \lower #.1 "(" "dim." } \tweak bound-details.right-broken.text ##f \tweak bound-details.left-broken.text ##f \tweak bound-details.right.text \markup \lower #.5 " )" \dim #}) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% fin de fonction %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% enlever ou garder des tags et nuances %{ voici la fonction que j’utilise ; elle me permet d’enlever toutes les nuances sauf celles que j’ai tagguées (ici avec le mot-clé 'ici) et celles pour lesquelles j’ai indiqué une direction explicite (c’est-à-dire avec _\ff ou ^\ff plutôt que \ff tout seul). Il est également possible de procéder en sens inverse : garder toutes les nuances sauf celles préselectionnées (il suffit d’enlever le "not" dans le code, avec la parenthèse correspondante). %} #(define (dynamic? x) (let ((name (ly:music-property x 'name))) (or (eq? name 'DynamicEvent) (eq? name 'AbsoluteDynamicEvent) (eq? name 'CrescendoEvent) (eq? name 'DecrescendoEvent) (eq? name 'SpanDynamicEvent)))) enleverNuances = #(define-music-function (m) (ly:music?) (music-filter (lambda (x) (let ((tags (ly:music-property x 'tags)) (dir (ly:music-property x 'direction))) (not ; objes à enlever (and ; si toutes les conditions sont réunies : (dynamic? x) ; c'est bien une nuance (not (memq 'ici tags)) ; elle ne possède pas le tag (null? dir) ; sa direction n'est PAS indéfinie )))) m)) garderNuances = #(define-music-function (m) (ly:music?) (music-filter (lambda (x) (let ((tags (ly:music-property x 'tags)) (dir (ly:music-property x 'direction))) (not ; objets à garder (and ; si toutes les conditions sont réunies : (dynamic? x) ; c'est bien une nuance ET (or ; l'une ou l'autre des conditions suivantes : (memq 'ici tags) ; soit elle a le tag (not (null? dir) ; soit sa direction est définie )))))) m)) %{ exécution : { \enleverNuances \musique } { \garderNuances \musique } %} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% fin de fonction %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% redéfinir de vraies nuances %{ je remarque que vous avez défini beaucoup de nuances supplémentaires en tant que markups. Si vous voulez pouvoir les utiliser directement sans avoir besoin du caractère "_", il suffit d’ajouter celui ci dans la définition : fsF = _\markup \dynamic fsf ce qui permet ensuite de faire { c' d' e'2\fsF } … cependant, ce n’est pas idéal car ce ne seront toujours pas de vraies nuances (et du coup elles seront ignorées par \enleverNuances etc.). En fait, il y a une autre solution encore meilleure : utiliser de _vraies_ nuances (dont on trafique le contenu), plutôt qu’un markup. Voici le code que j’utilise pour cela : %} %%%%%%%%%%%%%% #(define-public (char-punctuation? ch) (char-set-contains? char-set:punctuation ch)) #(define-public char-set:dynamics (char-set #\f #\m #\p #\r #\s #\z)) #(define-markup-command (dynamic-string layout props str) (string?) (let ((composite-chars (char-set-union char-set:dynamics char-set:whitespace char-set:punctuation)) (split (lambda (s) (string-index s #\sp ))) (str-list '()) (dyn-markup (lambda (s) (make-dynamic-markup s))) (text-markup (lambda (s) (make-normal-text-markup (make-italic-markup s))))) (do ((current-str (string-append str " "))) ((not (split current-str))) (begin (set! str-list (append str-list (list (string-take current-str (split current-str))))) (set! current-str (string-drop current-str (+ (split current-str) 1))))) (interpret-markup layout props (make-line-markup (map (lambda (word) (if (string-every composite-chars word) (if (string-every char-set:dynamics word) (dyn-markup word) (let ((word-lst (string->list word))) (make-concat-markup (map (lambda (ch) (let ((print-ch (string ch))) (if (char-punctuation? ch) (text-markup print-ch) (dyn-markup print-ch)))) word-lst)))) (text-markup word))) str-list))))) nuance = #(define-event-function (arg) (markup?) (let ((d (make-music 'AbsoluteDynamicEvent))) (ly:music-set-property! d 'text (cond ((string? arg) (if (string-every char-set:dynamics arg) arg (markup #:dynamic-string arg))) (else arg))) d)) %% Quelques exemples : %{ { b1\nuance pp } { b1\nuance "pp sub." } { b1\nuance "più pp (ma non troppo)" } %% On peut même y mettre des markups (mais %% cela reste de vraies nuances) : { b1\nuance \markup { \hspace #-3 \normal-text \italic più pp} } %% Ou même dans une variable : moltoF = \nuance "molto f" {b1\moltoF } %} %%%%%%%%%%%%%% fin de fonction pour nuances %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%% myBreakO = { } %%%%%%% saut de portées pour orchestre myBreakO = { } %%%%%%%%%% valeur par défaut si \removeWithTag #'Original est exécuté myBreakO = \tag #'Original { \break } %%%%%% utilidsation de tag pour gérer les sauts de portées entre scores %%%%%%%%%% myBreakO = { \break } %%%%%%%%%% myBreakC = { } %%%%%%% saut de portées pour le choeur myBreakC = { \break } fsF = \nuance "fsf" ffsF = _\markup { \dynamic { ffsf } } parenthP = _\markup { \dynamic { \parenthesize p } } parenthPalign = _\markup { \halign #-4 \dynamic { \parenthesize p } } \> pianoSubito = _\markup { \dynamic p \italic "subito" } pianoCrescMolto = \nuance \markup { \hspace #12 p \normal-text \italic "cresc.molto" } pDim = _\markup { \dynamic \parenthesize p \parenthesize \italic "dim." } pE = _\markup { \dynamic p \italic "-e" } sfpSubito = _\markup { \dynamic sf p \italic "subito" } piuF = _\markup {\hspace #-3.0 \italic "più" \dynamic f } piuFsf = _\markup { \hspace #-6.0 \italic "più" \dynamic fsf } sempreCresc = \nuance "sempre cresc" piuP = _\markup { \italic "più" \dynamic p } piuPP = _\markup { \italic "più" \dynamic pp } %%%%%%%%%%%%% menoF = _\markup {\italic "meno" \dynamic f } menoF = \nuance "meno f" dolcePP = _\markup { \dynamic pp \italic "dolce elegico" } FFmarcato = _\markup { \dynamic ff \italic "marcato" } vSf = _\markup { \vspace #4 \dynamic sf } hmF = _\markup { \hspace #-4 \dynamic mf } surTirets = { \override TextScript.outside-staff-priority = #-2.5 % placer le texte du markup sur les traits de dim \override TextScript.extra-offset = #'(0 . -1.5) } % placer le texte du markup sur les traits de dim generalPart = { \new Devnull { s1 } \new Devnull { s1 } }