summaryrefslogtreecommitdiff
path: root/liveengine/src
diff options
context:
space:
mode:
Diffstat (limited to 'liveengine/src')
-rwxr-xr-x[-rw-r--r--]liveengine/src/main.cpp7
-rwxr-xr-xliveengine/src/testApp.cpp192
-rwxr-xr-xliveengine/src/testApp.h26
3 files changed, 147 insertions, 78 deletions
diff --git a/liveengine/src/main.cpp b/liveengine/src/main.cpp
index 41470a2..28ab04b 100644..100755
--- a/liveengine/src/main.cpp
+++ b/liveengine/src/main.cpp
@@ -1,17 +1,20 @@
#include "ofMain.h"
#include "testApp.h"
+#include "ofxFensterManager.h"
#include "ofAppGlutWindow.h"
//========================================================================
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 1024,768, OF_WINDOW); // <-------- setup the GL context
+ ofSetupOpenGL(ofxFensterManager::get(),1024,768, OF_WINDOW);
+ //ofSetupOpenGL(&window, 1024,768, 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());
+ //ofRunApp( new testApp());
+ ofRunFensterApp( new testApp());
}
diff --git a/liveengine/src/testApp.cpp b/liveengine/src/testApp.cpp
index 4935803..5e5a140 100755
--- a/liveengine/src/testApp.cpp
+++ b/liveengine/src/testApp.cpp
@@ -1,69 +1,98 @@
#include "testApp.h"
-
+previewWindow::~previewWindow(){
+ cout << "preview window destroyed" << endl;
+}
+void previewWindow::setup(){}
+void previewWindow::setBuffer(ofFbo *buffer){
+ rb=buffer;
+}
+void previewWindow::draw(){
+ float offset=(ofGetWidth()-ofGetHeight())/2;
+
+ ofPushMatrix();
+
+ ofTranslate(ofGetWidth()/2,ofGetHeight()/2);
+ ofRotate(90);
+ ofTranslate(-ofGetWidth()/2,-ofGetHeight()/2);
+
+ rb->draw(offset,-offset,ofGetHeight(),ofGetWidth());
+ ofPopMatrix();
+}
//--------------------------------------------------------------
void testApp::setup(){
- int midiPort=0;
- midiChannel=0;
- if( !XML.loadFile("settings.xml") ){
+ int midiPort=0;
+ midiChannel=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);
- }
-
- midiIn.listPorts();
- midiIn.openPort(midiPort);
- midiIn.addListener(this);
+ 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);
+ }
- // to register only to one controller pass the id as first argument
- // midiIn.addListener(84,this);
+ midiIn.listPorts();
+ midiIn.openPort(midiPort);
+ midiIn.addListener(this);
- // to debug
- // midiIn.setVerbose(true);
+ // to register only to one controller pass the id as first argument
+ // midiIn.addListener(84,this);
+ // to debug
+ // midiIn.setVerbose(true);
- controllers=new unsigned char[NUM_CONTROLLERS];
- memset(controllers,NUM_CONTROLLERS,0);
+ controllers=new unsigned char[NUM_CONTROLLERS];
+ memset(controllers,NUM_CONTROLLERS,0);
note=0;
- makeColours();
+ makeColours();
- controlColours=false;
+ controlColours=false;
+ debug=false;
+ noteRandomiseColours=false;
- grab.allocate(1024,768,GL_RGB); //ofGetWidth(), ofGetHeight(),GL_RGB);
- //grab.setUseTexture(true);
+ //ofGetWidth(), ofGetHeight(),GL_RGB); //
+ rb1.allocate(1024,768,GL_RGB);
+ rb2.allocate(1024,768,GL_RGB);
- showFPS=false;
- ofBackground(0,0,0);
+ showFPS=false;
+ ofBackground(0,0,0);
- ofSetBackgroundAuto(false);
+ ofSetBackgroundAuto(false);
- xshift=-1;
- yshift=-1;
+ xshift=-1;
+ yshift=-1;
- fadetime=0;
-
+ fadetime=0;
- mode=BLOCKS;
+ mode=BLOCKS;
- lastnoteTime=ofGetElapsedTimef();
- decayTime=2.0f;
+ lastnoteTime=ofGetElapsedTimef();
+ decayTime=2.0f;
- //ofSetVerticalSync(true); deosn't seem effective
- //glXSwapIntervalSGI(1);
- /*
- printf("hue of red is %f\n",ofColor(255,0,0).getHue());
- printf("hue of green is %f\n",ofColor(0,255,0).getHue());
- printf("hue of blue is %f\n",ofColor(0,0,255).getHue());
- hue is float from 0.0-255.0
- */
- ofSetFrameRate(60);
- rotate=0;
- scale=1.0f;
-
- prevWin.setup();
+ //ofSetVerticalSync(true); deosn't seem effective
+ //glXSwapIntervalSGI(1);
+ /*
+ printf("hue of red is %f\n",ofColor(255,0,0).getHue());
+ printf("hue of green is %f\n",ofColor(0,255,0).getHue());
+ printf("hue of blue is %f\n",ofColor(0,0,255).getHue());
+ hue is float from 0.0-255.0
+ */
+ ofSetFrameRate(60);
+ rotate=-90;
+ scale=1.0f;
+
+
+ //window stuff
+ ofxFenster* win=ofxFensterManager::get()->createFenster(0, 0, ofGetHeight()/2, ofGetWidth()/2, OF_WINDOW);
+ ofAddListener(win->events.mouseMoved, this, &testApp::mouseMovedEvent);
+ ofAddListener(win->events.keyPressed, this, &testApp::keyPressedEvent);
+ win->setWindowTitle("preview");
+ win->addListener(&prevWin);
+ prevWin.setup();
+ prevWin.setBuffer(&rb2);
+
+
}
void testApp::makeColours() {
@@ -78,21 +107,21 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
- grab.loadScreenData( 0, 0, ofGetWidth(), ofGetHeight() );
+ rb1.begin();
+
/* can this work?
grab.setAnchorPoint(xshift,yshift);
grab.setTextureWrap( GL_WRAP_BORDER, GL_WRAP_BORDER);
grab.draw(0,0); // xshift,yshift);
*/
- ofSetColor(255-fadetime,255-fadetime,255-fadetime);
+ ofSetColor(255-fadetime,255-fadetime,255-fadetime);
for (int i=(xshift>0?xshift-ofGetWidth():xshift);i<ofGetWidth()*2;i+=ofGetWidth()) {
- for (int j=(yshift>0?yshift-ofGetHeight():yshift);j<ofGetHeight()*2;j+=ofGetHeight()) {
- grab.draw(i,j);
- }
+ for (int j=(yshift>0?yshift-ofGetHeight():yshift);j<ofGetHeight()*2;j+=ofGetHeight()) {
+ rb2.draw(i,j);
+ }
}
-
-
+
float notewidth=ofGetWidth()/NUM_NOTES;
float noteheight=ofGetHeight()/NUM_CONTROLLERS;
@@ -126,13 +155,29 @@ void testApp::draw(){
//for (int i=0;i<numLayers;i++) layers[i]->draw();
ofSetColor(255,255,255);
- if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20);
+ if (showFPS) ofDrawBitmapString(ofToString(ofGetFrameRate(), 2),20,20);
+
+ rb1.end();
+
+ rb2.begin();
+ ofSetColor(255,255,255);
+ rb1.draw(0,0);
+ rb2.end();
+
+ rb2.draw(0,0);
+
}
//--------------------------------------------------------------
-void testApp::keyPressed (int key){
- if(key == 'q'){
+void testApp::keyPressed(int key, ofxFenster* win){
+ if(key == ' '){
+ win->toggleFullscreen();
+ }
+ else keyPressed(key);
+}
+void testApp::keyPressed(int key){
+ if(key == 'q'){
list.load("insects.xml");
}
if(key == 'w'){
@@ -172,20 +217,19 @@ void testApp::keyPressed (int key){
if(key >='0' && key <= '9'){
mode=key-'0';
}
- if(key == OF_KEY_LEFT){
- yshift++;
-
+ if(key == 267){
+ yshift++;
}
- if(key == OF_KEY_RIGHT){
+ if(key == 268){
yshift--;
}
- if(key == OF_KEY_DOWN){
+ if(key == 269){
xshift--;
}
- if(key == OF_KEY_UP){
+ if(key == 270){
xshift++;
}
- if(key == '='){
+ if(key == '='){
makeColours();
}
if(key == '-'){
@@ -209,6 +253,14 @@ void testApp::keyPressed (int key){
if(key == '{'){
rotate-=90;
}
+
+
+ if(key == 'd'){
+ debug=!debug;
+ }
+ if(key == 'p'){
+ noteRandomiseColours=!noteRandomiseColours;
+ }
}
//--------------------------------------------------------------
@@ -247,6 +299,15 @@ void testApp::gotMessage(ofMessage msg){
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
+}
+
+void testApp::mouseMovedEvent(ofMouseEventArgs &args) {
+ //cout << "MOUSE WAS MOVED" << endl;
+}
+
+void testApp::keyPressedEvent(ofKeyEventArgs &args) {
+ //printf("window key pressed: %i (%c)\n",args.key,args.key);
+ keyPressed(args.key);
}
void testApp::toggleFPS(){
@@ -279,15 +340,16 @@ void testApp::newMidiMessage(ofxMidiEventArgs& eventArgs){
//for (int i=0;i<numLayers;i++){
// if (layers[i]->note==eventArgs.byteOne) layers[i]->setActive(noteOn);
//}
- printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
+ if (debug) printf("note: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
note=eventArgs.byteOne;
- lastnoteTime=ofGetElapsedTimef();
+ lastnoteTime=ofGetElapsedTimef();
+ if (noteRandomiseColours) makeColours();
break;
case 176: //control change channel 0
//for (int i=0;i<numLayers;i++){
// if (layers[i]->mix==eventArgs.byteOne) layers[i]->setMixAmt(((float)eventArgs.byteTwo)/127.0f);
//}
- printf("cc: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
+ if (debug) printf("cc: %i %i\n",eventArgs.byteOne,eventArgs.byteTwo);
controllers[eventArgs.byteOne-START_CONTROLLER]=eventArgs.byteTwo;
}
}
diff --git a/liveengine/src/testApp.h b/liveengine/src/testApp.h
index 9104ac6..a556038 100755
--- a/liveengine/src/testApp.h
+++ b/liveengine/src/testApp.h
@@ -56,6 +56,8 @@ wrap around/ scale textures
3d blocks
non random colours
+option to randomise colours on each note
+
*/
@@ -79,17 +81,14 @@ non random colours
class previewWindow: public ofxFensterListener{
public:
- ~previewWindow(){
- cout << "preview window destroyed" << endl;
- }
- void setup(){
- }
- void draw(ofTexture &grab){
- grab.draw(0,0,ofGetWidth(),ofGetHeight());
- }
-
+ ~previewWindow();
+ ofFbo *rb;
+ void setup();
+ void setBuffer(ofFbo *buffer);
+ void draw();
};
+//#define GRAB_TEXTURE
class testApp : public ofxFensterListener, public ofxMidiListener{
@@ -99,6 +98,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
void update();
void draw();
+ void keyPressed(int key, ofxFenster* win);
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
@@ -109,6 +109,9 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
+ void mouseMovedEvent(ofMouseEventArgs &args);
+ void keyPressedEvent(ofKeyEventArgs &args);
+
void makeColours();
void toggleFPS();
@@ -119,7 +122,8 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
unsigned char* controllers;
int note, mode;
- bool controlColours;
+ bool debug, controlColours;
+ bool noteRandomiseColours;
float lastnoteTime;
float decayTime;
@@ -132,7 +136,7 @@ class testApp : public ofxFensterListener, public ofxMidiListener{
ofColor* controller_colours;
- ofTexture grab;
+ ofFbo rb1,rb2;
previewWindow prevWin;