Mixer access for plugin development

• Apr 19, 2015 - 11:01

Hello!

I would like to use musescore to create mp3 files for choir training from a score with multiple voices (Soprano, Alto, Tenor, Bass).

Using plugins I would love to achive to export different versions for training purposes.
E.g.
* export each voice individualy
* mute a single voice, but export remaining 3
* Have a voice at full volume but decrease all other to 30%

This all could be achived by accessing the mixer prior to export. But as far as I know there is no access to the mixer. Is this true? Or does a workaround exist (maybe even with a different software)?


Comments

I don't think the mixer is what you would want - it doesn't give control voice by voice, only staff by staff. Instead, you should probably set the playback properties of the notes - play and veloOffset. No idea if this actually works, but it's how you'd need to do it outside the plugin framework, so it's the natural choice for a plugin as well

In reply to by Isaac Weiss

Yes, this is correct. Everything on it's own stave.

So far I was only able to export the whole score using:
writeScore(curScore , "D:/export.mp3", "mp3" );

This took me a while because at first it did not work until the latest musescore update.

But it takes the current mixer settings into account.
E.g. If I mute tenor and alto they are also not part of the export.
So I need to reset those settings (manually) prior to export.

As far as I understood play & veloOffset I do need to define a cursor to walk through the score and mute each note separately. Afterwards export and then reset everything (because otherwise the notes could be accidently saved as muted).

Currently I try to understand how to access each stave, one after the other, and access all notes.

Hello,

thank you all for your feedback. It helped me a lot.
It took me some time to understand some concepts of museScore and plugin development.
(and how to read the documentation)

I almost finished a plugin to set note velocity but then I found out about museScore parts settings.
These allow access to some parts of the mixer, e.g. volume and mute.
see:
curScore.parts[0].volume = 100
curScore.parts[0].mute = true

Here is the plugin I do currently use for reference:

{syntaxhighlighter title="plugin"}
import QtQuick 2.0
import MuseScore 1.0

MuseScore {
version: "1.0"
description: "Exports score as mp3 as well as every Choir voice twice as loud as other voices"
menuPath: "Plugins.Choir Rehearsal Export"

// Set all parts to volume specified by vol
// disable mute if enabled.
function mixerVolAll(vol)
{
var part
for (var partIdx = 0; partIdx < curScore.parts.length; partIdx++)
{
part = curScore.parts[partIdx];
//console.log ( "part partName/shortName: " + part.partName + "/" + part.shortName);
part.volume = vol
part.mute = false
}
}

// not everything needs to be exported.
// use export only for Choir voiced but not for Piano
// it is assumed the piano is always the last part
function getMaxChoirPart()
{
var maxPart = 0
var part
for (var partIdx = 0; partIdx < curScore.parts.length; partIdx++)
{
part = curScore.parts[partIdx];
if ("S." == part.shortName) maxPart++;
if ("Mzs." == part.shortName) maxPart++;
if ("A." == part.shortName) maxPart++;
if ("T." == part.shortName) maxPart++;
if ("B." == part.shortName) maxPart++;
}
return maxPart
}

// set the volume of a certain part to "vol"
function mixerVolPart(vol, partIdx)
{
var part
part = curScore.parts[partIdx];
// console.log ( "part partName/shortName: " + part.partName + "/" + part.shortName);
part.volume = vol
part.mute = false
}

// Get a Name/Volume pattern to be used in the export filename
// e.g. S.50_A.100_T.50_B.50
function namesVol( maxPart )
{
var part
var retName
retName = ""
for (var partIdx = 0; partIdx < maxPart ; partIdx++)
{
part = curScore.parts[partIdx];
retName += "_" + part.shortName + part.volume
}

return retName
}

onRun:
{
var expName // filename for export

if (typeof curScore == 'undefined') { Qt.quit()}
console.log("parts: " + curScore.parts.length);

// set Volume of all parts to 100
mixerVolAll(100)

// export score as mp3 with all voices at normal
expName = "D:/" + curScore.name
expName += ".mp3"
console.log ( "createfile: " + expName);
writeScore(curScore , expName, "mp3" )

// get number of all parts without piano
// for every choir voice (eq. part) set all others to volume 50
var maxPart = getMaxChoirPart()
for (var partIdx = 0; partIdx < maxPart; partIdx++)
{
// all others to 50
mixerVolAll(50)
// single choir voice to 100
mixerVolPart(100,partIdx)

expName = "D:/" + curScore.name
expName += namesVol(maxPart) + ".mp3"
console.log ( "createfile: " + expName);
writeScore(curScore , expName, "mp3" )
}

// when finished set all back to normal
mixerVolAll(100)
Qt.quit()
} // on run
}
{/syntaxhighlighter}

In reply to by LennartRipke

Hi,
I have been doing this in a manual process so far and that is already a pretty awesome plugin I like it quite a bit! I've been looking quite a while for something like this.
What I would like to add to this plugin is change the instrument (sound) for the highlighted voice so it is more easy to follow. Has anyone out there an idea which how to access the instrument (sound) on the mixer so I can change this within this plugin?

Any suggestion would be much appreciated.

Cheers

chris

In reply to by LennartRipke

Thanks to LennartRipke's help, I was able to tweak the code so far, to export my neccessary files.

Since the api documentation says that the midiProgram property is read only, I have currently no way to change it to an other value.
- Are there any other possibilities to switch to defferent midiProgram?
- Is there a reason, why the property must be read only? I share the idea to highlight a certain voice.

In the current version (3.3) the properties for part.volume and part.mute are also gone. Is there an replacement for them?

Do you still have an unanswered question? Please log in first to post your question.