Skip to content

Instantly share code, notes, and snippets.

@lasconic
Created May 17, 2011 05:17
Show Gist options
  • Save lasconic/975991 to your computer and use it in GitHub Desktop.
Save lasconic/975991 to your computer and use it in GitHub Desktop.
Call an external command line tool - Example with lilypond
//---------------------------------------------------------
// init
// this function will be called on startup of mscore
//---------------------------------------------------------
function init()
{
}
//-------------------------------------------------------------------
// run
// this function will be called when activating the
// plugin menu entry
//-------------------------------------------------------------------
function run()
{
// temp folder for user C:\Users\<USERNAME>\AppData\Local\Temp on windows
var path = QDir.tempPath(); //
var file = path + "/score.ly";
curScore.save(file, "ly");
//See http://doc.qt.nokia.com/latest/qprocess.html
var lilypond = new QProcess();
var args = new Array();
args[0]= "-o";
args[1]= path;
args[2]= file;
// if you want to log output
//lilypond.setStandardOutputFile("stdout.txt");
//lilypond.setStandardErrorFile("stderr.txt");
lilypond.start("lilypond", args );
lilypond.waitForStarted();
lilypond.waitForFinished();
}
//---------------------------------------------------------
// menu: defines were the function will be placed
// in the MuseScore menu structure
//---------------------------------------------------------
var mscorePlugin = {
menu: 'Plugins.Lilypond process',
init: init,
run: run
};
mscorePlugin;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment