[CLAM] Question on the Midi file reader

Vincent SHAO vince.shao at gmail.com
Mon Mar 9 09:11:45 PDT 2009


Hi, all:
Sorry to bother again. I encountered a problem that i have no clue and need
your help.

I am intending to extract the melody information from a midi file, I wrote
the following codes:

     *MIDIFileIOConfig midiFConfig;
    midiFConfig.SetFileName(filename);
    MIDIFileReader midiFReader(midiFConfig);
    MIDISong midiSong;
    midiFReader.Do(midiSong);
    Array<MIDITrack> tracks = midiSong.GetTracks();
    int tracksNumber = midiSong.GetNumberOfTracks();
    cout<<"Track number is : "<<tracksNumber<<endl;
    for(int i =0; i< tracksNumber; i++){
        MIDIMelody midiMelody = tracks[i].GetTrackMelody();
        XMLStorage x;
        x.UseIndentation(true);
        x.Dump(midiMelody,"Analyzed_MIDIMelody",filename+(char)i);
    }*

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:

*Expected a header chunk.
terminate called after throwing an instance of 'MIDI::Reader::Error'
Aborted*

Did i miss something, like i have to close the midi file reader? Can't
locate the bug and need your help.

A huge thank to all of you.

Cheers

Vincent
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clam-project.org/pipermail/clam-users-clam-project.org/attachments/20090310/5924eec9/attachment-0001.html>


More information about the clam-users mailing list