From mboxrd@z Thu Jan 1 00:00:00 1970 From: Torsten Anders Subject: Babel: 1st version for music notation language Fomus Date: Thu, 7 Jul 2011 18:34:51 +0100 Message-ID: Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: multipart/mixed; boundary=Apple-Mail-19-1040409702 Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QesTb-0004Sv-5N for emacs-orgmode@gnu.org; Thu, 07 Jul 2011 13:35:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QesTZ-0008VB-Lv for emacs-orgmode@gnu.org; Thu, 07 Jul 2011 13:34:59 -0400 Received: from smtp.idnet.com ([212.69.40.133]:44629) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QesTZ-0008V5-9H for emacs-orgmode@gnu.org; Thu, 07 Jul 2011 13:34:57 -0400 Received: from localhost (unknown [127.0.0.1]) by smtp.idnet.com (Postfix) with ESMTP id 7D7552FDC4A for ; Thu, 7 Jul 2011 17:34:53 +0000 (UTC) Received: from smtp.idnet.com ([127.0.0.1]) by localhost (smtp.idnet.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id GalIbQ6+sCSv for ; Thu, 7 Jul 2011 18:34:51 +0100 (BST) Received: from smtp.idnet.com (template [127.0.0.1]) by smtp.idnet.com (Postfix) with ESMTP id F233F2FDC7C for ; Thu, 7 Jul 2011 18:34:50 +0100 (BST) Received: from [192.168.0.3] (cust132-dsl91-135-3.idnet.net [91.135.3.132]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by smtp.idnet.com (Postfix) with ESMTPS id AEF3E2FDC4A for ; Thu, 7 Jul 2011 18:34:50 +0100 (BST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --Apple-Mail-19-1040409702 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Dear Babel developers,=20 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;=20 time 2 dur 1 pitch 62;=20 time 3 dur 1 pitch 63;=20 time 4 dur 4 pitch 65;=20 #+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.=20 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 --Apple-Mail-19-1040409702 Content-Disposition: attachment; filename=ob-fomus.el Content-Type: application/octet-stream; name="ob-fomus.el" Content-Transfer-Encoding: 7bit ;;; 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 --Apple-Mail-19-1040409702 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii --Apple-Mail-19-1040409702--