Afegir funcions especials de lilypond
This commit is contained in:
File diff suppressed because one or more lines are too long
84
folkugat_web/assets/templates/lilypond/lib.ly
Normal file
84
folkugat_web/assets/templates/lilypond/lib.ly
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
% -------------------------------------------------------------------------
|
||||||
|
% Extra custom functions
|
||||||
|
% -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
% Alternative chords
|
||||||
|
|
||||||
|
#(define (pitches-bass-inversion-context-list music context)
|
||||||
|
"Creates a list containing relevant pitches, bass, inversion and context to
|
||||||
|
serve as argument for `ignatzek-chord-names', derived from @var{music}
|
||||||
|
"
|
||||||
|
(let* (;; work on a copy of `music', warranting not to change it
|
||||||
|
(m-add (ly:music-deep-copy music))
|
||||||
|
(ev-notes-orig (event-chord-notes m-add))
|
||||||
|
;; if chord is an inversion some pitches are below root, in this case
|
||||||
|
;; 'octavation-property is set.
|
||||||
|
;; reset pitch of them
|
||||||
|
;; TODO this is an ugly hack, find better method
|
||||||
|
(ev-notes
|
||||||
|
(map
|
||||||
|
(lambda (m)
|
||||||
|
(if (and (not (null? (ly:music-property m 'octavation)))
|
||||||
|
(= (ly:music-property m 'octavation) -1))
|
||||||
|
(begin
|
||||||
|
(ly:music-set-property! m 'pitch
|
||||||
|
(ly:pitch-transpose
|
||||||
|
(ly:music-property m 'pitch)
|
||||||
|
(ly:make-pitch 1 0 0)))
|
||||||
|
m)
|
||||||
|
m))
|
||||||
|
ev-notes-orig))
|
||||||
|
;; sort the ptches ascending as expected by `ignatzek-chord-names'
|
||||||
|
(ev-pitches
|
||||||
|
(sort
|
||||||
|
(map (lambda (m) (ly:music-property m 'pitch)) ev-notes)
|
||||||
|
ly:pitch<?))
|
||||||
|
;; get bass
|
||||||
|
(bass-note
|
||||||
|
(filter
|
||||||
|
(lambda (m)
|
||||||
|
(not (null? (ly:music-property m 'bass))))
|
||||||
|
ev-notes))
|
||||||
|
(bass-pitch
|
||||||
|
(if (not (null? bass-note))
|
||||||
|
(ly:music-property (car bass-note) 'pitch)
|
||||||
|
'()))
|
||||||
|
;; get inversion
|
||||||
|
(inversion-note
|
||||||
|
(filter
|
||||||
|
(lambda (m)
|
||||||
|
(not (null? (ly:music-property m 'inversion))))
|
||||||
|
ev-notes))
|
||||||
|
(inversion-pitch
|
||||||
|
(if (not (null? inversion-note))
|
||||||
|
(ly:music-property (car inversion-note) 'pitch)
|
||||||
|
'()))
|
||||||
|
;; TODO why is this needed?
|
||||||
|
(in-pitches
|
||||||
|
(if (null? inversion-pitch)
|
||||||
|
(delq bass-pitch ev-pitches)
|
||||||
|
ev-pitches)))
|
||||||
|
|
||||||
|
(list in-pitches bass-pitch inversion-pitch context)))
|
||||||
|
|
||||||
|
altChords =
|
||||||
|
#(define-music-function (m1 m2)(ly:music? ly:music?)
|
||||||
|
"Return the default ChordName of @var{m1}, with an added parenthesized ChordName
|
||||||
|
derived from @var{m2}"
|
||||||
|
#{
|
||||||
|
\applyOutput ChordNames.ChordName
|
||||||
|
#(lambda (g ctx p)
|
||||||
|
(let ((main-text (ly:grob-property g 'text))
|
||||||
|
(alt-text
|
||||||
|
(apply
|
||||||
|
ignatzek-chord-names
|
||||||
|
(pitches-bass-inversion-context-list m2 ctx))))
|
||||||
|
(ly:grob-set-property! g 'text
|
||||||
|
#{
|
||||||
|
\markup
|
||||||
|
{ $main-text \hspace #0.4 \fontsize #-3 \parenthesize $alt-text }
|
||||||
|
#})))
|
||||||
|
$m1
|
||||||
|
#})
|
||||||
|
|
||||||
|
% -------------------------------------------------------------------------
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
\version "2.24.4"
|
\version "2.24.4"
|
||||||
|
{% include "lilypond/lib.ly" %}
|
||||||
{% if tune.score_source is not none %}
|
{% if tune.score_source is not none %}
|
||||||
\score {
|
\score {
|
||||||
\language "english"
|
\language "english"
|
||||||
|
|||||||
@@ -7,13 +7,25 @@
|
|||||||
% -----------------------------------------------------
|
% -----------------------------------------------------
|
||||||
|
|
||||||
% A
|
% A
|
||||||
|
\repeat volta 2 {
|
||||||
|
\alternative {
|
||||||
|
\volta 1 { }
|
||||||
|
\volta 2 { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
% B
|
% B
|
||||||
|
\repeat volta 2 {
|
||||||
|
\alternative {
|
||||||
|
\volta 1 { }
|
||||||
|
\volta 2 { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\new Staff {
|
\new Staff {
|
||||||
\relative {
|
\relative c' {
|
||||||
% -----------------------------------------------------
|
% -----------------------------------------------------
|
||||||
% Compàs
|
% Compàs
|
||||||
% -----------------------------------------------------
|
% -----------------------------------------------------
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
\version "2.24.4"
|
\version "2.24.4"
|
||||||
|
|
||||||
|
{% include "lilypond/lib.ly" %}
|
||||||
|
|
||||||
\paper {
|
\paper {
|
||||||
top-margin = 10
|
top-margin = 10
|
||||||
left-margin = 15
|
left-margin = 15
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{{ score_beginning }}
|
{{ score_beginning }}
|
||||||
\version "2.24.4"
|
\version "2.24.4"
|
||||||
|
|
||||||
|
{% include "lilypond/lib.ly" %}
|
||||||
|
|
||||||
\book {
|
\book {
|
||||||
\paper {
|
\paper {
|
||||||
top-margin = 10
|
top-margin = 10
|
||||||
|
|||||||
Reference in New Issue
Block a user