lilypond-user
[Top][All Lists]
Advanced

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

Re: Beginners problem with display in an include file


From: Paul Morris
Subject: Re: Beginners problem with display in an include file
Date: Wed, 19 Nov 2014 21:35:28 -0700 (MST)

Peter Gentry wrote
> \version "2.18.2"
> ;;; OS Vista and Frescobaldi
> ;;; attempt to improve include file enharmonic.ly
> ;;; why does guile display fail to produce an output to thefresobaldi log
> file
> #(ly:message "Test debug 1\n")
> #(define (naturalize-pitch p)
> (let ((o (ly:pitch-octave p))
> (a (* 4 (ly:pitch-alteration p)))
> ;;; alteration, a, in quarter tone steps,
> ;; for historical reasons
> (n (ly:pitch-notename p)))
> (cond
> ((and (> a 1) (or (eq? n 6) (eq? n 2)))
> (set! a (- a 2))
> (set! n (+ n 1)))
> ((and (< a -1) (or (eq? n 0) (eq? n 3)))
> (set! a (+ a 2))
> (set! n (- n 1))))
> (display a)
> (cond
>  ((> a 2) (ly:message "a>2"))
>  ((< a -2) (ly:message "a<-2"))
> )
> (cond
> ((> a 2) (set! a (- a 4)) (set! n (+ n 1)))
> ((< a -2) (set! a (+ a 4)) (set! n (- n 1))))
> (cond
>  ((< n 0) (ly:message "n<0"))
>  ((= n 0) (ly:message "n=0"))
>  ((= n 1) (ly:message "n=1"))
>  ((= n 2) (ly:message "n=2"))
>  ((= n 3) (ly:message "n=3"))
>  ((= n 4) (ly:message "n=4"))
>  ((= n 5) (ly:message "n=5"))
>  ((= n 6) (ly:message "n=6"))
>  ((> n 6) (ly:message "n>6"))
> )
> (if (< n 0) (begin (set! o (- o 1)) (set! n (+ n 7))))
> (if (> n 6) (begin (set! o (+ o 1)) (set! n (- n 7))))
> (ly:make-pitch o n (/ a 4))))
> #(ly:message "Test debug 3\n")
> #(define (naturalize music)
> (let ((es (ly:music-property music 'elements))
> (e (ly:music-property music 'element))
> (p (ly:music-property music 'pitch)))
> (if (pair? es)
> (ly:music-set-property!
> music 'elements
> (map (lambda (x) (naturalize x)) es)))
> (if (ly:music? e)
> (ly:music-set-property!
> music 'element
> (naturalize e)))
> (if (ly:pitch? p)
> (begin
> (set! p (naturalize-pitch p))
> (ly:music-set-property! music 'pitch p)))
> music))
> naturalizeMusic =
> #(define-music-function (parser location m)
> (ly:music?)
> (ly:message "Test debug 4\n")
> (naturalize m))
> 
> I an trying to get some debug feedback from the code but ly:message only
> seems to allow strings and display reutns nothing. I'll bet
> it's a simple missunderstanding of the guile scheme interface.
> 
> regards
> Peter Gentry 

Hi Peter,  I tried your code and everything seems to be working for me.  I
just had add the following to call to your naturalizeMusic function:

  \naturalizeMusic { <c e g> bes c dis }

Cheers,
-Paul



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Beginners-problem-with-display-in-an-include-file-tp168792p168833.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

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