From b3548f90171f0be1ebfd7020f38f3d0acec65f8b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 9 Aug 2012 20:14:02 +0100 Subject: initial commit --- liveengine/src/main.cpp | 17 +++++ liveengine/src/testApp.cpp | 165 +++++++++++++++++++++++++++++++++++++++++++++ liveengine/src/testApp.h | 37 ++++++++++ 3 files changed, 219 insertions(+) create mode 100644 liveengine/src/main.cpp create mode 100755 liveengine/src/testApp.cpp create mode 100755 liveengine/src/testApp.h (limited to 'liveengine/src') diff --git a/liveengine/src/main.cpp b/liveengine/src/main.cpp new file mode 100644 index 0000000..f5eaddd --- /dev/null +++ b/liveengine/src/main.cpp @@ -0,0 +1,17 @@ +#include "ofMain.h" +#include "testApp.h" +#include "ofAppGlutWindow.h" + +//======================================================================== +int main( ){ + + ofAppGlutWindow window; + ofSetupOpenGL(&window, 400,300, OF_WINDOW); // <-------- setup the GL context + //ofSetupOpenGL(&window, 1024,768, OF_WINDOW); + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp( new testApp()); + +} diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp new file mode 100755 index 0000000..9ecb92f --- /dev/null +++ b/liveengine/src/testApp.cpp @@ -0,0 +1,165 @@ +#include "testApp.h" + + +//-------------------------------------------------------------- +void testApp::setup(){ + int midiPort=0; + midiChannel=0; + //numLayers=0; + if( !XML.loadFile("settings.xml") ){ + printf("unable to load settings.xml check data/ folder\n"); + }else{ + printf("settings loaded!\n"); + midiPort=ofToInt(XML.getAttribute("liveEngine", "port", "0")); //default to 0/all + midiChannel=ofToInt(XML.getAttribute("liveEngine", "channel", "0")); + if (midiChannel) printf("listening on port %d, midi channel %d\n",midiPort,midiChannel); + else printf("listening on port %d, all midi channels\n",midiPort); + if(XML.pushTag("liveEngine")) { + /* + numLayers=XML.getNumTags("layer"); + if(numLayers) { + layers=new globeLayer*[numLayers]; + for (int i=0;iupdate(); +} + +//-------------------------------------------------------------- +void testApp::draw(){ + ofBackground(0,0,0); + + //for (int i=0;idraw(); + + if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20); + +} + +//-------------------------------------------------------------- +void testApp::keyPressed (int key){ + if(key == 's'){ + XML.saveFile("settings.xml"); + printf("settings saved!\n"); + } + if(key == 'f'){ + toggleFPS(); + } +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button){ + + +} +void testApp::mousePressed(int x, int y, int button) { +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void testApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void testApp::dragEvent(ofDragInfo dragInfo){ + +} + +void testApp::toggleFPS(){ + showFPS=!showFPS; +} + +void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){ + + //newMessage(eventArgs.port, eventArgs.channel, eventArgs.byteTwo, eventArgs.timestamp); + +//byteOne : message type + + /* + int port; + int channel; + int status; + int byteOne; + int byteTwo; + double timestamp; + */ + + //printf("%d %d %d %d %d\n",eventArgs.port,eventArgs.channel,eventArgs.status,eventArgs.byteOne,eventArgs.byteTwo); + + bool noteOn; //this old thing! + + if ((midiChannel==0)||(eventArgs.channel==midiChannel)) { + switch(eventArgs.status) { + case 144: //noteon-off + noteOn=(eventArgs.byteTwo==0?false:true); + //for (int i=0;inote==eventArgs.byteOne) layers[i]->setActive(noteOn); + //} + printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo); + break; + case 176: //control change + //for (int i=0;imix==eventArgs.byteOne) layers[i]->setMixAmt(((float)eventArgs.byteTwo)/127.0f); + //} + printf("cc: %i %i\ n",eventArgs.byteOne,eventArgs.byteTwo); + } + } +} + diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h new file mode 100755 index 0000000..9b07764 --- /dev/null +++ b/liveengine/src/testApp.h @@ -0,0 +1,37 @@ +#pragma once + +#include "ofMain.h" +#include "ofxXmlSettings.h" + +#define OF_ADDON_USING_OFXMIDIIN + +#include "ofxMidi.h" + +class testApp : public ofBaseApp, public ofxMidiListener{ + + public: + + 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 dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + + void toggleFPS(); + bool showFPS; + + ofxXmlSettings XML; + + int midiChannel; + ofxMidiIn midiIn; + void newMidiMessage(ofxMidiEventArgs& eventArgs); +}; + -- cgit v1.2.3