Sorry, I've known where the bug is. When i write xml file, the newly generated file overwrite the midi file, thus when i run it the second, it pops back that error. <br><br>Thanks. ;-)<br clear="all"><br>Cheers<br><br>
Vincent<br><br>
<br><br><div class="gmail_quote">On Tue, Mar 10, 2009 at 12:11 AM, Vincent SHAO <span dir="ltr"><<a href="mailto:vince.shao@gmail.com">vince.shao@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi, all:<br>Sorry to bother again. I encountered a problem that i have no clue and need your help.<br><br>I am intending to extract the melody information from a midi file, I wrote the following codes:<br><br> <i><b>MIDIFileIOConfig midiFConfig;<br>
midiFConfig.SetFileName(filename);<br> MIDIFileReader midiFReader(midiFConfig);<br> MIDISong midiSong;<br> midiFReader.Do(midiSong);<br> Array<MIDITrack> tracks = midiSong.GetTracks();<br> int tracksNumber = midiSong.GetNumberOfTracks();<br>
cout<<"Track number is : "<<tracksNumber<<endl;<br> for(int i =0; i< tracksNumber; i++){<br> MIDIMelody midiMelody = tracks[i].GetTrackMelody();<br> XMLStorage x;<br> x.UseIndentation(true);<br>
x.Dump(midiMelody,"Analyzed_MIDIMelody",filename+(char)i);<br> }</b></i><br><br>The code is working all right for the first time and can generate the melody file as i wanted, yet it won't work again, i mean i can't run this code again. When i run this it pops back the error:<br>
<br><b>Expected a header chunk.<br>terminate called after throwing an instance of 'MIDI::Reader::Error'<br>Aborted</b><br clear="all"><br>Did i miss something, like i have to close the midi file reader? Can't locate the bug and need your help. <br>
<br>A huge thank to all of you. <br><br>Cheers<br><font color="#888888"><br>Vincent<br><br>
</font></blockquote></div><br>