[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: filter out pitches higher/ or lower than a certain pitch
From: |
Aaron Hill |
Subject: |
Re: filter out pitches higher/ or lower than a certain pitch |
Date: |
Thu, 24 Sep 2020 06:40:22 -0700 |
User-agent: |
Roundcube Webmail/1.4.2 |
On 2020-09-24 5:23 am, Stefan Thomas wrote:
Dear community,
I would like to achieve , in a certain example, that all pitches will
get
automatically an accent sign.
Like this:
Music = { \time 6/8 g 8 r a g c'-> r g d'-> r g e'-> r }
MusikwithAccents = { \time 6/8 g 8 r a g c->' r g d'-> r d e'-> r }
Can this be done with lilypond?
Has someone an idea, how this can be implemented?
Here is one approach of conditionally attaching articulations to notes
based on their pitch:
%%%%
\version "2.20.0"
addArticulation =
#(define-scheme-function
(direction articulation)
((number? #f) string?)
(lambda (m)
(if (music-is-of-type? m 'note-event)
(ly:music-set-property! m 'articulations
(cons
(let ((a (make-music 'ArticulationEvent
'articulation-type articulation)))
(if (number? direction)
(ly:music-set-property! a 'direction direction))
a)
(ly:music-property m 'articulations))))
m))
whenPitchAbove =
#(define-scheme-function
(pitch proc)
(ly:pitch? procedure?)
(lambda (m)
(let ((p (ly:music-property m 'pitch)))
(if (and (ly:pitch? p) (ly:pitch<? pitch p))
(proc m)
m))))
whenPitchBelow =
#(define-scheme-function
(pitch proc)
(ly:pitch? procedure?)
(lambda (m)
(let ((p (ly:music-property m 'pitch)))
(if (and (ly:pitch? p) (ly:pitch<? p pitch))
(proc m)
m))))
whenPitchWithin =
#(define-scheme-function
(lower upper proc)
(ly:pitch? ly:pitch? procedure?)
(lambda (m)
(let ((p (ly:music-property m 'pitch)))
(if (and (ly:pitch? p)
(not (ly:pitch<? p lower))
(not (ly:pitch<? upper p)))
(proc m)
m))))
\musicMap \whenPitchBelow b' \addArticulation #DOWN "tenuto"
\musicMap \whenPitchWithin b' d'' \addArticulation "staccato"
\musicMap \whenPitchAbove c'' \addArticulation "accent"
\fixed c'' { \time 6/8 b,4 a, g,8 c d f e <a, c e>4. }
%%%%
-- Aaron Hill
music-map.cropped.png
Description: PNG image