Skip to content

Commit

Permalink
dd festival
Browse files Browse the repository at this point in the history
  • Loading branch information
krgn committed Apr 30, 2015
1 parent 8fa507c commit 976eccc
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 6 deletions.
7 changes: 4 additions & 3 deletions config.make
Expand Up @@ -76,7 +76,8 @@ PROJECT_ROOT = .
# add a runtime path to search for those shared libraries, since they aren't
# incorporated directly into the final executable application binary.
################################################################################
PROJECT_LDFLAGS=-Wl,-rpath=./libs -pg
# PROJECT_LDFLAGS=-Wl,-rpath=./libs -pg
PROJECT_LDFLAGS=-Wl,-rpath=./libs

################################################################################
# PROJECT DEFINES
Expand Down Expand Up @@ -104,7 +105,7 @@ PROJECT_LDFLAGS=-Wl,-rpath=./libs -pg
#
# Note: Leave a leading space when adding list items with the += operator
################################################################################
PROJECT_CFLAGS = -pg -g
# PROJECT_CFLAGS = -pg -g

################################################################################
# PROJECT OPTIMIZATION CFLAGS
Expand All @@ -128,7 +129,7 @@ PROJECT_CFLAGS = -pg -g
# Note: Leave a leading space when adding list items with the += operator
################################################################################
PROJECT_OPTIMIZATION_CFLAGS_RELEASE = -O3
# PROJECT_OPTIMIZATION_CFLAGS_DEBUG =
# PROJECT_OPTIMIZATION_CFLAGS_DEBUG =

################################################################################
# PROJECT COMPILERS
Expand Down
32 changes: 30 additions & 2 deletions src/Cameras.cpp
Expand Up @@ -3,12 +3,17 @@
void
Cameras::setup()
{
frameCount = 0;

layout = SINGLE;
viewMode = SCALE;

fxMode = false;
triggerMode = false;

lastTrigger = make_tuple(0, frameCount);
triggerTimeout = 20;

winWidth = ofGetWidth();
winHeight = ofGetHeight();

Expand Down Expand Up @@ -69,6 +74,7 @@ Cameras::draw()
drawMonocle();
break;
}
frameCount++;
}

void
Expand Down Expand Up @@ -185,7 +191,14 @@ Cameras::calculateHeight()
void
Cameras::drawSingle()
{
cameras.at(slots.at(0))
int idx;

if(triggerMode)
idx = slots.at(get<0>(lastTrigger));
else
idx = slots.at(0);

cameras.at(idx)
.draw(xOffset, yOffset, 0, scaledWidth, scaledHeight, 0, 0, camWidth, camHeight);
}

Expand Down Expand Up @@ -277,6 +290,19 @@ Cameras::trigger()
void
Cameras::trigger(int idx)
{
// if the last trigger was triggerTimeout frames in the past
uint offset = (frameCount - get<1>(lastTrigger));
if(offset >= triggerTimeout)
{
// and if last triggered is different, switch
if((idx != get<0>(lastTrigger)) &&
(idx >= 0 && idx < (int)cameras.size()))
{
lastTrigger = make_tuple(idx, frameCount);
cout << "setting to idx: " << idx << " frame: " << frameCount << endl;
}
}

if(idx >= 0 && idx < (int)cameras.size())
cameras.at(idx).trigger();
}
Expand All @@ -291,8 +317,9 @@ Cameras::reset(int idx)
void
Cameras::setTriggerMode(bool mode)
{
triggerMode = mode;
for(uint i=0; i < cameras.size(); i++)
cameras.at(i).setTriggerMode(mode);
cameras.at(i).setTriggerMode(triggerMode);
}

void
Expand Down Expand Up @@ -351,6 +378,7 @@ Cameras::setSlot(int idx, int cam)
void
Cameras::setDecay(int decay)
{
triggerTimeout = decay;
for(uint i=0; i < cameras.size(); i++)
cameras.at(i).setDecay(decay);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Cameras.h
Expand Up @@ -46,6 +46,10 @@ class Cameras {
bool fxMode;
bool triggerMode;

tuple<int,uint> lastTrigger;
uint frameCount;
uint triggerTimeout;

int numTiles;

int camWidth;
Expand All @@ -60,6 +64,7 @@ class Cameras {
int yOffset;
int xOffset;


vector<Camera> cameras;

void recalculate();
Expand Down
40 changes: 40 additions & 0 deletions src/MadCam.cpp
Expand Up @@ -10,6 +10,7 @@ void MadCam::setup(){
midiHandler.registerHost(this);
oscHandler.registerHost(this);
cameras.setup();
fbo.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA);
}

//--------------------------------------------------------------
Expand All @@ -35,9 +36,48 @@ MadCam::setScene(int idx)
cameras.setSlot(i, config.sceneMap.at(idx).slots.at(i));
}

void
MadCam::setIterations(int iter)
{
if(iter >= 0 && iter <= 30)
iterations = iter;
}

void
MadCam::setAlpha(int al)
{
if(al >= 0 && al <= 255)
alpha = al;
}

void
MadCam::setXOffset(int off)
{
if(off >= 0 && off <= ofGetWidth())
xoffset = off;
}

void
MadCam::setYOffset(int off)
{
if(off >= 0 && off <= ofGetWidth())
yoffset = off;
}

//--------------------------------------------------------------
void MadCam::draw(){
fbo.begin();
cameras.draw();
fbo.end();
for(int i = 0; i < iterations; i++) {
fbo.begin();
ofEnableAlphaBlending();
ofSetColor(255,255,255,alpha);
fbo.draw(ofRandom(-xoffset,xoffset),ofRandom(-yoffset,yoffset));
ofDisableAlphaBlending();
fbo.end();
}
fbo.draw(0,0);
}

//--------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions src/MadCam.h
Expand Up @@ -13,6 +13,10 @@

class MadCam : public ofBaseApp {
int currentCam;
int iterations;
int xoffset;
int yoffset;
int alpha;

public:
void setup();
Expand All @@ -30,10 +34,17 @@ class MadCam : public ofBaseApp {
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void setScene(int idx);

void setIterations(int iter);
void setAlpha(int alpha);
void setXOffset(int offs);
void setYOffset(int offs);

ofxXmlSettings XML;
void parseConfig();

ofFbo fbo;

MidiHandler midiHandler;
OscHandler oscHandler;
Cameras cameras;
Expand Down
2 changes: 1 addition & 1 deletion src/MidiHandler.cpp
Expand Up @@ -10,7 +10,7 @@ MidiHandler::registerHost(MadCam* app)

vector<string> portList = midiIn.getPortList();

for(int i = 0; i < portList.size(); i++) {
for(uint i = 0; i < portList.size(); i++) {
//if(portList.at(i).compare(0, 9, "USB Uno MIDI Interface") == 0) {
if(portList.at(i).compare(0, 9, "FastTrack") == 0) {
cout << "opening " << portList.at(i) << endl;
Expand Down
12 changes: 12 additions & 0 deletions src/OscHandler.cpp
Expand Up @@ -54,6 +54,18 @@ OscHandler::process()
if(addr == "/decay")
application->cameras.setDecay(m.getArgAsInt32(0));

if(addr == "/iterations")
application->setIterations(m.getArgAsInt32(0));

if(addr == "/alpha")
application->setAlpha(m.getArgAsInt32(0));

if(addr == "/xoffset")
application->setXOffset(m.getArgAsInt32(0));

if(addr == "/yoffset")
application->setYOffset(m.getArgAsInt32(0));

if(addr == "/fx/amount/global")
application->cameras.setFxAmount(m.getArgAsInt32(0), m.getArgAsInt32(1));

Expand Down

0 comments on commit 976eccc

Please sign in to comment.