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

Modified Files:
        ImportMIDI.cpp 
Log Message:
This commit replaces the old version of the allegro score representation 
library with portsmf, a newer version of allegro. Cut, copy, paste, and undo 
are now supported. Developed and tested on XP; untested on OS X and Linux. All 
changes are controlled by EXPERIMENTAL_NOTE_TRACK. Files added to the 
allegro.vcproj file are allegrosmfrd.h and allegrosmfrd.cpp.

Index: ImportMIDI.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/import/ImportMIDI.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ImportMIDI.cpp      23 Sep 2006 02:26:55 -0000      1.9
+++ ImportMIDI.cpp      28 Jun 2008 21:53:51 -0000      1.10
@@ -21,7 +21,12 @@
 #include "strparse.h"
 #include "allegrord.h"
 #include "mfmidi.h"
+
+#ifndef EXPERIMENTAL_NOTE_TRACK
 #include "mfallegro.h"
+#else /* EXPERIMENTAL_NOTE_TRACK */
+#include "allegrosmfrd.h"
+#endif /* EXPERIMENTAL_NOTE_TRACK */
 
 bool ImportMIDI(wxString fName, NoteTrack * dest)
 {
@@ -37,10 +42,15 @@
 
       // Import Allegro file (Roger Dannenberg)
 
+#ifndef EXPERIMENTAL_NOTE_TRACK
       Allegro_reader reader(mf.fp());
+#else /* EXPERIMENTAL_NOTE_TRACK */
+      Alg_reader reader( mf.fp(), new Alg_seq );
+#endif /* EXPERIMENTAL_NOTE_TRACK */
       reader.parse();
       mf.Close();
       
+#ifndef EXPERIMENTAL_NOTE_TRACK
       if (reader.seq.notes.len == 0) {
          // TODO: is there a better way to see if an error occurred?
          wxMessageBox(_("Error parsing Allegro file."));
@@ -48,6 +58,19 @@
       }
       // 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.
+#else /* EXPERIMENTAL_NOTE_TRACK */
+      if(reader.error_flag)
+      {
+         // TODO: is there a better way to see if an error occurred?
+         wxMessageBox(_("Error parsing Allegro 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.
+#endif /* EXPERIMENTAL_NOTE_TRACK */
+
+
+#ifndef EXPERIMENTAL_NOTE_TRACK
       Seq_ptr seq = new Seq;
       *seq = reader.seq;
       
@@ -66,7 +89,6 @@
       // Import Standard MIDI file
 
       Allegro_midifile_reader *reader = new Allegro_midifile_reader();
-      
       reader->initialize(mf.fp());
       
       mf.Close();
@@ -88,6 +110,49 @@
 
    return true;
 }
+#else /* EXPERIMENTAL_NOTE_TRACK */
+      /*Seq_ptr seq = new Seq;
+      *seq = reader.seq;*/
+      
+      // 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 );
+   }
+   else {
+
+      // Import Standard MIDI file
+
+      Alg_midifile_reader *reader = new Alg_midifile_reader(mf.fp(), new 
Alg_seq);
+      reader->parse();
+      
+      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 true;
+}
+#endif /* EXPERIMENTAL_NOTE_TRACK */
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a
 // version control system. Please do not modify past this point.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to