Extract information about playback function

• Oct 9, 2014 - 17:01

Hello,

I'm new in Musescore plugin development, but I'm trying to search the way to extract information (like the start and the end of a note) when the function playback of the score is running.

Is it possible? How can I extract this information?

Thank you very much!


Comments

In reply to by [DELETED] 5

Thanks

What I'm trying to do is obtain the start time and the duration of the current note in a score that is being plaid in Musescore.

I want this information because I'm trying to compare it with a recorded audio of a musician's playing the score.

I think that the simple way to do this is start to record when the note start and end the recording when the note ends. And then my system will determine the pitch of the recording and will compare it with the pitch of the note's score.

Hope is clearer now and many thanks for your help

In reply to by anna.

A plugin can't run in "real time" with the score playback - it will run either before or after the playback. Even if it ran at the same time, it wouldn't have access to any information about what is "now playing" - there is no real time support in the plugin framework. So I don't think what you are describing can be done - at least, not the way you are describing it. It *might* be possible to do a pre-pass through the score and just calculate the start & end times of all notes before playback even starts, then output that information somehow. But I don't think there is any good access to that sort of information in the the plugin framework currently. Almost definitely not in 1.3, probably not in 2.0 Beta or Nightly - but it might not be too late to get some sort of information like that added for 2.0.

In reply to by Marc Sabatella

Hello again,

I'm doing my degree's final project and for the moment I have programmed a system with two inputs: a xml score and a audio in wav. The system compares both inputs and tells if they are equals or not in terms of pitch.

But now I want to find the way to visualize the score and a cursor to tracking the notes in the actual tempo at the same time the system is recording a musician's interpretation of the score.
I'm thinking that the best way to do this is with a plugin in Musescore (for the moment I only have written a plugin code to execute my program when you start the plugin), but maybe not...

For this reason I want to know if there's the possibility to know (inside a plugin) when the user click the button "start or stop playback" and then the system will be able to know the moment to start or stop recording.

Please excuse my poor English and thank you for your attention!

In reply to by anna.

I want to know if there's the possibility to know (inside a plugin) when the user click the button "start or stop playback"
For the moment, plugins are not running in parallel of MuseScore. In short, a plugin is executed when the user clicks a menu item. The plugin does something (it can include displaying a dialog), and quit. When the plugin is doing something, I don't think it can get events.

"tracking the notes in the actual tempo"
Is that the tempo of the performance?
If yes, you might be interested in the OSC interface of MuseScore. It's currently not documented. But in short, MuseScore includes an OSC server that you can activate in Preferences -> General (then restart). MuseScore is now listening to OSC commands. You can start the playback, stop it. You can also probably move a cursor on the score by specifying a tick. You can basically create a remote control for MuseScore.
The available commands https://github.com/musescore/MuseScore/blob/master/mscore/osc.cpp

If you need more help with the OSC interface, feel free to ping me on IRC #musescore on freenode.net

In reply to by [DELETED] 5

Thank you for your help!

Now I can open and close files in Musescore with OSC commands, but when I send "/play" command it does nothing.

Also, when I send <<"/tempo" << 2 << , Musescore changes tempo to 360, for example... which is the relation between this number sent and the tempo in bpm?

Thank you very much!

In reply to by anna.

/tempo sets the relative tempo of the piece. 2 should double the current tempo of the piece. If the piece has a "quarter note = 120" at the start and you send /tempo 2, then the tempo should be 240. You don't see this?

To play you need to call "/actions/play" not "/play".

In reply to by [DELETED] 5

Hello again!

I have searched the way to change the tempo, not to set the relative tempo, but I don't find it.

And when I call "/actions/tempo" Musescore write the text "quarter=80" in the current cursor. Is possible to change the number? How?

Thank you!

In reply to by anna.

It's not possible to override the tempo of the full song with a given BPM. The song might contains several tempo changes already, so the only thing you can do is change the relative tempo to make the song play x time faster or slower. If there is a tempo change in the song, MuseScore will slow down or accelerate but keep being x time faster/slower.

The only way to override the tempo for the full song would be to go through all the notes, delete any tempo text and add a tempo at the start. This is currently not possible via OSC.

Can you explain exactly what you want to do and why you want to change the tempo?

In reply to by [DELETED] 5

I'm creating a graphic interface to communicate my program with MuseScore, so... I want to read the tempo because I want to simplify my GUI.
Now the user has to change the tempo in the PlayPanel in MuseScore and in my GUI (I need the tempo for calculations in my system), and the two tempos must be the same (if the tempos aren't the same my system doesn't work well).
So, I want to read the tempo of the PlayPanel in Musescore to simplify my system.

Is it possible? How?

Thank you!

In reply to by anna.

A score doesn't necessarily have a single tempo - many will change tempo over the course of the piece. Tempos are specified using tempo text - that is where tempo info actually lives. The play panel is just a UI for specifying an overall scaling to be applied to all tempo texts in the score (eg, play the entire score at 75% of the actual marked tempos).

In reply to by anna.

I know nothing about how the OSC stuff works, so I can't tell you if there is a way to read it. I can say that the default value is 100%. 100% of what? Well, 100% of whatever the actual tempo(s) for the piece is(are). Depending on the context of what you are trying to do, you could just assume the user won't be using the play panel at all (you could specifically instruct them not to) and only set the tempo scaling factor using your application. So it starts at 100%, and you could just track the changes you make via OSC from there.

In reply to by anna.

You probably don't need a plugin for this. You can run MuseScore from the command line like this:


mscore file.mscz -o file.spos

It will output an xml file containing the position of any segment in a score both time wise and graphic wise.

How do you need the pitch? you extract it from the MuseScore audio rendering? or you need an actual MIDI pitch value?

You could obtain the tick length of notes or write a Plugin (I suppose; haven't actually got to grips with MuseScores Qt commands and functions yet) that read out the start and end ticks or you could export to MusicXML and analyse the raw data in the file but can I ask how you are measuring the real musician's notes' durations? Presumably if you have some way of measuring individual notes played by a musician you could just have MuseScore play back a score and use the same measurement method?

In reply to by underquark

For the moment I'm measuring the pitch and duration of the notes of the musician's interpretation with my system. My system throws the pitch every X seconds.
I had thought about using the same measurement method with the play back of the score, but I obtained a very random output (meanwhile my system works perfectly with my music instrument), so I think I can't use this method.

Now I'm working in analyse the xml file to obtain pitch and duration information, I hope it works!

Excuse my bad english and thank you very much!

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