Hallo Erich,
vielen Dank, daß Du den Twintet-Sprachcode zur Verfügung gestellt hast, jetzt bin ich weitergekommen.
Tatsächlich habe ich mir die Freiheit genommen, (fast) alles neu zu kodieren um all die Code-Wiederholungen los zu werden.
Im "BASIC STUFF" habe ich twintet so eingebunden, daß man define-note-names.scm nicht mehr patchen muß, sowie eine procedure aus 2.19, 'event-chord-reduce', eingefügt, die nur die erste geschriebene Note eines Akkords zurückgibt. Dabei habe ich bemerkt, daß 'event-chord-reduce' zwei kleine bugs beinhaltet. Die sind hier aber ohne Bedeutung, denke ich.
Ansonsten habe ich einige Kommentare eingefügt, falls etwas unklar ist, melde Dich.
\version "2.18.0"
%%%%%%%%%%%%%%%%%%%%%%%%%
%% BASIC STUFF
%%%%%%%%%%%%%%%%%%%%%%%%%
%% Making available 'twintet' without need to patch define-note-names.scm
%% Could be included from another file.
twintet-pitch-names =
#`(
(b . ,(ly:make-pitch -1 0 FLAT))
(h . ,(ly:make-pitch -1 0 FLAT))
(ces . ,(ly:make-pitch -1 0 FLAT))
(c . ,(ly:make-pitch -1 0 NATURAL))
(cis . ,(ly:make-pitch -1 0 SHARP))
(des . ,(ly:make-pitch -1 1 FLAT))
(d . ,(ly:make-pitch -1 1 NATURAL))
(dis . ,(ly:make-pitch -1 1 SHARP))
(es . ,(ly:make-pitch -1 2 FLAT))
(e . ,(ly:make-pitch -1 2 NATURAL))
(eis . ,(ly:make-pitch -1 2 SHARP))
(f . ,(ly:make-pitch -1 3 FLAT))
(fis . ,(ly:make-pitch -1 3 NATURAL))
(ges . ,(ly:make-pitch -1 3 NATURAL))
(fus . ,(ly:make-pitch -1 3 SHARP))
(g . ,(ly:make-pitch -1 4 FLAT))
(gis . ,(ly:make-pitch -1 4 NATURAL))
(as . ,(ly:make-pitch -1 4 NATURAL))
(gus . ,(ly:make-pitch -1 4 SHARP))
(a . ,(ly:make-pitch -1 5 FLAT))
(ais . ,(ly:make-pitch -1 5 NATURAL))
(bes . ,(ly:make-pitch -1 5 NATURAL))
(aus . ,(ly:make-pitch -1 5 SHARP))
)
#(ly:parser-set-note-names parser twintet-pitch-names)
%% 'event-chord-reduce' isn't available in 2.18.0
%% c/p from 2.19.3
#(use-modules (srfi srfi-11))
#(define-public (event-chord-reduce music)
"Reduces event chords in @var{music} to their first note event,
retaining only the chord articulations. Returns the modified music."
(map-some-music
(lambda (m)
(and (music-is-of-type? m 'event-chord)
(let*-values (((notes arts) (partition
(lambda (mus)
(music-is-of-type? mus 'rhythmic-event))
(ly:music-property m 'elements)))
((dur) (ly:music-property m 'duration))
((full-arts) (append arts
(ly:music-property m 'articulations)))
((first-note) (and (pair? notes) (car notes))))
(cond (first-note
(set! (ly:music-property first-note 'articulations)
full-arts)
first-note)
((ly:duration? dur)
;; A repeat chord. Produce an unpitched note.
(make-music 'NoteEvent
'duration dur
'articulations full-arts))
(else
(ly:music-error m (_ "Missing duration"))
(make-music 'NoteEvent
'duration (ly:make-duration 2 0 0)
'articulations full-arts))))))
music))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% THE DEFINITIONS/FUNCTIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(define (zerointervall pitch)
(*
(-
(+ (ly:pitch-steps pitch)
(ly:pitch-alteration pitch))
(ly:pitch-octave pitch))
2))
#(define (make-fingering direction digit)
;; returns a FingeringEvent
(make-music 'FingeringEvent
'direction direction
'digit digit))
#(define (make-fingering-down digit) (make-fingering -1 digit))
#(define (number-list-diffs number-list)
;; takes a list of numbers and returns a list of diffs of all adjacent elements
(define (helper l1 l2)
(if (>= 1 (length l1))
(reverse l2)
(helper (cdr l1) (cons (- (cadr l1) (car l1)) l2))))
(helper number-list '()))
#(define (print-half-steps-as-fingerings m)
;; returns only the first entered note of an EventChord
;; adds the half-note-steps of adjacent notes as fingerings below
;; the order of notes entered in the EventChord matters, changing them will
;; cause a different result
(if (music-is-of-type? m 'event-chord)
(let* ((evt-chrd-notes (event-chord-notes m))
(evt-chrd-pitches (event-chord-pitches m))
(zerointervall-list
(map (lambda (p) (zerointervall p)) evt-chrd-pitches))
(pitch-diffs (number-list-diffs zerointervall-list))
(fingerings
(map (lambda (n) (make-fingering-down n)) pitch-diffs))
(evt-chrd-elts (ly:music-property m 'elements)))
(ly:music-set-property! m 'elements (append evt-chrd-elts fingerings))
(event-chord-reduce m))
m))
adds =
#(define-music-function (parser location music)(ly:music?)
(music-map
(lambda (m) (print-half-steps-as-fingerings m))
music))
%%%%%%%%%%%%%
%% TEST
%%%%%%%%%%%%
vorzeichen =
\new Voice
\set Staff.keySignature = #`((3 . ,FLAT)
(4 . ,FLAT)
(5 . ,FLAT))
remark =
\markup
\override #'(line-width . 30)
\wordwrap-string
#"NOTE: different entering order will cause different result:"
noten-down = {
<f'' a'' c'''>4.
<e'' g'' c'''>8
<d'' g'' b'''>2
<c'' f'' a''>
<c'' e'' g''>4.
<b'' d'' g''>8
<a' c'' f''>2
<g' c'' e''>
<g' b'' d''>4
<f' a' c''>
%% <>^"whatever" doesn't work with 'event-chord-reduce', bug!
s1*0^\remark
<e' g' c''>1
<e' c'' g'>1
<c'' e' g'>1
}
\score {
\new Staff
\with {
\override StaffSymbol #'line-positions = #'(2 0 -2 -4 -10)
\remove "Time_signature_engraver"
\remove "Bar_number_engraver"
%\remove "Bar_engraver"
\remove "Clef_engraver"
staffLineLayoutFunction =
#(lambda (p) (- (ly:pitch-steps p) (ly:pitch-octave p)))
\accidentalStyle forget
}
\adds { s1 \vorzeichen \noten-down }
}
HTH,
Harm