Am 30.08.2011 08:23, schrieb Marc Hohl:
Am 29.08.2011 18:52, schrieb Reinhold Kainhofer:
Am Montag, 29. August 2011, 18:07:17 schrieb Marc Hohl:
Hello list,
I think I have asked a similar question long time ago, but I didn't
find the answer.
Currently, I am working on a little scheme engraver which should
read the
'string-number, if given, and should do some calculations, depending on
other articulations, like 'HarmonicEvent.
The articulations are a list, so you have to filter them to get the
actual
string numbers.
Example attached,
Reinhold
Thank you, Neil, David and Reinhold, for your hints and examples!
Work like a charm!
Umm, well, not quite yet.
I noticed that
a)
I can detect string numbers within < ... > only, so
< c\3 > is recognized, d\4 not, but I need to cover *both* cases.
So I looked at the output of \displayMusic { c\4 }:
(make-music
'SequentialMusic
'elements
(list (make-music
'EventChord
'elements
(list (make-music
'NoteEvent
'duration
(ly:make-duration 2 0 1 1)
'pitch
(ly:make-pitch -1 0 0))
(make-music
'StringNumberEvent
'string-number
4)))))
Ok, so \4 isn't an articulation (which is obvious, but I had overlooked it).
AFAIK, the string-number won't be accessible in this case, so I tried to
acknowledge the string-number-interface, too.
For sake of simplicity, I staggered two for-each loops and am now able
to detect
string-numbers with this approach (note: the displayed information is
partly wrong
due to the loop construct), but still I can't access the first two notes
which aren't
surrounded by <...>. What am I doing wrong?
b)
Even in the first approach sent by Reinhold, the information about the
note heads is displayed *twice* for each note head - why?
Regards,
Marc
Regards,
Marc
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
\version "2.15.9"
#(define-public (test_engraver context)
(let ((string-pitch-list '())
(notes '())
(stringnumbers '()))
`(;; the list of acknowledgers
(acknowledgers
(note-head-interface .
,(lambda (trans grob source)
(set! notes (cons grob notes))))
(string-number-interface .
,(lambda (trans grob source)
(set! stringnumbers (cons grob stringnumbers)))))
;; once the acknowledging stage has finished,
;; process the grobs we've found
(process-acknowledged
. ,(lambda (trans)
(for-each (lambda (note)
(for-each (lambda (strnum)
(let* ((event (event-cause note))
(pitch (ly:event-property event 'pitch))
(nr (ly:event-property (event-cause strnum) 'string-number)))
(display "The event ")
(display " has pitch: ")
(display pitch)
(display "and string number events: ")
(display nr)
(display " \n"))
) ;; end lambda (strnum)
stringnumbers)
);; end lambda notes
notes)))
(stop-translation-timestep
. ,(lambda (trans)
(set! notes '())
(set! stringnumbers '()))))))
\layout {
\context {
\Voice
\consists \test_engraver
}
}
test = \relative c'{
c4\4 d\2 < e\2\harmonic > < d\3 g\2>
}
%\displayMusic { \test }
%\displayMusic { c\4 }
\new Voice { \test }
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user