Afegir funcions especials de lilypond

This commit is contained in:
marc
2025-12-20 20:31:54 +01:00
parent c1ec268823
commit 43706af7c4
6 changed files with 105 additions and 1155 deletions

File diff suppressed because one or more lines are too long

View 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
#})
% -------------------------------------------------------------------------

View File

@@ -1,4 +1,5 @@
\version "2.24.4"
{% include "lilypond/lib.ly" %}
{% if tune.score_source is not none %}
\score {
\language "english"

View File

@@ -7,13 +7,25 @@
% -----------------------------------------------------
% A
\repeat volta 2 {
\alternative {
\volta 1 { }
\volta 2 { }
}
}
% B
\repeat volta 2 {
\alternative {
\volta 1 { }
\volta 2 { }
}
}
}
}
\new Staff {
\relative {
\relative c' {
% -----------------------------------------------------
% Compàs
% -----------------------------------------------------

View File

@@ -1,4 +1,7 @@
\version "2.24.4"
{% include "lilypond/lib.ly" %}
\paper {
top-margin = 10
left-margin = 15

View File

@@ -1,5 +1,8 @@
{{ score_beginning }}
\version "2.24.4"
{% include "lilypond/lib.ly" %}
\book {
\paper {
top-margin = 10