//-------------------------------------------------------------- void testApp::keyPressed(int key) { // send a note on if the key is a letter or a number if(isalnum((unsigned char) key)) { // scale the ascii values to midi velocity range 0-127 // see an ascii table: http://www.asciitable.com/ note = ofMap(key, 48, 122, 0, 127); velocity = 64; midiOut.sendNoteOn(channel, note, velocity); } if(key == 'l') { ofxMidiOut::listPorts(); } if (key == ' ') { ofFileDialogResult openFileResult= ofSystemLoadDialog("Select a jpg or png"); if (openFileResult.bSuccess) { ofLogVerbose("User selected a file"); //We have a file, check it and process it processOpenFileSelection(openFileResult); } } if (key == OF_KEY_UP) { altura += 12 % 128; } if (key == OF_KEY_DOWN) { altura -= 12 % 128; } if(key == '+') { velocity += 1; } if(key == '-') { velocity -= 1; } if(key == '1') { if (port1) { port1 = false; } else { port1 = true; } } if(key == '2') { if (port2) { port2 = false; } else { port2 = true; } } if(key == '3') { if (port3) { port3 = false; } else { port3 = true; } } if (key == 'R') { ofColor c; for (int i=0; i<image.getWidth(); i++) { for (int j=0; j<image.getHeight(); j++) { c = image.getColor(i, j); image.setColor(i, j, ofColor(c.r+1, c.g, c.b)); } } image.update(); } if (key == 'r') { ofColor c; for (int i=0; i<image.getWidth(); i++) { for (int j=0; j<image.getHeight(); j++) { c = image.getColor(i, j); image.setColor(i, j, ofColor(c.r-1, c.g, c.b)); } } } if (key == 'G') { ofColor c; for (int i=0; i<image.getWidth(); i++) { for (int j=0; j<image.getHeight(); j++) { c = image.getColor(i, j); image.setColor(i, j, ofColor(c.r, c.g+1, c.b)); } } image.update(); } if (key == 'g') { ofColor c; for (int i=0; i<image.getWidth(); i++) { for (int j=0; j<image.getHeight(); j++) { c = image.getColor(i, j); image.setColor(i, j, ofColor(c.r-10, c.g-1, c.b)); } } } if (key == 'B') { ofColor c; for (int i=0; i<image.getWidth(); i++) { for (int j=0; j<image.getHeight(); j++) { c = image.getColor(i, j); image.setColor(i, j, ofColor(c.r, c.g, c.b+1)); } } image.update(); } if (key == 'b') { ofColor c; for (int i=0; i<image.getWidth(); i++) { for (int j=0; j<image.getHeight(); j++) { c = image.getColor(i, j); image.setColor(i, j, ofColor(c.r, c.g, c.b-1)); } } } }
void testApp::onOpenClicked(bool & pressed){ if (pressed == false) return; ofFileDialogResult openFileResult= ofSystemLoadDialog("Select a jpg or png"); processOpenFileSelection(openFileResult); }