Midi to XML Parse (not really sure if it is Standard Music XML)

Hello!
I used to have the idea of importing a midi file and using it to create animations and I didn’t manage to make it like I was adviced to here http://forum.openframeworks.cc/t/importing-midi-file-to-be-used-as-visual-or-math-information/7381/0
As it turns out I had the idea of converting and parsing a midi file into an XML. I think it worked since I just need to make visual stuff happen (no midi hardware, in or out functionality required).

But I’d like to know a bit more about how I can fill a few vectors from information inside an XML file using ofxXmlSettings. There are two parts that have me confused:
1.-How I can get a string from an XML file (I’ve had to use numbers to make boolean variables).
2.-How can I parse something like this into a few variables:
[tt][/tt]
or this:
[tt][/tt]

What also confuses me is that these examples don’t seem to look like the XML tags explained in xmlSettingsExample so I read a bit of an XML tutorial and I think they are “XML Element Attributes” but I have no idea how to use them in openFrameworks or get them inside some other variables.
Thanks for your time and patience :stuck_out_tongue:

[tt]
<Track_0>

0
SongName


0



0



0

</Track_0>

<Track_1>

0
Instr.


76800



76800



76858


</Track_1>[/tt]

Bump… :slight_smile:
I haven’t solved this so if anyone can point me to the appropriate information I’d be very thankfull. =D

at least some of your questions I can answer - the getters/setters that exist for values also exist for attributes, so you can also get attributes via ofxXmlSettings. Take a look at ofxXmlSettings.h to see what’s there.

Thanks bilderbuchi
It’s mostly working. I’ve been able to take string values out of XML Attributes by reading what you told me to, but when I try to read int values CodeBlocks says this:
[tt]error: request for member ‘getAttribute’ in ‘((testApp*)this)->testApp::SetTempoValue’, which is of non-class type ‘int’[/tt]

tesApp.h declares SetTempoValue as an int and the .cpp has the following code for getting the attribute (inside a few other tags for which I have already used pushTag() and popTag() accordingly (I checked).

  
SetTempoValue.getAttribute("SetTempo","Value",0,1);  

I also tried:

  
SetTempoValue.getAttribute("SetTempo","Value",0);  

And this is the tag that it should be reading and there are no other tags with the same name:
[tt][/tt]

if SetTempoValue is of type int, as you write, it does not have a member function getAttribute (because it’s just an int, not a class!), that’s what the compiler complains about here. you are confusing some things. you’d have to have something like
SetTempoValue = xmlsettingsobject.getAttribute(“SetTempo”,“Value”,0);
Look at the xml example in openFrameworks/apps/addonsExamples/xmlSettingsExample.
Also, mind that SetTempoValue is a bad name for a variable, it sounds like a setter function. tempoValue would be better, for example.

Thank you bilderbuchi. I was a long way off course on this topic.
I’ve never had the compiler give me such a message so I didn’t know where to start fixing this. I will research further on the subject.
Thanks again! =D

Edit->
I read my own code just now with what you said in mind and of course the problem was the code I had written. I had even used the correct code in the other part of the testApp that worked fine. So thank you for your patience bilderbuchi. I fixed the mistake and everything is working perfectly… all 139.539 events have been imported correctly from the parsed Music XML. :stuck_out_tongue:

no problem, that’s what we’re all here for. :slight_smile:
so, what are you gonna do with that newfound richness of data?

:stuck_out_tongue:
I’ve had many ideas for years and only now do I have the opportunity of implementing them. One of them I can remember has to do with music theory analysis using visualizations. Now that I think about it this opens up a world of possibilities! I can surely make an openF application that does classical chord progressions for me (that would make me a lazy composer but with style). All of this will take a long time to finish. =D

I also write music inside Cubase 6 and since it can export to Music XML I wanted to make something that would allow me to visualize the piano roll in a more “graphically rich way”. The idea of not using MIDI or OSC was intentional.

Now… I am thinking of not parsing any XML in order to make my code adjust to standard Music XML, so I’m left with a few questions that involve the following code:
[tt]

0
Chords


0

[/tt]

1.-In color green. MIDI XML puts track information inside a Tag WITH Attribute. How can I pushTag() that? I can’t seem to find that in the xmlSettingsExample. It also closes the Tag without the Attribute, is this standard?
2.-In color red. MIDI XML has an end-tag that describes the end of a track. I’m reading it is a child element. Should I worry about this? Would reading an XML with a tag such as this block the application using popTag() and crash it? Does ofxXmlSettings have any functionality regarding this that you can remember? I couldn’t find one but I don’t even know what I’m looking for.

Thanks again :stuck_out_tongue:

Edit->
I should mention that I’m using XML to import midi notes with absolute values. The type of Music XML exported from Cubase 6 is mostly for written music and has different structure and tags.