Chordpro export
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,8 +1,8 @@
|
||||
# ---> Lilypond
|
||||
*.pdf
|
||||
*.cho
|
||||
*.ps
|
||||
*.midi
|
||||
*.mid
|
||||
*.log
|
||||
*~
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
\include "eps_file_from_song_dir.ily"
|
||||
\include "title_with_category_images.ily"
|
||||
\include "chord_settings.ily"
|
||||
\include "chordpro.ily"
|
||||
\include "transposition.ily"
|
||||
\include "verses_with_chords.ily"
|
||||
\include "arrows_in_scores.ily"
|
||||
|
||||
@@ -158,6 +158,8 @@ override-stanza =
|
||||
#(define (stanza . stanzanumbers)
|
||||
#{
|
||||
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
|
||||
\once \override StanzaNumber.details.custom-stanza-type = #'verse
|
||||
\once \override StanzaNumber.details.custom-stanza-numbers = #stanzanumbers
|
||||
\applyContext
|
||||
#(lambda (context)
|
||||
(handle-stanza-numbers context stanzanumbers
|
||||
@@ -169,6 +171,8 @@ ref =
|
||||
#(define-music-function (stanzanumbers lyrics) ((number-list? (list)) ly:music?)
|
||||
#{ \lyricmode {
|
||||
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
|
||||
\once \override StanzaNumber.details.custom-stanza-type = #'ref
|
||||
\once \override StanzaNumber.details.custom-stanza-numbers = #stanzanumbers
|
||||
\applyContext
|
||||
#(lambda (context)
|
||||
(handle-stanza-numbers context stanzanumbers
|
||||
@@ -186,6 +190,8 @@ bridge =
|
||||
#(define-music-function (stanzanumbers lyrics) ((number-list? (list)) ly:music?)
|
||||
#{ \lyricmode {
|
||||
\once \override StanzaNumber.details.custom-realstanza = ##t % set this to signal that there is a real stanza and no repeat signs
|
||||
\once \override StanzaNumber.details.custom-stanza-type = #'bridge
|
||||
\once \override StanzaNumber.details.custom-stanza-numbers = #stanzanumbers
|
||||
\applyContext
|
||||
#(lambda (context)
|
||||
(handle-stanza-numbers context stanzanumbers
|
||||
@@ -201,8 +207,11 @@ bridge =
|
||||
|
||||
% prints a repStart Sign as stanza if the tag 'repeats is kept.
|
||||
% if there was a stanza already set by the stanza function with StanzaNumber.details.custom-realstanza = ##t we set that also as stanza.
|
||||
% Sets custom-inline-text for ChordPro export so it can collect the repeat sign separately
|
||||
repStartWithTag = \lyricmode {
|
||||
\tag #'repeats {
|
||||
\once \override StanzaNumber.details.custom-inline-text = \repStart
|
||||
\once \override StanzaNumber.details.custom-inline-direction = #LEFT
|
||||
\applyContext
|
||||
#(lambda (context)
|
||||
(let ((lastStanza (ly:context-property context 'stanza))
|
||||
@@ -220,6 +229,8 @@ repStartWithTag = \lyricmode {
|
||||
|
||||
repStopWithTag = \lyricmode {
|
||||
\tag #'repeats {
|
||||
\once \override StanzaNumber.details.custom-inline-text = \repStop
|
||||
\once \override StanzaNumber.details.custom-inline-direction = #RIGHT
|
||||
\once \override StanzaNumber.font-series = #'normal
|
||||
\once \override StanzaNumber.direction = 1
|
||||
\set stanza = \markup { \pad-x-right #1 \repStop }
|
||||
|
||||
@@ -40,34 +40,19 @@ shiftChords = #(define-music-function (parser location xshift chords) (number? l
|
||||
|
||||
altChord =
|
||||
#(define-music-function (parser location mainchord altchord) (ly:music? ly:music?)
|
||||
(let* ((remove-point-and-click
|
||||
(lambda (grob)
|
||||
(ly:grob-set-property! grob 'cause #f)
|
||||
(ly:text-interface::print grob)))
|
||||
(chord-name (lambda (in-pitches bass inversion context) #{
|
||||
\markup {
|
||||
\translate #'(-0.5 . 0)
|
||||
\score {
|
||||
\chords { \transposable #(cons (car (music-pitches mainchord)) (car in-pitches)) { #(music-clone mainchord) \klamm #(music-clone altchord) } }
|
||||
\layout {
|
||||
\LAYOUT
|
||||
\context {
|
||||
\ChordNames
|
||||
\override ChordName.extra-spacing-width = #'(0 . 0.3)
|
||||
\override ChordName.stencil = #remove-point-and-click
|
||||
}
|
||||
\context {
|
||||
\Score
|
||||
\override SpacingSpanner.spacing-increment = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}#})))
|
||||
(let* ((chord-name (lambda (in-pitches bass inversion context)
|
||||
(make-line-markup (list
|
||||
(ignatzek-chord-names in-pitches bass inversion context)
|
||||
(make-hspace-markup 0.3)
|
||||
(parenthesis-ignatzek-chord-names (music-pitches (transposable (cons (car (music-pitches mainchord)) (car in-pitches)) (music-clone altchord))) '() '() context)
|
||||
))
|
||||
)))
|
||||
#{
|
||||
\once \set chordNameFunction = #chord-name
|
||||
#mainchord
|
||||
#}))
|
||||
|
||||
|
||||
% Akkorde werden so transponiert, dass sie passen, wenn man mit Kapo im angegebenen Bund spielt
|
||||
capoTranspose =
|
||||
#(define-music-function (fret chords) (number? ly:music?)
|
||||
|
||||
1040
private_includes/base/chordpro.ily
Normal file
1040
private_includes/base/chordpro.ily
Normal file
File diff suppressed because it is too large
Load Diff
@@ -379,6 +379,8 @@ Chord_lyrics_spacing_engraver =
|
||||
\override SpacingSpanner.spacing-increment = 0
|
||||
% \override SpacingSpanner.packed-spacing = ##t
|
||||
\consists \Chord_lyrics_spacing_engraver
|
||||
% ChordPro engraver in Score context to collect all data
|
||||
\consists \ChordPro_score_collector
|
||||
\remove Bar_number_engraver
|
||||
\remove Mark_engraver
|
||||
\remove Jump_engraver
|
||||
|
||||
@@ -39,6 +39,20 @@ TEXT = \markuplist {
|
||||
TEXT_PAGES
|
||||
(list TEXT))))
|
||||
|
||||
%% Add invisible ChordPro write trigger to last TEXT_PAGES markuplist
|
||||
#(when (and (defined? 'chordpro-export-enabled) chordpro-export-enabled (pair? TEXT_PAGES))
|
||||
(let* ((last-index (- (length TEXT_PAGES) 1))
|
||||
(last-page (list-ref TEXT_PAGES last-index))
|
||||
(modified-last-page #{
|
||||
\markuplist {
|
||||
#last-page
|
||||
\chordpro-delayed-write
|
||||
}
|
||||
#}))
|
||||
(set! TEXT_PAGES
|
||||
(append (list-head TEXT_PAGES last-index)
|
||||
(list modified-last-page)))))
|
||||
|
||||
#(define (add-text-pages text-pages)
|
||||
(if (pair? text-pages)
|
||||
(begin
|
||||
@@ -55,12 +69,34 @@ TEXT = \markuplist {
|
||||
(if header (set! $defaultheader header))
|
||||
(if paper (set! $defaultpaper paper))
|
||||
)
|
||||
|
||||
;; ChordPro export: Store filename and extract metadata from basicSongInfo FIRST
|
||||
(when (and (defined? 'chordpro-export-enabled) chordpro-export-enabled)
|
||||
;; Use ly:parser-output-name which returns the output basename
|
||||
;; This will write relative to current working directory (same as PDF)
|
||||
(let ((output-name (ly:parser-output-name)))
|
||||
(set! chordpro-current-filename output-name))
|
||||
|
||||
;; Try to extract metadata from basicSongInfo \header block
|
||||
(when (defined? 'basicSongInfo)
|
||||
(let* ((header-alist (ly:module->alist basicSongInfo))
|
||||
(title (assoc-ref header-alist 'title))
|
||||
(authors (assoc-ref header-alist 'authors)))
|
||||
(when title
|
||||
(set! chordpro-header-title
|
||||
(if (markup? title)
|
||||
(markup->string title)
|
||||
(if (string? title) title "Untitled"))))
|
||||
(when authors
|
||||
(set! chordpro-header-authors authors)))))
|
||||
|
||||
(add-score #{
|
||||
\score {
|
||||
\MUSIC
|
||||
\layout { \LAYOUT }
|
||||
}#})
|
||||
(add-text-pages TEXT_PAGES)
|
||||
|
||||
(add-score #{
|
||||
\score {
|
||||
\unfoldRepeats { \MUSIC \INLINESCOREMUSIC }
|
||||
|
||||
Reference in New Issue
Block a user