merge with master
authorPaul Brossier <piem@piem.org>
Tue, 19 Jan 2016 15:54:26 +0000 (16:54 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 19 Jan 2016 15:54:26 +0000 (16:54 +0100)
1  2 
example_aubioDemo/src/ofApp.cpp
example_aubioDemo/src/ofApp.h
src/ofxAubioBeat.cpp
src/ofxAubioBeat.h

@@@ -84,23 -86,17 +88,22 @@@ void ofApp::update()
  //--------------------------------------------------------------
  void ofApp::draw(){
      // update beat info
-     if (beat.received()) {
+     if (gotBeat) {
          ofSetColor(ofColor::green);
          ofRect(90,150,50,50);
+         gotBeat = false;
      }
 +    if (beat.toSendTatum) {
 +        ofSetColor(ofColor::limeGreen);
 +        ofRect(140,150,25,25);
 +        beat.toSendTatum = false;
 +    }
  
      // update onset info
-     if (onset.received()) {
+     if (gotOnset) {
          ofSetColor(ofColor::red);
          ofRect(250 + 90,150,50,50);
-         gotOnset = 1;
-     } else {
-         gotOnset = 0;
+         gotOnset = false;
      }
      onsetNovelty = onset.novelty;
      onsetThresholdedNovelty = onset.thresholdedNovelty;
@@@ -37,7 -40,7 +40,8 @@@ class ofApp : public ofBaseApp
          ofxFloatSlider pitchConfidence;
  
          ofxPanel beatGui;
+         bool gotBeat;
 +        ofxIntSlider bpm_tatumSignature;
          ofxFloatSlider bpm;
  
          ofxPanel onsetGui;
@@@ -56,17 -59,9 +59,19 @@@ void ofxAubioBeat::blockAudioIn(
      aubio_tempo_do(tempo, aubio_input, aubio_output);
      if (aubio_output->data[0]) {
          //ofLogNotice() << "found beat: " << aubio_output->data[0];
-         toSend = true;
          bpm = aubio_tempo_get_bpm(tempo);
+         float last_beat = aubio_tempo_get_last_s(tempo);
+         ofNotifyEvent(gotBeat, last_beat, this);
+         ofNotifyEvent(gotGlobalBeat, last_beat);
      }
 +    if (aubio_tempo_was_tatum(tempo) == 1) {
 +        toSendTatum = true;
 +    }
 +}
 +
 +void ofxAubioBeat::setTatumSignature(unsigned tatumSignature)
 +{
 +    if (aubio_tempo_set_tatum_signature(tempo, tatumSignature)) {
 +        tatum_signature = tatumSignature;
 +    }
  }
Simple merge