lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with mixing Scheme and Music


From: Carl Sorensen
Subject: Help with mixing Scheme and Music
Date: Wed, 22 Dec 2010 22:13:45 -0700

Hi,

I'm trying to get an easier method of creating custom string tunings (see
http://article.gmane.org/gmane.comp.gnu.lilypond.general/60871)

I'd like to do one of the following:

\makeStringTuning #'violin-tuning <g d' a' e''>

or 

violin-tuning = \makeStringTuning <g d' a' e''>


I can get the chord music argument into a scheme function if I define
\makeStringTuning as a music function, but I'm having a hard time getting
the stringTuning (which is a Scheme list) out.

I've tried

makeStringTuning =
#(define-music-function (parser location tuning chord)
   (symbol? ly:music?)
   (let* ((ev-chord (car (extract-named-music chord 'EventChord)))
          (pitches (event-chord-pitches ev-chord)))
     (set! tuning pitches)
     (make-music 'SequentialMusic 'void #t)))

but this fails because it tries to set tuning to pitches, instead of setting
the passed symbol to pitches.  Plus I think it fails because the symbol that
is passed in hasn't yet been defined in the top-level context.


I've also tried

makeStringTuning =
#(lambda (chord)
  (let* ((ev-chord (car (extract-named-music chord 'EventChord)))
         (pitches (event-chord-pitches ev-chord)))
    (display pitches)
    (display (defined? (string->symbol tuning)))
    (set! (string->symbol tuning) pitches)    (make-music 'SequentialMusic
'void #t)))


mychord = { 
 <g d' a' e''>
}
violinTuning = \makeStringTuning \mychord
#(display violinTuning)


But this doesn't work because of delayed evaluation -- violinTuning is just
set to be the lambda function, not the lambda function applied to the
argument.

Any tips on how to resolve this?

Thanks,

Carl




reply via email to

[Prev in Thread] Current Thread [Next in Thread]