On 20/07/11 01:05, Carl Sorensen wrote:
>
>
> With the exceptions I've noted above, it looks great! I think this will do
> exactly what you want done, and it will satisfy my concerns and Neil's
> concerns. Great job!
>
Okay, I've tried to follow what you've said, and make the appropriate
changes. Patches attached. But it won't run :-( and I'm pretty certain
I've messed up the "let(" syntax.
I've looked at the scheme tutor "structure and interpretation..." and
while I sort of understand what's going on, I haven't quite got it yet.
Anyways, here's the code:
(define-public (capo-handler pitches bass inversion context)
(let (chord-function (ly:context-property context 'chordNameFunction #f))
(capo-pitch (ly:context-property context 'capoPitch #f))
(if (not (capo-pitch)) ;; if there's no capo pitch
or no chord
(chord-function pitches bass inversion context) ;; call the
chordNameFunction as of old
(let ((new-pitches ;; else
transpose the pitches and do the chord twice
(map (lambda (p)
(ly:pitch-transpose p capo-pitch))
pitches))
(new-bass
(and (ly:pitch? bass)
(ly:pitch-transpose bass capo-pitch)))
(new-inversion
(and (ly:pitch? inversion)
(ly:pitch-transpose inversion
capo-pitch)))
(capo-markup (make-parenthesize-markup (chord-function
new-pitches new-bass new-inversion context)))
(markup (chord-function pitches bass inversion context))
(capo-vertical (ly:context-property context 'capoVertical #f))
(if (capo-vertical)
(make-column-markup (list markup capo-markup))
(make-line-markup (list markup (make-hspace-markup 1)
capo-markup))))))))
And the error:
anthony@ashdown ~/gitstuff/music/Hymnal/Choruses $ lilypond
HeGaveMeBeautyForAshes.ly
GNU LilyPond 2.15.6
Processing `HeGaveMeBeautyForAshes.ly'
Parsing...
Interpreting music... ERROR: In procedure memoization:
ERROR: In file "/usr/local/share/lilypond/2.15.6/scm/chord-name.scm",
line 173: Bad binding chord-function in expression (let (chord-function
(ly:context-property context (quote chordNameFunction) #f)) (capo-pitch
(ly:context-property context (quote capoPitch) #f)) (if (not
(capo-pitch)) (chord-function pitches bass inversion context) (let
((new-pitches (map (lambda # #) pitches)) (new-bass (and (ly:pitch?
bass) (ly:pitch-transpose bass capo-pitch))) (new-inversion (and
(ly:pitch? inversion) (ly:pitch-transpose inversion capo-pitch)))
(capo-markup (make-parenthesize-markup (chord-function new-pitches
new-bass new-inversion context))) (markup (chord-function pitches bass
inversion context)) (capo-vertical (ly:context-property context (quote
capoVertical) #f)) (if (capo-vertical) (make-column-markup (list markup
capo-markup)) (make-line-markup (list markup # capo-markup))))))).
anthony@ashdown ~/gitstuff/music/Hymnal/Choruses $
Cheers,
Wol
>From a3ecdace013082f319987bd7aa98aa54d9decd0b Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Wed, 20 Jul 2011 18:49:43 +0100
Subject: [PATCH 1/3] Add capo-handler function for guitar chords
---
scm/chord-name.scm | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/scm/chord-name.scm b/scm/chord-name.scm
index 79b0189..6910044 100644
--- a/scm/chord-name.scm
+++ b/scm/chord-name.scm
@@ -170,3 +170,27 @@ FOOBAR-MARKUP) if OMIT-ROOT is given and non-false.
(alist (map chord-to-exception-entry elts)))
(filter (lambda (x) (cdr x)) alist)))
+(define-public (capo-handler pitches bass inversion context)
+ (let (chord-function (ly:context-property context 'chordNameFunction #f))
+ (capo-pitch (ly:context-property context 'capoPitch #f))
+ (if (not (capo-pitch)) ;; if there's no capo pitch or no
chord
+ (chord-function pitches bass inversion context) ;; call the
chordNameFunction as of old
+ (let ((new-pitches ;; else
transpose the pitches and do the chord twice
+ (map (lambda (p)
+ (ly:pitch-transpose p capo-pitch))
+ pitches))
+ (new-bass
+ (and (ly:pitch? bass)
+ (ly:pitch-transpose bass capo-pitch)))
+ (new-inversion
+ (and (ly:pitch? inversion)
+ (ly:pitch-transpose inversion
+ capo-pitch)))
+
+ (capo-markup (make-parenthesize-markup (chord-function new-pitches
new-bass new-inversion context)))
+ (markup (chord-function pitches bass inversion context))
+
+ (capo-vertical (ly:context-property context 'capoVertical #f))
+ (if (capo-vertical)
+ (make-column-markup (list markup capo-markup))
+ (make-line-markup (list markup (make-hspace-markup 1)
capo-markup))))))))
--
1.7.3.4
>From 1fac8b04ed35228fd043e5143199eaaef34890db Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Wed, 20 Jul 2011 18:52:24 +0100
Subject: [PATCH 2/3] Add capo properties to define-context-properties
---
scm/define-context-properties.scm | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/scm/define-context-properties.scm
b/scm/define-context-properties.scm
index dab5211..d17f72f 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -135,6 +135,8 @@ that normally end on beats.")
(beatStructure ,list? "List of @code{baseMoment}s that are combined
to make beats.")
+ (capoPitch ,ly:pitch? "The pitch to transpose chords down by when using
the capo.")
+ (capoVertical ,boolean? "Whether to display actual and transposed pitches
above each other or not.")
(chordChanges ,boolean? "Only show changes in chords scheme?")
(chordNameExceptions ,list? "An alist of chord exceptions.
Contains @code{(@var{chord} . @var{markup})} entries.")
--
1.7.3.4
>From 3426c1bb03d1df09f918bbaefc19d3a6c466268c Mon Sep 17 00:00:00 2001
From: Wol <[email protected]>
Date: Wed, 20 Jul 2011 19:01:18 +0100
Subject: [PATCH 3/3] Modify chord-name-engraver to call capo-handler
---
lily/chord-name-engraver.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc
index d0ced5a..2442cdb 100644
--- a/lily/chord-name-engraver.cc
+++ b/lily/chord-name-engraver.cc
@@ -124,8 +124,8 @@ Chord_name_engraver::process_music ()
pitches = scm_sort_list (pitches, Pitch::less_p_proc);
- SCM name_proc = get_property ("chordNameFunction");
- markup = scm_call_4 (name_proc, pitches, bass, inversion,
+ SCM capo_proc = ly_lily_module_constant ("capo-handler");
+ markup = scm_call_4 (capo_proc, pitches, bass, inversion,
context ()->self_scm ());
}
/*
--
1.7.3.4