changeset 1128:50210da3997c

Simple MIDI writer test
author Chris Cannam
date Tue, 01 Sep 2015 15:51:07 +0100
parents 067b60ae4861
children 1cc96e03a903
files data/fileio/MIDIFileWriter.cpp
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/MIDIFileWriter.cpp	Wed Aug 19 16:36:21 2015 +0100
+++ b/data/fileio/MIDIFileWriter.cpp	Tue Sep 01 15:51:07 2015 +0100
@@ -27,9 +27,13 @@
 
 #include "base/Pitch.h"
 
+#include <QCoreApplication>
+
 #include <algorithm>
 #include <fstream>
 
+//#define DEBUG_MIDI_FILE_WRITER 1
+
 using std::ofstream;
 using std::string;
 using std::ios;
@@ -320,12 +324,9 @@
 
     MIDIEvent *event;
 
-    event = new MIDIEvent(0, MIDI_FILE_META_EVENT, MIDI_CUE_POINT,
-                          "Exported from Sonic Visualiser");
-    m_midiComposition[track].push_back(event);
-
-    event = new MIDIEvent(0, MIDI_FILE_META_EVENT, MIDI_CUE_POINT,
-                          "http://www.sonicvisualiser.org/");
+    event = new MIDIEvent
+        (0, MIDI_FILE_META_EVENT, MIDI_CUE_POINT,
+         ("Exported from " + qApp->applicationName()).toStdString());
     m_midiComposition[track].push_back(event);
 
     long tempoValue = long(60000000.0 / m_tempo + 0.01);
@@ -384,6 +385,10 @@
                               127); // loudest silence you can muster
 
         m_midiComposition[track].push_back(event);
+
+#ifdef DEBUG_MIDI_FILE_WRITER
+        cerr << "midiTime = " << midiTime << ", endTime = " << endTime << endl;
+#endif
     }
     
     // Now gnash through the MIDI events and turn the absolute times
@@ -404,6 +409,9 @@
         for (MIDITrack::iterator it = m_midiComposition[i].begin();
              it != m_midiComposition[i].end(); it++) {
             unsigned long deltaTime = (*it)->getTime() - lastMidiTime;
+#ifdef DEBUG_MIDI_FILE_WRITER
+            cerr << "time = " << (*it)->getTime() << ", lastMidiTime = " << lastMidiTime << ", deltaTime = " << deltaTime << endl;
+#endif
             lastMidiTime = (*it)->getTime();
             (*it)->setTime(deltaTime);
         }