[-- Attachment #1: Type: text/plain, Size: 1448 bytes --] Dear Babel developers, Inspired by the newly available Lilypond, I hacked up a first version of language support for Fomus (http://fomus.sourceforge.net/). Briefly, Fomus is a music notation system that translates a relatively simple domain specific music language into multiple output formats, including Lilypond and MusicXML (the latter is an open format supported by many commercial music notation systems such as Finale and Sibelius). In a nutshell, Fomus can simplify the generation of complex scores, because it can add various score information automatically. Anyway, please find my first attempt of a Fomus integration attached. This works already fine for standard code blocks such as the following. Note that the result of this is a Lilypond file. #+begin_src fomus :file test1.ly time 0 dur 2 pitch 60; time 2 dur 1 pitch 62; time 3 dur 1 pitch 63; time 4 dur 4 pitch 65; #+end_src Of course, because this is a quick hack, various improvements can be made. For example, it might be a good idea to allow for something like :file test.pdf, where the resulting Lilypond call would see file.ly, but the automatically inserted link in the org buffer would be the resulting file.pdf. Comments are welcome. Best wishes, Torsten -- Dr Torsten Anders Course Leader, Music Technology University of Bedfordshire Park Square, Room A315 http://strasheela.sourceforge.net http://www.torsten-anders.de [-- Attachment #2: ob-fomus.el --] [-- Type: application/octet-stream, Size: 2496 bytes --] ;;; ob-fomus.el --- org-babel functions for fomus evaluation ;; Copyright (C) 2011 Free Software Foundation, Inc. ;; Author: Torsten Anders, Eric Schulte ;; Keywords: literate programming, reproducible research ;; Homepage: http://orgmode.org ;; Version: ;;; Commentary: ;; Org-Babel support for evaluating Fomus source code. ;; For information on Fomus see http://fomus.sourceforge.net/ ;; ;; This differs from most standard languages in that ;; ;; 1) there is no such thing as a "session" in fomus ;; ;; 2) we are generally only going to return results of type "file" ;; ;; 3) we are adding the "file" and "cmdline" header arguments ;; ;; 4) there are no variables (at least for now) ;;; Code: (require 'ob) (require 'ob-eval) (defvar org-babel-default-header-args:fomus '((:results . "file") (:exports . "results")) "Default arguments to use when evaluating a fomus source block.") (defun org-babel-expand-body:fomus (body params) "Expand BODY according to PARAMS, return the expanded body." (let ((vars (mapcar #'cdr (org-babel-get-header params :var)))) (mapc (lambda (pair) (let ((name (symbol-name (car pair))) (value (cdr pair))) (setq body (replace-regexp-in-string (concat "\$" (regexp-quote name)) (if (stringp value) value (format "%S" value)) body)))) vars) body)) (defun org-babel-execute:fomus (body params) "Execute a block of Fomus code with org-babel. This function is called by `org-babel-execute-src-block'." (let* ((result-params (cdr (assoc :result-params params))) (out-file (cdr (assoc :file params))) (cmdline (cdr (assoc :cmdline params))) (cmd (or (cdr (assoc :cmd params)) "fomus")) (in-file (org-babel-temp-file "fomus-" ".fms"))) (with-temp-file in-file (insert (org-babel-expand-body:fomus body params))) ;; TMP: testing ;; (message (concat cmd ;; " " (org-babel-process-file-name in-file) ;; " " cmdline ;; " -o " (org-babel-process-file-name out-file))) (org-babel-eval (concat cmd " " (org-babel-process-file-name in-file) " " cmdline " -o " (org-babel-process-file-name out-file)) "") nil)) ;; signal that output has already been written to file (defun org-babel-prep-session:fomus (session params) "Return an error because Fomus does not support sessions." (error "Fomus does not support sessions")) (provide 'ob-fomus) ;; arch-tag: 817d0516-7b47-4f77-a8b2-2aadd8e4d0e2 ;;; ob-fomus.el ends here [-- Attachment #3: Type: text/plain, Size: 5 bytes --]
Hi Torsten, Thanks for sharing this, it looks great, short clear and to the point. Shall I add it to the contrib/ directory? Best -- Eric Torsten Anders <torsten.anders@beds.ac.uk> writes: > Dear Babel developers, > > Inspired by the newly available Lilypond, I hacked up a first version > of language support for Fomus > (http://fomus.sourceforge.net/). Briefly, Fomus is a music notation > system that translates a relatively simple domain specific music > language into multiple output formats, including Lilypond and MusicXML > (the latter is an open format supported by many commercial music > notation systems such as Finale and Sibelius). In a nutshell, Fomus > can simplify the generation of complex scores, because it can add > various score information automatically. Anyway, please find my first > attempt of a Fomus integration attached. > > This works already fine for standard code blocks such as the following. Note that the result of this is a Lilypond file. > > #+begin_src fomus :file test1.ly > time 0 dur 2 pitch 60; > time 2 dur 1 pitch 62; > time 3 dur 1 pitch 63; > time 4 dur 4 pitch 65; > #+end_src > > Of course, because this is a quick hack, various improvements can be > made. For example, it might be a good idea to allow for something like > :file test.pdf, where the resulting Lilypond call would see file.ly, > but the automatically inserted link in the org buffer would be the > resulting file.pdf. > > Comments are welcome. > > Best wishes, > Torsten > > -- > Dr Torsten Anders > Course Leader, Music Technology > University of Bedfordshire > Park Square, Room A315 > http://strasheela.sourceforge.net > http://www.torsten-anders.de > > > > > > > -- Eric Schulte http://cs.unm.edu/~eschulte/
Dear Eric, On 8 Jul 2011, at 02:38, Eric Schulte wrote: > > Thanks for sharing this, it looks great, short clear and to the point. > > Shall I add it to the contrib/ directory? If you think it is already at that point, that is certainly fine by me. Best, Torsten > > Best -- Eric > > Torsten Anders <torsten.anders@beds.ac.uk> writes: > >> Dear Babel developers, >> >> Inspired by the newly available Lilypond, I hacked up a first version >> of language support for Fomus >> (http://fomus.sourceforge.net/). Briefly, Fomus is a music notation >> system that translates a relatively simple domain specific music >> language into multiple output formats, including Lilypond and MusicXML >> (the latter is an open format supported by many commercial music >> notation systems such as Finale and Sibelius). In a nutshell, Fomus >> can simplify the generation of complex scores, because it can add >> various score information automatically. Anyway, please find my first >> attempt of a Fomus integration attached. >> >> This works already fine for standard code blocks such as the following. Note that the result of this is a Lilypond file. >> >> #+begin_src fomus :file test1.ly >> time 0 dur 2 pitch 60; >> time 2 dur 1 pitch 62; >> time 3 dur 1 pitch 63; >> time 4 dur 4 pitch 65; >> #+end_src >> >> Of course, because this is a quick hack, various improvements can be >> made. For example, it might be a good idea to allow for something like >> :file test.pdf, where the resulting Lilypond call would see file.ly, >> but the automatically inserted link in the org buffer would be the >> resulting file.pdf. >> >> Comments are welcome. >> >> Best wishes, >> Torsten >> >> -- >> Dr Torsten Anders >> Course Leader, Music Technology >> University of Bedfordshire >> Park Square, Room A315 >> http://strasheela.sourceforge.net >> http://www.torsten-anders.de >> >> >> >> >> >> >> > > -- > Eric Schulte > http://cs.unm.edu/~eschulte/ >
Torsten Anders <torsten.anders@beds.ac.uk> writes: > Dear Eric, > > On 8 Jul 2011, at 02:38, Eric Schulte wrote: >> >> Thanks for sharing this, it looks great, short clear and to the point. >> >> Shall I add it to the contrib/ directory? > > If you think it is already at that point, that is certainly fine by me. > Great, I do prefer to fold new languages in early so that they can benefit from wider use and testing. This is now located in contrib/babel/langs/. Thanks for the contribution -- Eric > > Best, > Torsten > > >> >> Best -- Eric >> >> Torsten Anders <torsten.anders@beds.ac.uk> writes: >> >>> Dear Babel developers, >>> >>> Inspired by the newly available Lilypond, I hacked up a first version >>> of language support for Fomus >>> (http://fomus.sourceforge.net/). Briefly, Fomus is a music notation >>> system that translates a relatively simple domain specific music >>> language into multiple output formats, including Lilypond and MusicXML >>> (the latter is an open format supported by many commercial music >>> notation systems such as Finale and Sibelius). In a nutshell, Fomus >>> can simplify the generation of complex scores, because it can add >>> various score information automatically. Anyway, please find my first >>> attempt of a Fomus integration attached. >>> >>> This works already fine for standard code blocks such as the following. Note that the result of this is a Lilypond file. >>> >>> #+begin_src fomus :file test1.ly >>> time 0 dur 2 pitch 60; >>> time 2 dur 1 pitch 62; >>> time 3 dur 1 pitch 63; >>> time 4 dur 4 pitch 65; >>> #+end_src >>> >>> Of course, because this is a quick hack, various improvements can be >>> made. For example, it might be a good idea to allow for something like >>> :file test.pdf, where the resulting Lilypond call would see file.ly, >>> but the automatically inserted link in the org buffer would be the >>> resulting file.pdf. >>> >>> Comments are welcome. >>> >>> Best wishes, >>> Torsten >>> >>> -- >>> Dr Torsten Anders >>> Course Leader, Music Technology >>> University of Bedfordshire >>> Park Square, Room A315 >>> http://strasheela.sourceforge.net >>> http://www.torsten-anders.de >>> >>> >>> >>> >>> >>> >>> >> >> -- >> Eric Schulte >> http://cs.unm.edu/~eschulte/ >> > > -- Eric Schulte http://cs.unm.edu/~eschulte/
Hi Eric,
Eric Schulte <schulte.eric@gmail.com> writes:
> I do prefer to fold new languages in early so that they can benefit from
> wider use and testing.
>
> This is now located in contrib/babel/langs/.
Thanks. I slightly updated library-of-babel.org to list existing
supported languages, either in core or in contrib/babel/langs/.
--
Bastien
Bastien <bzg@altern.org> writes: > Hi Eric, > > Eric Schulte <schulte.eric@gmail.com> writes: > >> I do prefer to fold new languages in early so that they can benefit from >> wider use and testing. >> >> This is now located in contrib/babel/langs/. > > Thanks. I slightly updated library-of-babel.org to list existing > supported languages, either in core or in contrib/babel/langs/. Thanks for making this change. -- Eric -- Eric Schulte http://cs.unm.edu/~eschulte/