comparison jnmr/testApp.cpp @ 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 158f5f38e9d3
children
comparison
equal deleted inserted replaced
51:ef30f465a904 52:13194a9dca77
3 3
4 testApp::testApp(ofxArgs* args){ 4 testApp::testApp(ofxArgs* args){
5 this->args = args; 5 this->args = args;
6 } 6 }
7 7
8 #pragma mark -Initialise
8 9
9 //-------------------------------------------------------------- 10 //--------------------------------------------------------------
10 void testApp::setup(){ 11 void testApp::setup(){
11 12
12 13
96 lastScoreIndexSent = 0; 97 lastScoreIndexSent = 0;
97 midiEvents.bestMatchIndex = 0; 98 midiEvents.bestMatchIndex = 0;
98 99
99 100
100 } 101 }
101 102 #pragma mark -Update
102 //-------------------------------------------------------------- 103 //--------------------------------------------------------------
103 void testApp::update(){ 104 void testApp::update(){
104 if (playing){ 105 if (playing){
105 midiEvents.updatePlayPosition();//this fn calls midiEvents.bayesStruct.updateBestEstimate(); 106 midiEvents.updatePlayPosition();//this fn calls midiEvents.bayesStruct.updateBestEstimate();
106 } 107 }
367 } 368 }
368 369
369 // cout << "MIDI message [port: " << args.port << ", channel: " << args.channel << ", status: " << args.status << ", byteOne: " << pitch << ", byteTwo: " << args.byteTwo << ", timestamp: " << args.timestamp << "]" << endl; 370 // cout << "MIDI message [port: " << args.port << ", channel: " << args.channel << ", status: " << args.status << ", byteOne: " << pitch << ", byteTwo: " << args.byteTwo << ", timestamp: " << args.timestamp << "]" << endl;
370 } 371 }
371 372
373 #pragma mark -Draw
374
372 //-------------------------------------------------------------- 375 //--------------------------------------------------------------
373 void testApp::draw(){ 376 void testApp::draw(){
374 377
375 midiEvents.drawFile(); 378 midiEvents.drawFile();
376 379 /*
377 string info = "Measure "; 380 string info = "Measure ";
378 info += ofToString(lastMeasureSent); 381 info += ofToString(lastMeasureSent);
379 info += " Last note "; 382 info += " Last note ";
380 info += ofToString(lastScoreIndexSent); 383 info += ofToString(lastScoreIndexSent);
381 384 ofDrawBitmapString(info, 20, 20);
382 ofSetHexColor(0xFF0000); 385 */
383 // ofDrawBitmapString(info, 20, 20);
384
385 midiEvents.drawMidiFile(noteInStream.midiInputEvents); 386 midiEvents.drawMidiFile(noteInStream.midiInputEvents);
386 387
387 //drawMuseScoreText(); 388 //drawMuseScoreText();
388 389
389 ofSetHexColor(0x000000); 390 ofSetHexColor(0x000000);
406 407
407 ratingString += extraText; 408 ratingString += extraText;
408 verdana30.drawString(ratingString, 20, 60); 409 verdana30.drawString(ratingString, 20, 60);
409 } 410 }
410 411
412 #pragma mark -keyInput
411 //-------------------------------------------------------------- 413 //--------------------------------------------------------------
412 void testApp::keyPressed(int key){ 414 void testApp::keyPressed(int key){
413 415
414 if (key == '.'){ 416 if (key == '.'){
415 midiPort++; 417 midiPort++;
433 timenow *= -1; 435 timenow *= -1;
434 timenow += ofGetElapsedTimeMillis(); 436 timenow += ofGetElapsedTimeMillis();
435 printf("CROSS UPDATE TOOK %f", timenow); 437 printf("CROSS UPDATE TOOK %f", timenow);
436 } 438 }
437 439
438 if (key == 'x')
439 sendNoteDataByOsc(60, 0);
440 440
441 if (key == OF_KEY_LEFT){ 441 if (key == OF_KEY_LEFT){
442 442
443 } 443 }
444 444
517 517
518 if (key == 'o' || key == 'O'){ 518 if (key == 'o' || key == 'O'){
519 loadRecordedMidiFile(); 519 loadRecordedMidiFile();
520 } 520 }
521 521
522 522 if (key == 'v'){
523 523 midiEvents.bayesStruct.drawPrior = midiEvents.bayesStruct.drawPosterior;
524 midiEvents.bayesStruct.drawLikelihood = !midiEvents.bayesStruct.drawLikelihood;
525 midiEvents.bayesStruct.drawPrior = !midiEvents.bayesStruct.drawPrior;
526 midiEvents.bayesStruct.drawPosterior = !midiEvents.bayesStruct.drawPosterior;
527 }
528
529 if (key == 'x'){
530 midiEvents.bayesStruct.drawPrior = !midiEvents.bayesStruct.drawPrior;
531 }
532
533 if (key == 'g'){
534 midiEvents.writeAllDistributions();
535 }
524 } 536 }
525 537
526 void testApp::loadRecordedMidiFile(){ 538 void testApp::loadRecordedMidiFile(){
527 //open audio file 539 //open audio file
528 string *filePtr; 540 string *filePtr;