annotate jnmr/testApp.h @ 52:13194a9dca77 tip

Added exporting of image and text data
author Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk>
date Tue, 17 Jul 2012 22:13:10 +0100
parents 3ce6dadd8167
children
rev   line source
andrew@33 1 #ifndef _TEST_APP
andrew@33 2 #define _TEST_APP
andrew@33 3
andrew@33 4
andrew@33 5 //midieventholder - newMidiEvents() sent there
andrew@33 6 //create cannamMidiLoader for cannamMainfunction
andrew@33 7
andrew@33 8
andrew@33 9 //check new prior offset function - how is used?
andrew@33 10
andrew@33 11
andrew@33 12
andrew@33 13 //check the widening function - adding decay noise
andrew@33 14 //ticksperscreen could be better as millis per screen
andrew@33 15
andrew@37 16 //uses ftmMidiPlay in max5 via osc to communicate notes in
andrew@33 17
andrew@33 18
andrew@37 19 //other users would need to change root in testApp setup to point to their director for the RWC files
andrew@33 20
andrew@48 21
andrew@48 22
andrew@33 23 #include "ofMain.h"
andrew@33 24
andrew@33 25 #include "MIDIFileReader.h"
andrew@33 26 #include "ofxFileDialogOSX.h"
andrew@33 27 #include "drawMidiNotes.h"
andrew@34 28
andrew@33 29 #include "CannamMidiFileLoader.h"
andrew@33 30 #include <iostream>
andrew@33 31 #include "midiEventHolder.h"
andrew@33 32 #include "ofxMidiIn.h"
andrew@33 33 #include "ofxOsc.h"
andrew@33 34 #include "MidiInputStream.h"
andrew@33 35 #include "ofxArgs.h"
andrew@36 36 #include "Annotations.h"
andrew@34 37
andrew@34 38 // basic file operations for text file stuff
andrew@34 39 #include <iostream>
andrew@34 40 #include <fstream>
andrew@34 41 using namespace std;
andrew@34 42
andrew@33 43 #define PORT 12121
andrew@33 44 #define SEND_PORT 5282
andrew@33 45 #define HOST "localhost"
andrew@33 46
andrew@33 47 using namespace MIDIConstants;
andrew@33 48
andrew@33 49 class testApp : public ofBaseApp{
andrew@33 50 private:
andrew@33 51 ofxArgs* args;
andrew@33 52 string option1, option2;
andrew@33 53 bool flag1;
andrew@33 54 ofxOscReceiver receiver;
andrew@33 55 ofxOscSender sender;
andrew@33 56
andrew@33 57 public:
andrew@33 58 testApp(ofxArgs* args);
andrew@33 59
andrew@33 60 void setup();
andrew@33 61 void update();
andrew@33 62 void draw();
andrew@33 63
andrew@33 64 void keyPressed (int key);
andrew@33 65 void keyReleased(int key);
andrew@33 66 void mouseMoved(int x, int y );
andrew@33 67 void mouseDragged(int x, int y, int button);
andrew@33 68 void mousePressed(int x, int y, int button);
andrew@33 69 void mouseReleased(int x, int y, int button);
andrew@33 70 void windowResized(int w, int h);
andrew@33 71
andrew@48 72 void checkOSCmessages();
andrew@33 73 void startPlaying();
andrew@33 74 void stopPlaying();
andrew@33 75 bool getFilenameFromDialogBox(string* fileNameToSave);
andrew@33 76
andrew@33 77 typedef std::vector<int> IntVector;
andrew@33 78 typedef std::vector<double> DoubleVector;
andrew@33 79 // typedef std::vector<IntVector> IntMatrix;
andrew@33 80 IntVector v;
andrew@33 81
andrew@33 82 midiEventHolder midiEvents;
andrew@33 83
andrew@33 84 int cannamMainFunction();
andrew@33 85 string midiFileName;
andrew@33 86 std::string museScoreFilename;
andrew@33 87
andrew@33 88 bool playing;
andrew@33 89 //drawMidiNotes drawer;
andrew@33 90
andrew@33 91 // BayesianArrayStructure bayesStruct;
andrew@33 92
andrew@33 93 int screenWidth, screenHeight;
andrew@33 94 CannamMidiFileLoader fileLoader;
andrew@33 95
andrew@33 96 //MIDI INPUT
andrew@33 97 // vars
andrew@33 98 int port;
andrew@33 99 int id;
andrew@33 100 int value;
andrew@33 101 double timestamp;
andrew@33 102 char msg[255];
andrew@33 103 string portName;
andrew@33 104
andrew@33 105 void checkNewScoreNote();
andrew@33 106 void sendNoteToMuseScore();
andrew@33 107 void sendMeasureToMuseScore();
andrew@33 108 void sendBlackNotes();
andrew@33 109 void findMeasure();
andrew@33 110
andrew@33 111 // midi addon
andrew@33 112 ofxMidiIn midiIn;
andrew@33 113 // this is your listener function
andrew@33 114 void newMessage(ofxMidiEventArgs &args);
andrew@33 115
andrew@33 116 MidiInputStream noteInStream;
andrew@33 117
andrew@33 118 double firstNoteTime;
andrew@33 119 bool liveInputPlaying;
andrew@33 120 double timePlayed;
andrew@33 121 int transpose;
andrew@33 122 int lastScoreIndexSent;
andrew@33 123 int lastMeasureSent;
andrew@33 124 double performanceRating;
andrew@33 125 void sendNoteDataByOsc(const int& pitch, const int& ticks);
andrew@33 126
andrew@33 127 ofTrueTypeFont verdana30;
andrew@33 128 int midiPort;
andrew@33 129 std::string midiPortName;
andrew@33 130 void loadRecordedMidiFile();
andrew@33 131
andrew@33 132 bool readyToStart;
andrew@33 133 void prepareToStartOnNextNote();
andrew@34 134 void drawMuseScoreText();
andrew@36 135 void readInSomeValues();
andrew@34 136
andrew@34 137
andrew@34 138
andrew@34 139 //file output
andrew@34 140 ofstream myfile;
andrew@37 141 ofstream diffFile;
andrew@37 142 string root, outputFileRoot;
andrew@37 143 int midiFileNumber;
andrew@37 144 void loadRWCfileNumber(const int& i);
andrew@37 145 void openOutputFile(const int& i);
andrew@38 146 std::string makeRWCfilename(std::string& root, const int& fileID, std::string& endPart);
andrew@38 147 void loadAnnotation(const int& fileID);
andrew@41 148
andrew@41 149 vector<std::string> rwcFileNameStrings;
andrew@41 150 void createRWCfilenameStrings();
andrew@49 151 string annotationRoot ;//eg = "/Users/andrew/Documents/work/MuseScore/RWC/ANNOTATION/RM-C0";
andrew@33 152 };
andrew@33 153
andrew@33 154 #endif