Allgemein > Hilfe beim Einstieg in Lilypond
Pausen innerhalb von Akkorden
fugenkomponist:
Nunja, das ist anscheinend halt fest eingebaut: „r“ darf nicht in Akkorden stehen, sondern nur Tonhöhen.
Ein Ansatz könnte sein, eine eigene, sonst nicht genutzte Tonhöhe (also z. B. (ly:make-pitch -1 0 355/113)) zu definieren und per ly:parser-set-note-names zu verwenden (siehe z. B. makam.ly). extractMusic könnte dann alle Vorkommen dieser Tonhöhe durch Pausen ersetzen.
harm6:
--- Zitat von: rJazz ---Harm: was meinst Du mit Beispiel-Code?
Das war doch der Beiepiel-Zielcode mit der
Pause drin (was einen Syntaxfehler gibt).
--- Ende Zitat ---
Nun, manchmal bin ich etwas schwer von Begriff, deshalb brauche ich alle mögliche Hilfe, die der Fragende mir nur geben kann.
Dein code aus dem zweiten Beispiel ist da schon weiterführend.
Tatsächlich möchtest Du ja
(1)
--- Code: ---\relative c'
{
<c e g>
<d f a>
<e g>
}
--- Ende Code ---
durch die Anwendung einer geigneten procedure so bearbeiten, daß
--- Code: ---\relative c' { c d e }
\relative c' { e f g }
\relative c' { g' a r }
--- Ende Code ---
entstehen kann.
(2)
Du glaubst das durch einfügen einer Pause in den Akkord verwirklichen zu können.
Tatsächlich geht (2) nicht.
Man könnte jetzt extractNote aus Snippet 545 so verändern, daß es eine Pause an die entsprechende Stelle setzt. Das führt zu
--- Code: ---\version "2.18.2"
#(define (make-rest-music dur)
(make-music 'RestEvent
'duration dur))
#(define (noteEvent? music)
(eq? (ly:music-property music 'name) 'NoteEvent))
#(define (expand-q-chords music); for q chords : see chord-repetition-init.ly
(expand-repeat-chords! (list 'rhythmic-event) music))
%%%%%%%%%%%%%%%%%%%%%%%%%% extractNote %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(define tagNotExtractNote (gensym))
#(use-modules (ice-9 receive)) %% for the use of receive
#(define (chord->note chord n . args)
"Return either the note n of chord chord, keeping articulations or if other
numbers are specified in args, a chord with the matching notes."
(receive (notes others)
(partition noteEvent? (ly:music-property chord 'elements))
(if (null? notes)
chord
(let* ((len (length notes))
(res
(filter-map
(lambda(i)
(and (integer? i)
(<= i len)
(> i 0)
(list-ref notes (1- i)))) ; list-ref is zero-based
(cons n args)))
(one-note
(cond
;; for an empty list return a procedure, which will return
;; a rest, once called appropiate
((null? res) (lambda (d) (make-rest-music d)))
((null? (cdr res))(car res))
(else #f))))
(cond ((ly:music? one-note)
(begin
(ly:music-set-property! one-note 'articulations
(append
(ly:music-property one-note 'articulations)
others))
one-note))
((procedure? one-note)
(one-note
(car
(delete-duplicates
(map
(lambda (n) (ly:music-property n 'duration))
notes)))))
(else (ly:error "No suitable event found: ~a" one-note)))))))
#(define (extract-note music n . args)
"Extract the note n of each chords in music, keeping articulations.
If other numbers are given in args, the function returns a chord build with all
matching notes. If no note matches, returns the last note of the chord."
(map-some-music
(lambda (evt)
(cond
((eq? 'EventChord (ly:music-property evt 'name))
(let ((tags (ly:music-property evt 'tags)))
(if (memq tagNotExtractNote tags)
(ly:music-set-property! evt 'tags ; only remove the tag
(delq tagNotExtractNote tags))
(set! evt (apply chord->note evt n args)))
evt))
(else (and (ly:music-property evt 'duration #f) evt))))
(expand-q-chords music)))
extractNote = #(define-music-function (parser location n music )
(number? ly:music?)
(extract-note music n))
--- Ende Code ---
und scheint ja auch für Dein Beispiel zu klappen:
--- Code: ---m =
\relative c' {
<c e g>4
<d f a>
<e g>
}
\new Staff \m
\new Staff \extractNote #3 \m
\new Staff \extractNote #2 \m
\new Staff \extractNote #1 \m
--- Ende Code ---
Aber sobald der EventChord mit weniger Noten als die anderen, Ausgangs- oder Endpunkt eines Spanners ist wie Slur, Tie, etc, wird eine Warnung wegen nicht zu beendender Spanner ausgegeben.
Versuchs mal mit dem Beispiel aus dem LSR-snippet.
--- Code: ---music = \relative c' {
<c e g>4-> <d f>( <b g' d'>) <c e g>-. g2 r2 c2
}
\score {
<<
\new Staff \music
\new Staff \extractNote #3 \music
\new Staff \extractNote #2 \music
\new Staff \extractNote #1 \music
>>
}
--- Ende Code ---
In dieser Hinsicht ist auch fugenkomponists Vorschlag nicht weiter führend.
Du könntest jetzt natürlich eine weitere procedure schreiben, die untersucht, ob all diese spanner einen sinnvollen Start- und Zielpunkt haben und falls nicht, sollte der jeweilige Spanner komplett gelöscht werden...
Das ist durchaus machbar, aber ehrlich gesagt, ich habe besseres mit meiner Zeit vor ;)
Gruß,
Harm
rJazz:
Den scheme-Code muss ich erstmal verstehen.
Bei mir fügt er auch eine Pause im Beispiel ein,
dass ist ja schon ein Schritt weiter.
An Spanner oder Slurs hatte ich gar nicht gedacht,
weil ich auch keine polyphonen Linien auf diese
Art schreiben wiil.
Den Vorschlag, eine eigene Note zu definieren,
finde ich schon flexibel (wenn e snicht zu ändern ist,
dass r im chord einen Syntaxfehler gibt).
Um das auszuprobieren, muss ich schnme aber erst
besser verstehen. Mit dem code kann ich im Moment
noch nicth viel anfangen.
Danke für Eure Hilfe!
Navigation
[0] Themen-Index
[*] Vorherige Sete
Zur normalen Ansicht wechseln