|
Cookbook /
Music NotationSummary: Display music scores from various ascii notations (abc, abctab, asciitab, tab)
Version: 1.3 2008-03-07
Prerequisites: abcm2ps|abctab2ps, [tab2abc], [ascii2abctab], [abc2midi], [timidity], [lame|toolame], [flac], [oggenc], ghostscript, ppmtogif, pmcrop, content.php, markupsamepass.php
Status: Stable
Maintainer: Martin Fick
Categories: Markup
Questions answered by this recipe
DescriptionThis recipe converts music files in various ascii notations into other music notations and PostScript scores, gif images, and midi/wav/mp2/mp3/flac/vorbis files. Once configured (see below), this script enables markups of the form:
The gif image will display the notation as a musical score, and links underneath it will open the associated other available format files. See this recipe in action here. The list of output types is configurable via the types, list and embed options which can be specified with all of the above directives. The formats for these options are: types=[+|-]type,... list=default|all|none embed=true|false The types= and list= options allow you to customize which of the available type-links to create links to or to embed. The list= determines what types will be available before the types= option is processed. The default list for every input type in this recipe is '-ppm,-ps' (every type except for ppm and ps), which means that the following types are likely to actually be output:
This list can then be added to or deleted from with the types= option. If a type in the types= option does not contain a '+' or a '-', the types list will be assumed to be an absolute list and the list= option will be ignored entirely. The embed=false option can be used to disable image embedding in favor of a link. If you want to modify the default list to be something other than '-ppm,-ps' follow the instructions below in the configuration section. Configuration:Download music.phpΔ, content.phpΔ and markupsamepass.phpΔ, copy them to cookbook directory and install them by adding to config.php: include("cookbook/content.php");
include("cookbook/music.php");
Depending on the outputs you wish to produce, your system will also need some or all of the following external commands (executable programs):
It is OK if you do no have all of the above executables on your system, the output for the particular missing converter will simply be omitted. On the other hand, if you have some of these executables, but do not want to support a specific converter with this recipe, simply comment the converter registration out in the music.php file! If any of the converters are not in your web server's path you will need to edit the music.php script with the appropriate path. For example the ascii2abctab converter is defined like this: ContentRegFSConverter("asciitab", "abctab", 'ascii2abctab < ${i} > ${o}');
You could add an absolute path to this converter like this: ContentRegFSConverter("asciitab", "abctab", '/usr/local/bin/ascii2abctab < ${i} > ${o}');
The default path for temporary and cache files is set to /var/tmp/content. If you would like to change this, do so with the $ContentCfgCacheDir variable in your config.php. If you want to secure your converters from data entered by non authorized authors, you can set a preview key with $ContentCfgPreviewKey. Depending on which converters you use and the size of some of your songs, you may need to boost several php parameters to prevent php timeouts or out-of-memory errors. Some specific php parameters of interest defined in your php.ini are: max_execution_time = 30 ; Maximum execution time of each script, in seconds memory_limit = 8M ; Maximum amount of memory a script may consume (8MB) If you do not like the default list of output types, you may override it easily in your config.php by setting the $MUSIC_LIST variable to the list of types that you want by default. For example, if you want wav and mp3 to not be output by default, set $MUSIC_LIST='-ppm,-ps,-wav,-mp3'; # all types except for ppm, ps, wav, and mp3 and then when you want to add them to certain songs, simply use types=+wav,+mp3, i.e.: (:abcm types=+wav,+mp3:) Be sure to assign this variable in your config.php script before calling the music recipe! NotesRecipe sample pages. This recipe uses the Content recipe. As such, it is very easy to add support for new formats if either of the following are already available to handle the format: some php code or an executable. Since I do not own any windows machines, this recipe does not support that OS yet. If someone would like it to work on windows, I will gladly help them get it to work if they are willing to test it. As a prerequisite, make sure that any converters needed are supported on windows. Please feel free to post any success/failure attempts to port this to windows here and to the mailing list! This recipe is a complete rewrite of Pm's AbcMusic recipe using the Content recipe. It supports two new formats, asciitab and tab, additionally it supports multi-page outputs and wav/mp3/flac/vorbis generation. Release Notes
Comments
See Also
Contributors
ChrootsThe recipe can be upgraded to use chroots for almost every operation. Using a chroot can greatly enhance the
isolation of your converters from the rest of your system making the recipe even more secure. This upgrade requires the SchrootConverter recipe which requires the scrhoot utility, along with individual chroots for each of your converters that you wish to isolate. To make things easier, here are some ready made chroot tar files for many of the converters in this recipe. While these are mostly debian linux i386 based chroot converters, they will probably work on any linux ABI i386 compatible system since they are fully self contained user spaces with their own libraries. These will not cause any conflicts with any libraries on your system.
The easiest way to install these is to download them to a directory such as
The |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||