Update of /cvsroot/audacity/audacity-src/src/import
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv18786/src/import

Modified Files:
        ImportMIDI.cpp 
Log Message:
Replaced allegro with portsmf as part of removing the EXPERIMENTAL_NOTE_TRACK 
flag and replacing it with USE_MIDI.  Changed ImportMIDI significantly to work 
with the new library.  Although allegro is no longer used when building 
Audacity, it has not yet been removed from CVS and will be removed once it is 
determined that portsmf causes no (additional) problems for developers.  Built 
and tested on Windows XP, untested on OSX and Linux.

Index: ImportMIDI.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/import/ImportMIDI.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ImportMIDI.cpp      7 Jul 2008 18:13:48 -0000       1.11
+++ ImportMIDI.cpp      11 Jul 2008 15:39:25 -0000      1.12
@@ -19,73 +19,42 @@
 
 #include "allegro.h"
 #include "strparse.h"
-#include "allegrord.h"
 #include "mfmidi.h"
-#include "allegrosmfrd.h"
 
 bool ImportMIDI(wxString fName, NoteTrack * dest)
 {
-   wxFFile mf(fName, wxT("rb"));
-
-   if (!mf.IsOpened()) {
-      wxMessageBox( _("Could not open file: ") + fName);
+   if (fName.Length() <= 4){
+      wxMessageBox( _("Could not open file ") + fName + ": Filename too 
short.");
       return false;
    }
 
-   if (fName.Length() > 4 &&
-       !fName.Right(4).CmpNoCase(wxT(".gro"))) {
-
-      // Import Allegro file (Roger Dannenberg)
+   bool is_midi = false;
+   if (fName.Right(4).CmpNoCase(wxT(".mid")) == 0)
+      is_midi = true;
+   else if(fName.Right(4).CmpNoCase(wxT(".gro")) != 0) {
+      wxMessageBox( _("Could not open file ") + fName + ": Incorrect 
filetype.");
+      return false;
+   }
 
-      Alg_reader reader( mf.fp(), new Alg_seq );
-      reader.parse();
-      mf.Close();
-      
-      if(reader.error_flag)
-      {
-         // TODO: is there a better way to see if an error occurred?
-         wxMessageBox(_("Error parsing Allegro file."));
-         return false;
-      }
-      
-      // this is probably not necessary, and would be cleaner if reader 
returned
-      // a Seq_ptr:
-      /*
-      reader.seq.notes.events = NULL;
-      reader.seq.notes.len = 0;
-      reader.seq.map.beats.beats = NULL;
-      reader.seq.map.beats.len = 0;
-      reader.seq.time_sig.time_sigs = NULL;
-      reader.seq.time_sig.len = 0;
-      */
-      dest->SetSequence( reader.seq );
+   wxFFile mf(fName, wxT("rb"));
+   if (!mf.IsOpened()) {
+      wxMessageBox( _("Could not open file ") + fName + ".");
+      return false;
    }
-   else {
 
-      // Import Standard MIDI file
+   Alg_seq_ptr new_seq = new Alg_seq(fName, is_midi);
 
-      Alg_midifile_reader *reader = new Alg_midifile_reader(mf.fp(), new 
Alg_seq);
-      reader->parse();
-      
+   //Should we also check if(seq->tracks() == 0) ?
+   if(new_seq->get_read_error() == alg_error_open){
+      wxMessageBox( _("Could not open file ") + fName + ".");
       mf.Close();
-      
-      if (reader->seq->tracks() == 0) {
-         // TODO: is there a better way to see if an error occurred?
-         wxMessageBox(_("Error parsing MIDI file."));
-         return false;
-      }
-
-      // need a Seq_ptr to a seq on the heap, but all we have is a reader 
member
-      // so copy to the heap. Be careful because reader will be deleted.
-      //Seq_ptr seq = new Seq;
-      //*seq = *(reader.seq);
-      
-      dest->SetSequence(reader->seq);
-
+      return false;
    }
 
+   dest->SetSequence(new_seq);
+   mf.Close();
    return true;
-}
+}      
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a
 // version control system. Please do not modify past this point.


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to