changeset 11:df9c838d0b8f

fixed bug where the full midi file was sometimes not drawn (since minNoteIndexToPrint) was at the max and did not decrease properly in draw routine
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 25 Oct 2011 15:01:52 +0100
parents 2ab6f4670cf5
children 5897a5626f1f
files src/CannamMidiFileLoader.cpp src/midiEventHolder.cpp src/testApp.cpp workingNotes.rtf
diffstat 4 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/CannamMidiFileLoader.cpp	Mon Oct 17 22:22:55 2011 +0100
+++ b/src/CannamMidiFileLoader.cpp	Tue Oct 25 15:01:52 2011 +0100
@@ -49,7 +49,6 @@
 		int td = fr.getTimingDivision();
 		if (td < 32768) {
 			cout << "Timing division: " << fr.getTimingDivision() << " ppq" << endl;
-			
 			myMidiEvents.pulsesPerQuarternote = fr.getTimingDivision();
 		} else {
 			int frames = 256 - (td >> 8);
--- a/src/midiEventHolder.cpp	Mon Oct 17 22:22:55 2011 +0100
+++ b/src/midiEventHolder.cpp	Tue Oct 25 15:01:52 2011 +0100
@@ -183,7 +183,7 @@
 	timeString += " \n best estimate "+ofToString(bayesStruct.bestEstimate, 1);
 	timeString += " error "+ofToString(minimumMatchError, 0);
 	timeString += " map "+ofToString(bayesStruct.relativeSpeedPosterior.integratedEstimate, 1);
-	timeString += " rel speed "+ofToString(bayesStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesStruct.relativeSpeedPosterior.integratedEstimate), 1);
+	timeString += " rel speed "+ofToString(bayesStruct.relativeSpeedPosterior.getIndexInRealTerms(bayesStruct.relativeSpeedPosterior.integratedEstimate), 2);
 	
 	
 	//be able to draw the prior in correct location relative to the midi notes
@@ -490,7 +490,7 @@
 		//	numberOfScreensIn = tickLocation / ticksPerScreen;//rounds down
 		timeOffsetForScreen = getEventTimeMillis(numberOfScreensIn * ticksPerScreen);
 		
-		while (noteArrayIndex < recordedNoteOnMatrix.size() && tickLocation > recordedNoteOnMatrix[noteArrayIndex][0] )
+		while (noteArrayIndex < recordedNoteOnMatrix.size()-1 && tickLocation > recordedNoteOnMatrix[noteArrayIndex][0] )
 			noteArrayIndex++;
 		
 		
@@ -499,12 +499,12 @@
 		
 		//need to start where we currently are in file
 		int maxNoteIndexToPrint	= noteArrayIndex;
-		int minNoteIndexToPrint = noteArrayIndex;
+		int minNoteIndexToPrint = min(size-1,noteArrayIndex);//not needed as changed above
 		
 		while (maxNoteIndexToPrint < recordedNoteOnMatrix.size() && recordedNoteOnMatrix[maxNoteIndexToPrint][0] < (numberOfScreensIn+1)*ticksPerScreen )
 			maxNoteIndexToPrint++;
 		
-		while (minNoteIndexToPrint > 0 && minNoteIndexToPrint < size && recordedNoteOnMatrix[minNoteIndexToPrint][0] > numberOfScreensIn*ticksPerScreen)
+		while (minNoteIndexToPrint > 0 && recordedNoteOnMatrix[minNoteIndexToPrint][0] > numberOfScreensIn*ticksPerScreen)//&& minNoteIndexToPrint < size 
 			minNoteIndexToPrint--;
 		
 		for (int tmpIndex = max(0,minNoteIndexToPrint);tmpIndex < min(maxNoteIndexToPrint, (int)recordedNoteOnMatrix.size());tmpIndex++){
@@ -552,13 +552,19 @@
 		ofLine(xLocation, 0, xLocation, (*screenHeight));
 		
 		
+		int maxSize = recordedNoteOnMatrix[size-1][0];
+		
+		string indexString = "num screens in "+ofToString(numberOfScreensIn)+"; min index to print "+ofToString(minNoteIndexToPrint)+", max index to print "+ofToString(maxNoteIndexToPrint);
+		indexString += " size "+ofToString(size)+" tick loc "+ofToString(tickLocation)+" max size "+ofToString(maxSize);
+		ofDrawBitmapString(indexString, 20, 40);
+
 	}	
 	
 	ofDrawBitmapString(ofToString(timeOffsetForScreen, 1), 20,20);
 	
 	ofDrawBitmapString(timeString, 20, 60);
 	
-	
+
 }
 
 void midiEventHolder::drawFile(){	
--- a/src/testApp.cpp	Mon Oct 17 22:22:55 2011 +0100
+++ b/src/testApp.cpp	Tue Oct 25 15:01:52 2011 +0100
@@ -137,6 +137,7 @@
 		if (getFilenameFromDialogBox(filePtr)){
 			printf("Midifile: Loaded name okay :\n'%s' \n", midiFileName.c_str());	
 			cannamMainFunction();
+			
 		}
 	
 	}
--- a/workingNotes.rtf	Mon Oct 17 22:22:55 2011 +0100
+++ b/workingNotes.rtf	Tue Oct 25 15:01:52 2011 +0100
@@ -4,7 +4,11 @@
 \paperw11900\paperh16840\margl1440\margr1440\vieww20940\viewh15820\viewkind0
 \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
 
-\f0\fs24 \cf0 BUGS:\
+\f0\fs24 \cf0 USE ftmplayMidiFile in MaxMSP to send the MIDI notes in via OSC\
+\
+_ _ ______ __\
+\
+BUGS:\
 When prior and posterior etc are split off the screen, it doesn't find the right indices for them. Are we writing the correct prior vector? constrained limits?\
 \
 \