allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

MediaWiki扩展:Myriad音乐功能

天下维客,你可以修改的网络知识库

Jump to: navigation, search

本文取自元维基,欢迎共同翻译、整理与大家共享,促进中文wiki发展^_^

Template:If
Type: Parser Extension
Maturity:
MediaWiki: 1.4+
Version:
Last Update: October 2005
Description: Myriad Music plug-in
MediaWiki extensions

Myriad Music plug-in lets you view, play, print, zoom, transpose tunes created with Harmony Assistant and Melody Assistant.

I've created this extension to add musical scores on my wiki.

I know there are some people working on Lilypond for Wikipedia. But Myriad music plug-in works differently.

Consider it works like Macromedia Flash: you have a file, need an external program, need a special tag.

  1. You create your score with Harmony Assistant, or import a MusicXML. Extension is .myr, .mus or .mu3.
  2. Upload it like an image.
  3. Myriad extension writes the object / embed to display the score.

On google we can find a flash extension for Mediawiki but it uses external .swf files, not uploaded! Easy...:-)

On a programming side, it was a bit harder, but really interesting, you can copy it and modify to fit your need for other plug-ins (Flash now done - I didn't tested it -, Scorch...)

Tag:

<myriad>filename.myr|options</myriad>

The filename.myr is an uploaded one, or a link to an external file, on another website.

Contribution: Iubito 20:54, 21 May 2005 (UTC)


目录



What is Harmony Assistant?

Harmony Assistant is a commercial software for computer-assisted music composition and editing, with powerful harmonizing capabilities.

For me, its most unbeatable feature is the quality of the sound, instead of MIDI, Harmony Assistant uses a digital sound bank.

The one packaged in the downloadable plug-in is very tiny and lowest quality: about 600 KB. The biggest and best one, is sold on CD-Rom and called "Gold". A medium quality 6MB sound bank is downloadable at http://www.myriad-online.com/en/resources/extbase.htm

Harmony Assistant imports MusicXML. Melody Assistant is a shareware, with less features.

Requisits

Requires:

  • Myriad Music plug-in installed on users' computers.

Platforms:

  • Windows 95 to XP
  • Mac OS8 to OSX
  • seems to work on Linux through Wine (tested by some users)

Browsers: mostly all

  • IE 4+
  • Netscape 4+
  • Mozilla
  • Opera
  • K-Meleon
  • ICab
  • Safari
  • Camino
  • ...

Install instructions

  1. Include it at the end of your LocalSettings.php:
    include("extensions/myriad.php");
add .myr, .mus and .mu3 in the extension list:
$wgFileExtensions = array('png','gif',...,'myr','mus','mu3');

If you want to translate the 2 messages in your language, go to http://yoursite/wiki/index.php?title=MediaWiki:myriadbeforeplugin and ...?title=MediaWiki:myriadafterplugin. You can also change the default values for height and width in MediaWiki namespace or in the myriad.php file.

Sample

For a complete list of parameters between tags, see the Myriad Music Plug-In Web Designer manual examples:

<myriad>file.myr|width=210|height=300|autoplay=on</myriad>
<myriad><a href="http://www.anothersite.com/accordion.myr" class="external free" target="_blank" title="http://www.anothersite.com/accordion.myr" rel="nofollow">http://www.anothersite.com/accordion.myr</a></myriad>

Produces: <a href="/index.php?title=Special:Upload&wpDestFile=Myriadextension.png" class="new" title="Image:Myriadextension.png">Image:Myriadextension.png</a> This screen capture show a score in the plug-in, with one of the sentences I've translated in French in the Mediawiki namespace.

For a simple melody, or a 2-3 staves scores (piano, organ) you can zoom. The best parameter, for a 800x600 screen is:

<myriad>file.myr|width=550|height=400|zoomvalue=220</myriad>

which produces: <a href="/index.php?title=Special:Upload&wpDestFile=Myriadextension2.png" class="new" title="Image:Myriadextension2.png">Image:Myriadextension2.png</a> Template:Br

PHP code (copy from here!)

Copy/paste into your editor, save it to extentions/myriad.php, and then upload it to your site.

<?php
# Myriad Music Plug-in WikiMedia extension
# 
# http://meta.wikimedia.org/w/index.php?title=Myriad
# 
# Tag:
#   <myriad>uploaded filename.myr or .mus or .mu3|options</myriad>
# Requires:
#   Myriad Music plug-in installed on users' computers.
# Platforms:
#   Windows 95 to XP, Mac OS8 to OSX, maybe Linux through Wine (not tested)
# Browsers:
#   mostly all: IE 4+, Netscape 4+, Mozilla, Opera, K-Meleon, ICab, Safari, Camino...
# Contribution by:
#   Iubito
# 
# Myriad Music plug-in display, allow to play, print, zoom, transpose
# tunes created with Harmony Assistant and Melody Assistant.
# 
# Harmony Assistant is a software for computer-assisted music composition
# and editing, with powerful harmonizing capabilities.
# For me, its most unbeatable feature is the quality of the sound, instead
# of MIDI, Harmony Assistant uses a numeric sound bank.
# The one packaged in the downloadable plug-in is very tiny: about 600 KB.
# The biggest one, the best quality, is sold on CD-Rom and called "Gold".
# A medium quality 6MB sound bank is downloadable at 
# http://www.myriad-online.com/en/resources/extbase.htm
# Harmony Assistant imports MusicXML.
# Melody Assistant is a shareware, with less features.
# 
# To activate the extension:
# - include it at the end of your LocalSettings.php: include("extensions/myriad.php");
# - add .myr, .mus and .mu3 in the extension list:
#   $wgFileExtensions = array('png','gif',...,'myr','mus','mu3');
# 
# If you want to translate the 2 messages in your language, go to
# http://yoursite/wiki/index.php?title=MediaWiki:myriadbeforeplugin
# and http://yoursite/wiki/index.php?title=MediaWiki:myriadafterplugin
# You can also change the default values for height and width in MediaWiki
# namespace or in this file.
# 
# For a complete list of parameters between tags, see the
# "Myriad Music Plug-In Web Designer manual"
# at http://www.myriad-online.com/en/docs/plugdoc.htm
# e.g. <myriad>file.myr|autoplay=on|look=moon</myriad>
# 
# Enjoy!
# 
# For those who want to create extension, you may be interested to look how
# I manage uploaded file (throught Image object), and also how to store default
# messages in the MessageCache (addMessage), and get them from the MediaWiki
# namespace or the MessageCache (wfMsg).

$wgExtensionFunctions[] = 'wfMyriad';

function wfMyriad() {
	global $wgParser, $wgMessageCache;
	# register the extension with the WikiText parser
	# the first parameter is the name of the new tag. In this case it defines the tag <myriad> ... </myriad>
	# the second parameter is the callback function for processing the text between the tags
	$wgParser->setHook('myriad', 'renderMyriad');
	
	# Default text before and after the plug-in, you can translate them in MediaWiki namespace.
	$wgMessageCache->addMessage('myriadbeforeplugin',
		'To view, play and print this musical score, you need the <a href="'
		.'http://www.myriad-online.com/en/products/mmplugin.htm'
		.'" target="_blank">Myriad music plug-in</a>.');
	$wgMessageCache->addMessage('myriadafterplugin',
		'For a better sound quality, you can <a href="'
		.'http://www.myriad-online.com/en/resources/extbase.htm'
		.'" target="_blank">download <em>GMSEBase</em> sound base</a>.');
	# Default plug-in height and width, OK for a 800x600 screen
	$wgMessageCache->addMessage('myriadpluginheight', '500');
	$wgMessageCache->addMessage('myriadpluginwidth', '325');
}

# The callback function for converting the input text to HTML output
function renderMyriad($input) {
	//$input = "filename.myr|param=xx|param2=yy|..."
	$arr = explode('|', trim($input));
	$img = new Image($arr[0]);
	
	//The parameters for object and embed
	$params = Array();
	# File uploaded or external link?
	if (!$img->exists())
		$params['src'] = $arr[0];
	else
		$params['src'] = $img->getURL();
	unset($arr[0], $img);
	
	//Don't change this
	$params['type'] = 'application/x-myriad-music';
	$params['pluginspage'] = 'http://www.myriad-online.com/cgi-bin/mmplug.pl';
	//Default height & width
	$params['height'] = wfMsg('myriadpluginheight');
	$params['width'] = wfMsg('myriadpluginwidth');
	//Other defaults, less important
	$params['antialias'] = 'high';
	$params['soundbaselogo'] = 'off';
	$params['desktopcolor'] = 'E7E3E7';
	
	foreach($arr as $oneparam) {
		$pos = strpos($oneparam, '=');
		if ($pos!== false) {
			$left = trim(substr($oneparam, 0, $pos));
			$right = trim(substr($oneparam, $pos+1));
			$params[$left] = $right;
		}
	}
	unset($arr);
	
	//class="toctoggle" is just a hack to print on screen but not on printer;-)
	$output = '<div class="toctoggle" style="text-align:center; font-size:84%;">'
			. wfMsg('myriadbeforeplugin')
			. '<br />'
			. '<object classid="CLSID:07000E2B-6AAD-497D-8E5B-5976560AD429" border="0" '
			. 'height="'.$params['height'].'" width="'.$params['width'].'">';
	foreach($params as $key=>$val) {
		$output .= '<param name="'.$key.'" value="'.$val.'" />';
	}
	$output .='<embed ';
	foreach($params as $key=>$val) {
		$output .= ' '.$key.'="'.$val.'"';
	}
	$output .='></embed></object><br />'
			. wfMsg('myriadafterplugin')
			. '</div>';
	
	return $output;
}
?>

原文参见: Myriad

Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币