Re: [frogs] Guitar capo code in scheme

[ Thread Index | Date Index | More lilynet.net/frogs Archives ]


This is a multi-part message in MIME format.
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






Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/