Extract information about playback function
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
Can you explain what you are trying to do more in details?
In reply to Can you explain what you are 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 Obtain start and duration of a note 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 A plugin can't run in "real by Marc Sabatella
Thank you very much for your reply!
In reply to A plugin can't run in "real 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 Button playback 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 I want to know if there's the 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 Thank you for your help! Now 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 /tempo sets the relative by [DELETED] 5
Oh! Perfect! Thank you for all!!! :)
In reply to /tempo sets the relative 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 Tempo by anna.
Just double click and change the number. By default the 'follows text' is enabled, if not check in Inspector
In reply to Just double click and change by Jojo-Schmitz
Ups! No, I wanted to say how to change tempo with an OSC command.
Now I'm trying to do it with "/actions/tempo", but this command only changes tempo to "quarter=80"...
And the command "/tempo" only multiplies the tempo with an integer.
In reply to Ups! No, I wanted to say how 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 It's not possible to override by [DELETED] 5
Ok! Thank you!
In reply to It's not possible to override 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 I'm creating a graphic 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 A score doesn't necessarily by Marc Sabatella
Thank you for your explanation!
Well, I want to read this overall scaling of the tempo introduced in the play planel.
Is it possible to read it?
There is a OSC command "/tempo" but only changes this overall scaling multiplying it with an integer...
In reply to Thank you for your 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 Obtain start and duration of a note 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?
In reply to You probably don't need a by [DELETED] 5
Thanks for this command line, but I don't understand the output .spos.
It's only a graphic information?
I'm thinking about extracting the pitch and time information from the xml file directly, but thank you for this information!
In reply to Thanks! by anna.
The first part of the file is graphical. The second part starting with
events
is about timing.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 You could obtain the tick 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!