changeset 601:5eb5449432f5

* debug only
author Chris Cannam
date Tue, 18 Aug 2009 11:08:29 +0000
parents 3f6d9930bc28
children 02d9664906e8
files plugin/plugins/SamplePlayer.cpp
diffstat 1 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/plugin/plugins/SamplePlayer.cpp	Fri Aug 14 14:01:09 2009 +0000
+++ b/plugin/plugins/SamplePlayer.cpp	Tue Aug 18 11:08:29 2009 +0000
@@ -32,6 +32,8 @@
 #include <samplerate.h>
 #include <iostream>
 
+//#define DEBUG_SAMPLE_PLAYER 1
+
 const char *const
 SamplePlayer::portNames[PortCount] =
 {
@@ -317,7 +319,9 @@
 
     if (player->m_pendingProgramChange >= 0) {
 
-//	std::cerr << "SamplePlayer::workThreadCallback: pending program change " << player->m_pendingProgramChange << std::endl;
+#ifdef DEBUG_SAMPLE_PLAYER
+	std::cerr << "SamplePlayer::workThreadCallback: pending program change " << player->m_pendingProgramChange << std::endl;
+#endif
 
 	player->m_mutex.lock();
 
@@ -358,8 +362,10 @@
 
     m_samples.clear();
 
+#ifdef DEBUG_SAMPLE_PLAYER
     std::cerr << "SamplePlayer::searchSamples: Directory is \""
 	      << m_sampleDir.toLocal8Bit().data() << "\"" << std::endl;
+#endif
 
     QDir dir(m_sampleDir, "*.wav");
     
@@ -368,7 +374,9 @@
         if (file.isReadable()) {
             m_samples.push_back(std::pair<QString, QString>
                                 (file.baseName(), file.filePath()));
-//            std::cerr << "Found: " << dir[i].toLocal8Bit().data() << std::endl;
+#ifdef DEBUG_SAMPLE_PLAYER
+            std::cerr << "Found: " << dir[i].toLocal8Bit().data() << std::endl;
+#endif
         }
     }
     
@@ -494,6 +502,10 @@
 	       && pos >= events[event_pos].time.tick) {
 
 	    if (events[event_pos].type == SND_SEQ_EVENT_NOTEON) {
+#ifdef DEBUG_SAMPLE_PLAYER
+                std::cerr << "SamplePlayer: found NOTEON at time " 
+                          << events[event_pos].time.tick << std::endl;
+#endif
 		snd_seq_ev_note_t n = events[event_pos].data.note;
 		if (n.velocity > 0) {
 		    m_ons[n.note] =
@@ -508,6 +520,10 @@
 		}
 	    } else if (events[event_pos].type == SND_SEQ_EVENT_NOTEOFF &&
 		       (!m_sustain || (*m_sustain < 0.001))) {
+#ifdef DEBUG_SAMPLE_PLAYER
+                std::cerr << "SamplePlayer: found NOTEOFF at time " 
+                          << events[event_pos].time.tick << std::endl;
+#endif
 		snd_seq_ev_note_t n = events[event_pos].data.note;
 		m_offs[n.note] = 
 		    m_sampleNo + events[event_pos].time.tick;
@@ -522,12 +538,19 @@
 	    count = events[event_pos].time.tick - pos;
 	}
 
+        int notecount = 0;
+
 	for (i = 0; i < Polyphony; ++i) {
 	    if (m_ons[i] >= 0) {
+                ++notecount;
 		addSample(i, pos, count);
 	    }
 	}
 
+#ifdef DEBUG_SAMPLE_PLAYER
+        std::cerr << "SamplePlayer: have " << notecount << " note(s) sounding currently" << std::endl;
+#endif
+
 	pos += count;
     }
 
@@ -564,6 +587,9 @@
 	unsigned long rsi = lrintf(floor(rs));
 
 	if (rsi >= m_sampleCount) {
+#ifdef DEBUG_SAMPLE_PLAYER
+            std::cerr << "Note " << n << " has run out of samples (were " << m_sampleCount << " available at ratio " << ratio << "), ending" << std::endl;
+#endif
 	    m_ons[n] = -1;
 	    break;
 	}
@@ -580,6 +606,9 @@
 	    }
 
 	    if (dist > releaseFrames) {
+#ifdef DEBUG_SAMPLE_PLAYER
+                std::cerr << "Note " << n << " has expired its release time (" << releaseFrames << " frames), ending" << std::endl;
+#endif
 		m_ons[n] = -1;
 		break;
 	    } else {