Sometimes I have to put text on a path

Tuesday, July 26, 2011

How to post music with LaTeX (in blogger, in your site)? Producing the highest-quality sheet music possible: MusicXML, LilyPond.

Music notation.
3 languages : 
  • MusicXML, 
  • LilyPond,
  • LaTeX (best method if you want to add mathematics, statistics, physics, chemistry, bibliography, diagrams, special drawings...). 


MusicXML is a XML-based music notation file format http://musicxml.org/. As of July 2011, MusicXML is supported to varying degrees by over 150 notation programs. 
MusicXML 2.0 files serve the same role for interactive sheet music that MP3 files serve for recorded music.

You have many sites for music in MusicXML Format:
See an example: http://www.wikifonia.org/node/1141. The rendering for all browser is flash!
Export music notation to MusicXML directly, just dowload compressed MusicXML code.

There are many freeware, and commercial applications http://www.recordare.com/musicxml/community/software
 Just one, a free cross-platform WYSIWYG music notation program: http://musescore.org/. It offers an alternative to professional programs such as Sibelius and Finale. 


"ex-ample":

The Myriad Music Plug-In (http://www.myriad-online.com/en/products/mmplugin.htm) enables you to build Web pages in which music will be played or displayed.Music files are ".mus", ".myr" or ".mu3" files created with Melody Assistant or Harmony Assistant. MusicXML and Packed MusicXML files, ABC files (mono or multi musics) are also managed. 

With firefox 4+, try this interactive music sheet (HTML5 canvas):



One of LilyPond's goals is to produce scores that are engraved with traditional layout rules.
It uses a simple text notation for music input (more concise than LaTeX or musicXML), which LilyPond interprets and processes in a series of stages. In the final stage, music notation is output to PDF or other graphical formats, such as SVG or PNG. LilyPond also has the facility to generate MIDI files that correspond to the music notation output.

Kainhofer wrote the musicxml2ly Python script that comes bundled with Lilypond: http://wiki.kainhofer.com/musicxml2ly/start
musicxml2ly converts MusicXML files to LilyPond syntax. 
Support for compressed MusicXML files (.mxl).


\( \TeX \)

There are many packages, for example: MusiXTeX is a suite of open source music engraving services (macros and fonts) that allow music typesetting in TeX: http://en.wikipedia.org/wiki/MusiXTeX

"ex-ample":
I tried this LaTeX code (see below) with Knol equation editor, Google equation editor, codecogs (http://www.codecogs.com/). These editors do not work: "equation too long"! I also tried Zoho: bad results...
With TeXshop (http://www.texshop.org) the compilation arrived to pdf (transformed to png):


----------LaTeX code-------------

\documentclass[10pt]{article}

 \usepackage[latin1]{inputenc}
 \usepackage[T1]{fontenc}  
 \usepackage{musixtex}
 \usepackage[frenchb]{babel}

 \begin{document}

 \normalmusicsize 

 \begin{music}

 \instrumentnumber{2} % 2 instruments

 \setstaffs 1{2} % instrument 1 (en bas) : 2 portées

 \setclef{1}{60} % clef de fa (6) en 1, clef de sol (0) en 2
 \generalmeter{\meterfrac{4}{4}} % mesure 4/4
 \setname 1{piano} %
 \setname 2{chant} %
 \parindent 10mm % pour éviter la collision de piano avec l'accolade
 \startextract
 % {{bleu|1re mesure}}
 \Notes 
 \ha J | % chgt portée, même instr
 \zhu{c e}\hu g & % chgt instr ; pas d'espace entre } et \hu
 \islurd0c\ibu0d0\qb0{c c c}\tslur0d\tbu0\qb0d 
 \enotes % assure l'alignement
 %
 \Notes 
 \ha N | % chgt portée, même instr
 \zhu{g i}\hu k & % chgt instr
 \qa{e d} 
 \enotes 
 \bar % après toutes les notes de la mesure, pour toutes les voix
 % {{bleu|2e mesure}}
 \Notes
 \qa J | 
 \zqu{c e}\qu g &
 \islurd0c\ibu0d0\qb0{c e} 
 \enotes
 %
 \Notes
 \qa N |
 \zqu{g i}\qu k &
 \qb0{d}\tslur0d\tbu0\qb0d
 \enotes
 %
 \Notes
 \ha J | 
 \zhu{c e}\hu g &
 \ha c 
 \enotes
 %
 \endextract

 \end{music}

 \end{document}
-------------------------

1 comment:

  1. Thank you for the thoughtful review. The main advantage of youtube html5 playerseems to be for embedding rich media such as audio and video in modern browsers. Although, the structure elements seem to be useful. CSS3 seems to be headed in the right direction, leaving many possibilities for implementation and creativity,

    ReplyDelete