view jnmr/testApp.h @ 36:5a1b0c6fa1fb

Added class to read in the csv Annotation file, then write out the respective difference between the performed piece as followed here, and the annotation of RWC by Ewert and Muller
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Thu, 15 Dec 2011 02:28:49 +0000
parents 9d2a651a87b2
children 795a99987875
line wrap: on
line source
#ifndef _TEST_APP
#define _TEST_APP


//midieventholder - newMidiEvents() sent there
//create cannamMidiLoader for cannamMainfunction


//check new prior offset function - how is used?



//check the widening function - adding decay noise
//ticksperscreen could be better as millis per screen



//uses ftmMidiPlay in max5 via osc to communicate notes in

#include "ofMain.h"

#include "MIDIFileReader.h"
#include "ofxFileDialogOSX.h"
#include "drawMidiNotes.h"

#include "CannamMidiFileLoader.h"
#include <iostream>
#include "midiEventHolder.h"
#include "ofxMidiIn.h"
#include "ofxOsc.h"
#include "MidiInputStream.h"
#include "ofxArgs.h"
#include "Annotations.h"

// basic file operations for text file stuff
#include <iostream>
#include <fstream>
using namespace std;

#define PORT 12121
#define SEND_PORT 5282
#define HOST "localhost"


using namespace std;
using namespace MIDIConstants;

class testApp : public ofBaseApp{
private:
	ofxArgs* args;
	string option1, option2;
	bool flag1;
	ofxOscReceiver	receiver;
	ofxOscSender	sender;
	
public:
		testApp(ofxArgs* args);

		void setup();
		void update();
		void draw();

		void keyPressed  (int key);
		void keyReleased(int key);
		void mouseMoved(int x, int y );
		void mouseDragged(int x, int y, int button);
		void mousePressed(int x, int y, int button);
		void mouseReleased(int x, int y, int button);
		void windowResized(int w, int h);

	void startPlaying();
	void stopPlaying();
	bool getFilenameFromDialogBox(string* fileNameToSave);

	typedef std::vector<int> IntVector;
	typedef std::vector<double> DoubleVector;
//	typedef std::vector<IntVector> IntMatrix;	
	IntVector v;

	midiEventHolder midiEvents;
	
	int cannamMainFunction();
	string midiFileName;
	std::string museScoreFilename;
	
	bool playing;
	//drawMidiNotes drawer;
	
//	BayesianArrayStructure bayesStruct;
	
	int screenWidth, screenHeight;
	CannamMidiFileLoader fileLoader;

	//MIDI INPUT
	// vars
	int port;
	int id;
	int value;
	double timestamp;
	char msg[255];
	string portName;
	
	void checkNewScoreNote();
	void sendNoteToMuseScore();
	void sendMeasureToMuseScore();
	void sendBlackNotes();
	void findMeasure();
	
	// midi addon
	ofxMidiIn	midiIn;
	// this is your listener function
	void newMessage(ofxMidiEventArgs &args);
	
	MidiInputStream noteInStream;

	double firstNoteTime;
	bool liveInputPlaying;
	double timePlayed;	
	int transpose;
	int lastScoreIndexSent;
	int lastMeasureSent;
	double performanceRating;
	void sendNoteDataByOsc(const int& pitch, const int& ticks);

	ofTrueTypeFont verdana30;
	int midiPort;
	std::string midiPortName;
	void loadRecordedMidiFile();
	
	bool readyToStart;
	void prepareToStartOnNextNote();
	void drawMuseScoreText();
	void readInSomeValues();

	
	
	//file output
	ofstream myfile;
	
};

#endif