lilypond-devel
[Top][All Lists]
Advanced

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

Re: Even more disconnected


From: Graham Percival
Subject: Re: Even more disconnected
Date: Mon, 21 Aug 2006 01:28:08 -0700
User-agent: Thunderbird 1.5.0.5 (Macintosh/20060719)

Erik Sandberg wrote:
I've been thinking
about one other solution as well: IIRC you have said it would be fairly easy to create a lilypond daemon, which could process .ly files on demand with a short start-up time. If all .ly snippets of a make web are processed by a single instance of lilypondd, then we will get an even better memory leak check.

I'm making heavy use of this for my Masters thesis, which I'll be starting in two weeks (well, the degree program; I'm not writing the thesis yet). The attached lilypond file is fed info from a perl script which I've finished writing, but it currently undocumented (and thus no recent public release). I'm planning on finishing it within a week, though.

It wouldn't be too hard to give it info from .ly files -- actually, an earlier version of my perl script did just that. On the command-line, you can use "netcat foo.ly 2904". The one problem is that the server only accepts notes, not funky \paper stuff, so I don't think you can just drop this in and process all the input/ files.


Warning: this is my first attempt at modifying scheme code; parenthesis were added on a "get this to compile" basis, and proper indentation is completely out the window. My perl code is much nicer than this. :)

Cheers,
- Graham

\version "2.7.39"
#(if #t
(let ((count 0))
(let ((filename "lilyserver.preview.png"))
  (let ((s (socket PF_INET SOCK_STREAM 0)))
       (setsockopt s SOL_SOCKET SO_REUSEADDR 1)
       (bind s AF_INET INADDR_ANY 2904)
       (listen s 5)

;;       (simple-format #t "Listening for clients in pid: ~S" (getpid))
       (newline)

       (while #t
              (let* ((client-connection (accept s))
                     (start-time (get-internal-real-time))
                     (client-details (cdr client-connection))
                     (client (car client-connection)))
;;                (simple-format #t "Got new client connection: ~S"
;;                               client-details)
;;                (newline)
;;                (simple-format #t "Client address: ~S"
;;                               (gethostbyaddr
;;                                (sockaddr:addr client-details)))
;;                (newline)
                ;; Send back the greeting to the client port
;;                (display (format
;;                          "hello LilyPond ~a\n"
;;                         (lilypond-version))
;;                          client)

               (let* ((question (read client))
                      (result (ly:parse-string-result
                               (format " \\notemode {  ~a } " question)
                               (ly:clone-parser parser))))
                      
                (print-music-as-book parser result)
        ;; Tells the client it is finished
                        (if (> count 0)
                                        (set! filename (string-append 
"lilyserver-" (number->string count) ".preview.png")))

                (let ((p (open-input-file filename)))
                (let f ((p p))
       (let ((x (read-char p)))
         (cond
          ((eof-object? x)
           (close-input-port p))
          (else
           (write-char x client)
           (f p))))))) 


                ;;(close-input-port lilyoutput)))

                (close client)

                                (set! count (+ count 1))
;;                (display (format "Finished. Time elapsed: ~a\n"
;;                          (/ (- (get-internal-real-time) start-time)
;;                         (* 1.0 internal-time-units-per-second))

                        ))
                (gc) ; do GC while app is refreshing the screen.
              )))))))


reply via email to

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