Difference between revisions of "Muse2ps"

From CCARH Wiki
Jump to navigation Jump to search
(removed "d" from "muse2ps")
Line 3: Line 3:
 
== Overview ==  
 
== Overview ==  
  
The <b>dmuse2ps</b> program is a command-line version of the [[autoset]], [[mskpage]] and [[pspage]] programs which are usually run within the [[dmuse]] editor using the built-in [[zbex language]] interpreter.  The ''dmuse2ps'' program reads MuseData [[stage2]] data or [[page file]] data from standard input and converts them into PostScript data representing graphical musical notation which is sent to standard output.  The following diagram illustrates the flow of data through ''muse2ps'':
+
The <b>muse2ps</b> program is a command-line version of the [[autoset]], [[mskpage]] and [[pspage]] programs which are usually run within the [[dmuse]] editor using the built-in [[zbex language]] interpreter.  The ''muse2ps'' program reads MuseData [[stage2]] data or [[page file]] data from standard input and converts them into PostScript data representing graphical musical notation which is sent to standard output.  The following diagram illustrates the flow of data through ''muse2ps'':
  
  
Line 10: Line 10:
 
</center>
 
</center>
  
The ''dmuse2ps'' program can accept two forms of input.  By default, the ''dmuse2ps'' program will read multi-file [[stage2]] data from standard input.  MuseData [[stage2]] files contain primarily symbolic musical data with possibly a little bit of formatting information (such as system and page breaks).  The ''dmuse2ps'' program will format this symbolic music internally into [[page files]] which give explicit information about the placement of notes, slurs, beams, dynamics, lyrics, ''etc.'' on each page of music.
+
The ''muse2ps'' program can accept two forms of input.  By default, the ''muse2ps'' program will read multi-file [[stage2]] data from standard input.  MuseData [[stage2]] files contain primarily symbolic musical data with possibly a little bit of formatting information (such as system and page breaks).  The ''muse2ps'' program will format this symbolic music internally into [[page files]] which give explicit information about the placement of notes, slurs, beams, dynamics, lyrics, ''etc.'' on each page of music.
  
 
Alternatively, if the <tt>=p</tt> option is given as an [[argument]] to ''muse2ps'', the program can read multi-file [[page files]] directly from standard input.  Typically, [[stage2]] files are converted automatically into [[pages files]] and then further processing is done on these [[page files]] in order to produce a final typeset score of the graphical music notation.  For example, the [[vskpage]] is used to refine the vertical spacing of staves and systems on a page of music within [[page files]], and [[eskpage]] is used to interactively edit the position of graphical elements within [[page files]].
 
Alternatively, if the <tt>=p</tt> option is given as an [[argument]] to ''muse2ps'', the program can read multi-file [[page files]] directly from standard input.  Typically, [[stage2]] files are converted automatically into [[pages files]] and then further processing is done on these [[page files]] in order to produce a final typeset score of the graphical music notation.  For example, the [[vskpage]] is used to refine the vertical spacing of staves and systems on a page of music within [[page files]], and [[eskpage]] is used to interactively edit the position of graphical elements within [[page files]].
Line 22: Line 22:
 
== Download ==
 
== Download ==
  
The ''dmuse2ps'' program executables for various operating systems or the source code can be downloaded from the following table.  Instructions for setting up the program for use can be found ''[[Muse2ps_installation_instructions| here]]''.
+
The ''muse2ps'' program executables for various operating systems or the source code can be downloaded from the following table.  Instructions for setting up the program for use can be found ''[[Muse2ps_installation_instructions| here]]''.
  
  
Line 37: Line 37:
 
== Command-line examples ==
 
== Command-line examples ==
  
The simplest use of ''dmuse2ps'' is to send it MuseData [[stage2]] files as standard input, and save standard output from the program into a PostScript file:
+
The simplest use of ''muse2ps'' is to send it MuseData [[stage2]] files as standard input, and save standard output from the program into a PostScript file:
  
 
     cat [[Media:bach-wtc1p01.md2|bach-wtc1p01.md2]] | muse2ps > [[Media:bach-wtc1p01.ps|bach-wtc1p01.ps]]
 
     cat [[Media:bach-wtc1p01.md2|bach-wtc1p01.md2]] | muse2ps > [[Media:bach-wtc1p01.ps|bach-wtc1p01.ps]]
Line 221: Line 221:
 
http://dmuse.ccarh.org).  The dmuse program is a text editor which also
 
http://dmuse.ccarh.org).  The dmuse program is a text editor which also
 
has a built-in zbex language interpreter.  The intepreter portion of
 
has a built-in zbex language interpreter.  The intepreter portion of
dmuse has been extracted for non-interactive use in dmuse2ps.
+
dmuse has been extracted for non-interactive use in muse2ps.

Revision as of 01:11, 20 December 2010

Overview

The muse2ps program is a command-line version of the autoset, mskpage and pspage programs which are usually run within the dmuse editor using the built-in zbex language interpreter. The muse2ps program reads MuseData stage2 data or page file data from standard input and converts them into PostScript data representing graphical musical notation which is sent to standard output. The following diagram illustrates the flow of data through muse2ps:


Muse2ps-dataflow.svg

The muse2ps program can accept two forms of input. By default, the muse2ps program will read multi-file stage2 data from standard input. MuseData stage2 files contain primarily symbolic musical data with possibly a little bit of formatting information (such as system and page breaks). The muse2ps program will format this symbolic music internally into page files which give explicit information about the placement of notes, slurs, beams, dynamics, lyrics, etc. on each page of music.

Alternatively, if the =p option is given as an argument to muse2ps, the program can read multi-file page files directly from standard input. Typically, stage2 files are converted automatically into pages files and then further processing is done on these page files in order to produce a final typeset score of the graphical music notation. For example, the vskpage is used to refine the vertical spacing of staves and systems on a page of music within page files, and eskpage is used to interactively edit the position of graphical elements within page files.

The only output from muse2ps (besides error messages) is PostScript data which describes the graphical music notation in a printable score of the music. This data can be further processed, such as sending directly to a PostScript printer, or converting into PDF files for web distrubution of the notated music. The representation of music notation within the PostScript file is in the form of bit-mapped musical fonts. The musical fonts are designed for use with 300 DPI resolution printers when printed at the native resolution (originally these fonts were designed for PCL-based printers). These fonts have the unique feature of dithered edges on sloped beams to minimize the visual effect of pixel stepping at 300 DPI resolution. Minor notation editing can be done on the PostScript/PDF files in programs such as Adobe Illustrator. If you print via PDF files, you may want to uncheck the page-scaling option in the printing program in order to avoid aliasing artifacts in the hard copy.

Two other forms of data can be embedded within the PostScript output. If the =M option is given as an argument to the muse2ps program, then the original stage2 data will be stored within comments in the PostScript data. Likewise, if the =P option is given, the page file data will be included in the PostScript output as comments. The page file data will either come from automatic generation using autoset/mskpage, or from standard input if you use the =p option.

There are also numerous options which primarily deal with the formatting of stage2 files with the autoset and mskpag program components. See the options section below for a complete list of the options.

Download

The muse2ps program executables for various operating systems or the source code can be downloaded from the following table. Instructions for setting up the program for use can be found here.


File Description
muse2ps.tar.bz2    Tar file containing source code and test examples.
muse2ps-linux    Program executable compiled statically for linux.
muse2ps-osx    Program executable compiled for Apple OS X, version 10.4 and higher.
muse2ps.exe    Program executable compiled for Microsoft Windows (prone to stack overflows in older versions of Windows). It is currently advised to download the source code and compile within a Cygwin terminal if you want to run on Windows (not suitable for the amateur Windows user who is not familiar with Unix).

Online

The muse2ps program can be run online at http://www.musedata.org/mdconverter . If you click on E-button.png icons next to data found on the http://www.musedata.org website, the musical data will be loaded into this online converter from which PostScript, PDF, or PNG images of the music can be generated.

For example, click on the E-button.png icon on the information page for this Bach chorale, then click on the Submit button on the converter page to generate a PDF file of the chorale with the default settings. Then try setting some options, such as using "[(.)(.)(.)(.)]" for the System spine option to prevent barlines from being drawn between staves in the score.

Command-line examples

The simplest use of muse2ps is to send it MuseData stage2 files as standard input, and save standard output from the program into a PostScript file:

    cat bach-wtc1p01.md2 | muse2ps > bach-wtc1p01.ps

You may need to use "./muse2ps" instead of "muse2ps" in the above command if the muse2ps program file is in the current directory, but the current directory is not in your command search path. The PostScript output can then be further processed in an external program. Usually it is more convenient to work with the data as a PDF file. The process of converting PostScript to PDF can be done by many methods. For example, Acrobat Distiller or Acrobat Professional will convert PostScript files into PDF files. There are online converters, such as this one: http://www.ps2pdf.com/convert.htm . And on most linux computers you can convert PostScript into PDF files using the ps2pdf command:

     ps2pdf bach-wtc1p01.ps

This will create the file bach-wtc1p01.pdf (replacing the .ps extension with a .pdf extention automatically when saving the PDF file). If you click on the PDF file link in the previous sentence, you should see the musical notation for J.S. Bach's Well-Tempered Clavier, Book I, prelude 1 in C major.

An alternate method of using ps2pdf to generate a PDF file in a single step in conjunction with muse2ps would be with this command-line construction:

    cat bach-wtc1p01.md2 | muse2ps | ps2pdf - > bach-wtc1p01.pdf

Last system justification

By default muse2ps does not right-justify the last system of the music on the last page of the output (as can be seen in bach-wtc1p01.pdf). If you want to justify the last system, use the =j option as an argument to muse2ps:

    cat bach-wtc1p01.md2 | muse2ps =j | ps2pdf - > bach-wtc1p01-j.pdf

The muse2ps (or more precisely, the internal mskpage component) will possibly adjust line breaks on one or more of the previous systems in the score in order to fill enough music onto the last system, and then stretch or contract the music on the last system to fit the width between margins exactly. The =j option can potentially take significantly more time to process the input data then when it is omitted. The reason for the increased processing time can be seen by comparing bach-wtc1p01.pdf and bach-wtc1p01-j.pdf. In order to right-justify the last system of the music, all systems in the music were recursively re-typeset so that the first system in the music contains only three measures instead of four.

Using multiple options

In the previous examples, the prelude is printed on two pages, with a single orphan system occurring on the second page. One way to force the music to fit onto a single page is to set the from 120 pixels to 0 pixels with the option =t0 and the printable length of the page to 3000 pixels (10 inches) with the option =l3000. When supplying multiple optional settings to muse2ps, there is only one option string which starts with the equals character (=) and is followed by all options with no spaces. Here is an example of using the =t0, =l3000 and =j options at the same time, resulting in a single page of music:

         cat bach-wtc1p01.md2 | muse2ps =jt0l3000 | ps2pdf - > bach-wtc1p01-jt0l3000.pdf

The order of the options in the option string is not important, so for example, "=l3000t0j" would yield the same results as "=jt0l3000".

Music size

The muse2ps program can typeset music in several sizes: 6, 14, 16, 18 and 21. These numbers refer to the pixel count (at 300 DPI) between successive staff lines. For example, here is a zoom-in of music typeset with the size 6 font, where each staff line is one pixel wide, and there are 5 pixels in the gap between lines:

Dmuse-size6.png


The default size that muse2ps will typeset music in is size 14. To use other sizes, use the =z option followed by the size. Here is the example prelude printed in all sizes (with right-justification of the last system using =j also added to the option string):

         cat bach-wtc1p01.md2 | muse2ps =z6j  | ps2pdf - > bach-wtc1p01-z6j.pdf
         cat bach-wtc1p01.md2 | muse2ps =z14j | ps2pdf - > bach-wtc1p01-z14j.pdf
         cat bach-wtc1p01.md2 | muse2ps =z16j | ps2pdf - > bach-wtc1p01-z16j.pdf
         cat bach-wtc1p01.md2 | muse2ps =z18j | ps2pdf - > bach-wtc1p01-z18j.pdf
         cat bach-wtc1p01.md2 | muse2ps =z21j | ps2pdf - > bach-wtc1p01-z21j.pdf

Full-scores are typically printed at size 14 (particularly scores with many parts). Parts for performers are typically printed at size 21. Size 18 has dither on two-pixel wide staff lines.

Input and output files

Options can be given to muse2ps. For example, "z21" is the option which sets the music size to 21 (21 pixels at 300 dpi between staves):

    cat work.md2 | muse2ps =z21 > work.ps

When inputting MPG (Music PaGe) files you must specify the "P" option:

    cat work.mpg | muse2ps =P > work.ps

If you are inputting multiple MPG files (each MPG file represents one page of a score or part), add the letter "P" on a line by itself after the single-page MPG content.


Options

Below is a list of the options which muse2ps understands. Options are given as the first argument to the program, staring with an equals sign (=) and followed by the options in any order, with no spaces between the options. For example, to set the music size to 18 and right-justify the last system on the last page, use the option string =z21j:

   cat file.md2 | muse2ps =z21j > file.ps

In option strings such as "=c<#>", replace <#> with an integer.

=c<#> compression factor: This is measured as a percentage of the default. 100 = no compression.
=d<#> putc Diagnostics and Error Messages.
            bit 0 of #:  ON = print error messages
            bit 1 of #:  ON = print all diagnostics
            bit 2 of #:  ON = print diagnostics from autoset
            bit 3 of #:  ON = print diagnostics from mskpage
            bit 4 of #:  ON = print diagnostics from pspage
            no number = 0x01: print error messages
=F fill pages to the bottom by adding to the intersystem space only. Default is don't change the vertical spacings.
=f fill pages to the bottom by proportionally stretching all spacings. Default is don't change the vertical spacings.
=g<#> grand staff intra-space measured in multiples of ledger lines times 10. The default is 100, which is 10 ledger lines.
=h<#> alter the minimum allowed space between notes. This is measured as a percentage of the default. 100 = no change (100%).
=j right justify the last system. The default is NOT to right justify.
=l<#> length of a page. Distance is measured dots, at 300 dots to the inch. Default is 2740 dots. The default starting height is 120 dots. This will not be lowered, but may be raised to accommodate a longer page.
=m<#> left margin, measured in at 300 dots/inch. The default is 200 dots
=n<#> maximum number of systems on a page. The default is no maximum.
=Q<#> duration which is assigned the minimum distance
              1 = whole notes
             ...   . . .
              8 = eighth notes
             16 = sixteenth notes, etc
=s^string^ custom left-hand spine. If the format is incorrect for any reason, the program will revert to the default. example:
            	=s^[(....)][(..)](.)[({..}..)]^
=t<#> top of page. Default is 120 dots
=v<#,#,#...#> custom spacings. If the format is incorrect for any reason, the program will revert to the default. example:
            =v192,192,192,208,192,192,208,176,176,176,200
=w<#> system width, measured in at 300 dots/inch. The default is 2050 dots
=x defeat all part inclusion suggestions in the data
=y defeat all line control suggestions in the data
=z<#> notesize: choices are 6,14,16,18,21. 14 is the default.
=M include a listing of the MuseData source files in the Trailer section of the file
=P include listings of the page specific i-files, which are the source of the .ps files
=p The source is a concatinated set of page specific i-files (also called .mpg files), not a set of Musedate files.
=G^group-name^ group name to process. The default is "score"
=E /END = /eof

Multi-file input specification

When inputting MuseData stage 2 files, each input file (which contains one part), should be ended by:

/END
/eof

The "/END" is probably optional. After "/END", any commentary text may occur which will be ignored by programs which process MuseData stage 2 files. The "/eof" marker is used specifically by muse2ps to locate the end of the current file (part). The very last line of input to muse2ps should be "//". So the end of the last part file send to muse2ps should look like this:

/END
/eof
//


Zprogs: autoset.z and pspage.z

The sub-directory zprogs contains programs used to generate the file zfun32.c. Most necessary files are in that directory, but perhaps not all of them. These programs are not used directly by muse2ps, but are compiled into zbex executable code within zfun32.c. The muse2ps is essentially a non-interactive version of dmuse (see http://dmuse.ccarh.org). The dmuse program is a text editor which also has a built-in zbex language interpreter. The intepreter portion of dmuse has been extracted for non-interactive use in muse2ps.