[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question regaring editor / debugger idea
From: |
Nicolas Sceaux |
Subject: |
Re: Question regaring editor / debugger idea |
Date: |
Sun, 16 May 2004 15:48:33 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Fri, 14 May 2004 13:38:07 -0400, David a dit :
> I've started on a language reference. You can take a look at what
> I've got so far. See attached. It's not much but it's a start.
> Also, look in the files in /usr/local/share/lilypond/<version>/ly (or
> as appropriate for your system). A lot of stuff is in there.
> David
A bit off topic, but still about notation: I use the following document
as a reference for scheme:
http://nicolas.sceaux.free.fr/notation-book.html
it is generated by the ly file:
%%% Run:
%%% lilypond-bin -e "(define-public out \"$PWD/notation-book.html\")"
notation-book.ly
%%% to generate notation-book.html
#(use-modules (ice-9 format)
(ice-9 optargs)
(ice-9 regex)
(guile-user)
(lily)
(srfi srfi-1))
%%;;;;;;;;;;;;;;;;;;;;;;;;
#(define-module (lily))
#(define*-public (markup->make-markup markup-expression)
"Generate a expression that, when evaluated, return an equivalent markup
expression"
(define (inner-markup->make-markup mrkup)
(let ((cmd (car mrkup))
(args (cdr mrkup)))
`(,(proc->command cmd) ,@(map transform-arg args))))
(define (proc->command proc)
(let ((cmd-markup (symbol->string (procedure-name proc))))
(symbol->keyword (string->symbol (substring cmd-markup 0 (-
(string-length cmd-markup)
(string-length "-markup")))))))
(define (transform-arg arg)
(cond ((and (pair? arg) (pair? (car arg))) ;; markup list
(apply append (map inner-markup->make-markup arg)))
((pair? arg) ;; markup
(inner-markup->make-markup arg))
(else ;; scheme arg
arg)))
`(markup ,@(inner-markup->make-markup markup-expression)))
#(define*-public (mus:pretty-string obj #:optional (depth 0))
(cond ((ly:music? obj)
(format #f "(make-music '~a~{~a~})"
(ly:music-property obj 'name)
(map (lambda (prop)
(format #f "~%~v_'~a ~a"
(+ 2 (* 13 depth))
(car prop)
(cond ((list? (cdr prop))
(format #f "(~{~a~})"
(map (lambda (mus)
(format #f "~%~v_~a"
(* 13 (1+ depth))
(mus:pretty-string mus (1+ depth))))
(cdr prop))))
((string? (cdr prop))
(string-append "\"" (cdr prop) "\""))
(else
(mus:pretty-string (cdr prop) (1+
depth))))))
(remove (lambda (prop)
(eqv? (car prop) 'origin))
(ly:music-mutable-properties obj)))))
((string? obj) (format #f "\"~a\"" obj))
((symbol? obj) (format #f "'~a" obj))
((ly:duration? obj) (format #f "(ly:make-duration ~a ~a ~a ~a)"
(ly:duration-log obj)
(ly:duration-dot-count obj)
(car (ly:duration-factor obj))
(cdr (ly:duration-factor obj))))
((ly:pitch? obj) (format #f "(ly:make-pitch ~a ~a ~a)"
(ly:pitch-octave obj)
(ly:pitch-notename obj)
(ly:pitch-alteration obj)))
((procedure? obj) (or (procedure-name obj) (format #f "(lambda ...)")))
((and (list? obj) (markup-function? (car obj)))
(format #f "~a" (markup->make-markup obj)))
(format #f "~a" obj)))
%%;;;;;;;;;;;;;;;;;;;;;;;;
#(define-module (*anonymous-ly-1*))
#(define (htmlize text)
(regexp-substitute/global #f ">"
(regexp-substitute/global #f "<" text 'pre "<"
'post)
'pre ">" 'post))
#(define (book text)
(format #t "~%~%~%<h1>~a</h1>~%" text))
#(define (chapter text)
(format #t "~%~%<h2>~a</h2>~%" text))
#(define (section text)
(format #t "~%<h3>~a</h3>~%" text))
#(define (comment text)
(format #t "~%<pre>~a</pre>~%" (htmlize text)))
#(define-public (read-and-htmlize-lily chr port)
(let ((lily-string (call-with-output-string
(lambda (out)
(do ((c (read-char port) (read-char port)))
((and (char=? c #\#)
(char=? (peek-char port) #\])) ;; we stop
when #] is encoutered
(read-char port))
(display c out))))))
`(let ((lily-expr (car (ly:music-property (ly:parse-string-result
,lily-string parser (current-module))
'elements))))
(format #t "~%<div style=\"border: 1pt solid black; padding: 0px;
margin: 5px;\">
<pre style=\"padding: 5px; margin: 0px; background-color: #ffffee\">~a</pre>~%
<pre style=\"padding: 5px; margin: 0px; background-color:
#ffeeee\">~a</pre>~%</div>"
(htmlize ,lily-string)
(htmlize (mus:pretty-string lily-expr))))))
#(read-hash-extend #\[ read-and-htmlize-lily)
%%;;;;;
#(define (blanker grob grob-origin context)
(if (and (memq (ly:get-grob-property grob 'interfaces)
note-head-interface)
(eq? (ly:get-grob-property grob 'staff-position) 0))
(ly:set-grob-property! grob 'transparent #t)))
#(define-public (write-notation-book file)
(with-output-to-file file
(lambda ()
(format #t "<html>~%<head>~% <title>Music
expressions</title>~%</head>~%~%<body>")
(book "Scheme notation book")
;;
(chapter "Note entry")
;;
(section "Notes")
#[ \notes { cis'4 } #]
;; (section "Pitches")
;; (comment "==> define pitch maker")
(section "Chromatic alterations")
#[ \notes { cis' cis'! cis'? } #]
(section "Chords")
#[\notes { <c e g>2. }#]
(section "Rests")
#[\notes { r8 }#]
#[\notes { d'4\rest }#]
(section "Skips")
#[\notes { s8 }#]
;; (section "Durations")
;; (comment "==> define duration maker")
(section "Stems")
#[\notes { c8[ e] }#]
(section "Ties")
#[\notes { e' ~ e' }#]
(section "Tuplets")
#[\notes { \times 2/3 {c'4 c' c'} }#]
;;
(chapter "Staff notation")
;;
(section "Key signature")
#[\notes { \key g \minor }#]
(section "Clef")
#[\notes { \clef bass }#]
;; ==> clef maker (clef pitch line #:optional octaviation)
(section "Time signature")
#[\notes { \time 3/4 }#]
#[\notes { #(set-time-signature 9 8 '(2 2 2 3)) }#]
(section "Partial measures")
#[\notes { \partial 16*5 }#]
(comment " \partial duration <=> \set Timing.measurePosition = -length of
duration")
(section "Bar lines")
#[\notes { \bar "|:" }#]
;;
(chapter "Expressive marks")
;;
(section "Slurs")
#[\notes { f( g) }#]
(section "Phrasing slurs")
#[\notes { f\( g\) }#]
(section "Breath marks")
#[\notes { c4 \breathe d4 }#]
(section "Metronome marks")
#[\notes { \tempo 8.=120 }#]
(section "Text spanners")
#[\notes { c1
\override TextSpanner #'direction = #-1
\override TextSpanner #'edge-text = #'("rall " . "")
c2\startTextSpan b c\stopTextSpan a }#]
(section "Analysis brackets")
#[\notes { c4\startGroup c4\stopGroup }#]
(section "Articulations")
#[\notes { c''4^^ }#]
#[\notes { c''4_. }#]
#[\notes { c\fermata }#]
(section "Fingering instructions")
#[\notes { c''4-1 }#]
(section "Text scripts")
#[\notes { c4^"longtext" }#]
(section "Grace notes")
#[\notes { \acciaccatura d8 c4 }#]
#[\notes { \appoggiatura d8 c4 }#]
#[\notes { \grace d8 c4 }#]
(section "Glissando")
#[\notes { c\glissando c' }#]
(section "Dynamics")
#[\notes { c4\sfz }#]
#[\notes { c4_\pp }#]
#[\notes { c''\< c''\! }#]
#[\notes { d''\decr e''\enddecr }#]
;;
(chapter "Repeats")
;;
(section "Repeat syntax ")
#[\notes { \repeat volta 2 { c4 } }#]
#[\notes { \repeat volta 4 { e1 }
\alternative { { g2. } { a4 } } }#]
(section "Manual repeat commands")
#[ \notes { c4
\set Score.repeatCommands = #'((volta "93") end-repeat)
c4 c4
\set Score.repeatCommands = #'((volta #f))
c4 c4 }#]
(section "Tremolo repeats")
#[\notes { \repeat "tremolo" 8 { c16 d16 } }#]
#[\notes { \repeat "tremolo" 4 c16 }#]
(section "Tremolo subdivisions")
#[\notes { c':32 }#]
(section "Measure repeats")
#[\notes { \repeat "percent" 4 { c'4 } }#]
;;
(chapter "Piano music")
;;
(section "Automatic staff changes")
#[ \notes \autochange \new Voice { g'4 }#]
(section "Manual staff switches")
#[\change Staff = "down"#]
(section "Arpeggio")
#[\notes { <c e g c>\arpeggio }#]
;;
(chapter "Vocal music")
;;
(section "Entering lyrics")
#[\lyrics { hel8 -- lo wo2 __ orld4 }#]
(section "The Lyrics context")
#[\notes << \context Voice = "lala" { f4 }
\lyricsto "lala" \new Lyrics \lyrics { la } >>#]
;;
(chapter "Chord names")
;;
#[\chords { c1 f:sus4 }#]
;;
(chapter "Orchestral music")
;;
(section "Rehearsal marks")
#[\notes { \mark \default }#]
#[\notes { \mark #8 }#]
#[\notes { \mark \markup \musicglyph #"scripts-ufermata" }#]
(section "Transpose")
#[\notes { \transpose c g' { c d } }#]
(section "Multi measure rests")
#[\notes { R1*17 }#]
(section "Automatic part combining")
#[\notes { \partcombine { c1 } { e1 } }#]
(section "Different editions from one source")
#[\notes { \tag #'score c1 }#]
;;
(chapter "Ancient notation")
;;
(section "Figured bass")
#[\figures { <6>4 <6+ [_!]>8 <6 5 [3+] > }#]
;;
(chapter "Tuning output")
;;
(section "Tuning objects")
#[\notes { \once \override Voice.Fingering #'padding = #3 }#]
#[\notes { \revert Stem #'thickness }#]
(section "Applyoutput")
#[\applyoutput #blanker#]
;;
;;(book "Technical manual")
;;
(chapter "Interpretation context")
;;
(section "Creating contexts")
#[\notes { \context Staff = "another" e4 }#]
#[\notes { \context Staff e4 }#]
#[\notes { \new Staff e4 }#]
(section "Context properties")
#[\notes { \set melismaBusy = #t }#]
#[\notes { \unset Voice.melismaBusy }#]
(section "Context evaluation")
#[\applycontext #(lambda (x)
(format #t "\nWe were called in barnumber ~a.\n"
(ly:get-context-property x
'currentBarNumber)))#]
(section "Changing contexts locally")
#[\notes { \new Staff \with {
\override StaffSymbol #'staff-space =
#(magstep 1.5)
fontSize = #1.5
\consists "Time_signature_engraver"
\remove "Clef_engraver" }
{ } }#]
;;
(chapter "Music storage format")
;;
(section "Music expressions")
#[\notes\simultaneous { c e }#]
#[\notes\sequential { c e }#]
(section "Manipulating music expressions")
(comment "(applymusic proc music-expr)")
;;
(format #t "~%</body>~%</html>")))
'())
#(let ((out-file (if (defined? 'out) out "/tmp/notation-book.html")))
(format #t "~%Writing ~a...~%" out-file)
(write-notation-book out-file)
(format #t "~%done.~%"))
\score { \notes { c' } }
nicolas