Skip to content

Commit

Permalink
added beep on randomization
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemcdonald committed Mar 9, 2012
1 parent 3abbcfb commit a72f140
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
Binary file modified FaceBeat Project/FaceBeat.als
Binary file not shown.
16 changes: 13 additions & 3 deletions FaceMusic/src/animation/animationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,24 @@ void animationManager::update() {
if (presence > 0.5){

bWasPresentLastFrame = true;
if (ofGetElapsedTimef() - lastNonPresenceTime < 1.1 && (lastNonPresenceTime-fistNonPresenceTime) > 0.3){
float pct = (ofGetElapsedTimef() - lastNonPresenceTime)/1.1;
bool didSwitch = false;
float curTime = ofGetElapsedTimef();
float clickWaitTime = .5; // wait for this much non-face until randomizing
float clickingTime = 2; // how long the randomizing lasts
float presenceLength = curTime - lastNonPresenceTime;
float nonPresenceLength = lastNonPresenceTime - fistNonPresenceTime;
if (presenceLength < clickingTime && nonPresenceLength > clickWaitTime) {
float pct = pow(ofNormalize(presenceLength, 0, clickingTime), .1f);
for (int i = 0; i < FA->nFeatures; i++){
if (ofRandom(1) > (pct)){
if (ofRandomf() > pct){
which[i] = ofRandom(0,10000000);
didSwitch = true;
}
}
}
if(didSwitch) {
Graph::sendManualNote(96);
}

for (int i = 0; i < FA->nFeatures; i++){
ofPoint offsetme;
Expand Down
5 changes: 5 additions & 0 deletions FaceMusic/src/faceAnalysis/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ void Graph::addSample(float sample) {
sendMidi();
}

void Graph::sendManualNote(int midiNote) {
midi.sendNoteOn(1, midiNote, 127);
midi.sendNoteOff(1, midiNote);
}

void Graph::sendMidi() const {
if(getTriggered()) {
midi.sendNoteOn(1, midiNote, 127);
Expand Down
2 changes: 2 additions & 0 deletions FaceMusic/src/faceAnalysis/Graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class Graph {
void keyPressed(int key);
void mouseMoved(int x, int y);

static void sendManualNote(int midiNote);

//private:
int width, height;
string name;
Expand Down
3 changes: 3 additions & 0 deletions FaceMusic/src/faceAnalysis/faceTrackerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ void faceTrackerManager::keyPressed(int key) {
if(key == '\t') {
enabled = !enabled;
}
if(key == 'c') {
Graph::sendManualNote(96);
}
if(key == 'r') {
classifier.reset();
expressionGraphs.clear();
Expand Down

0 comments on commit a72f140

Please sign in to comment.