Coder Social home page Coder Social logo

sammccormick61 / ofxbeat Goto Github PK

View Code? Open in Web Editor NEW

This project forked from darrenmothersele/ofxbeat

0.0 0.0 0.0 172 KB

A simple beat detection routine for openFrameworks that gives 32 fft bands plus separate output for kick, snare, and hihat.

Home Page: http://cyrilcode.com

C++ 100.00%

ofxbeat's Introduction

ofxBeat

A simple beat detection routine for openFrameworks that gives 32 fft bands plus separate output for kick, snare, and hihat. Created for inclusion in the Cyril language for live coded visuals.

Provenance

This builds on the beat tracking code in ofxBeatTracking, which itself was based on C++ code from Dominic Mazzoni, which was based on an free FFT implementation in Fortan. Further details are in the comments here.

Usage

Install the addon as usual, then in your openFrameworks app define an instance of ofxBeat, for example:

class testApp : public ofBaseApp{

  ofxBeat beat;
  void audioReceived(float*, int, int);

  // ... rest of your app class ...
};

Then initialize the sound stream in your app setup() method, for example:

void testApp::setup(){
  ofSoundStreamSetup(0, 1, this, 44100, beat.getBufferSize(), 4);
}

Add the following method to pass on audio events to the FFT processor:

void testApp::audioReceived(float* input, int bufferSize, int nChannels) {
  beat.audioReceived(input, bufferSize, nChannels);
}

Add a call to the update method to your app's update method to perform the fft processing on recevied audio, for example:

void testApp::update() {
  beat.update(ofGetElapsedTimeMillis());
}

You can then use the separate bands to get information in the current beat graph. These methods return a value between 1 and 0. It's 1 when a beat is detected and fades away to 0 based on the detected time between beats.

float kick = beat.kick();
float snare = beat.snare();
float hihat = beat.hihat();

You can also access the raw fft bands using the following function, where i is a value between 0 and 31 (i.e. 32 fft bands indexed from 0):

float selectedBand = beat.getBand(i);

Limitations

This is a pretty basic implementation of beat detection but it is fast and gets a fairly good result.

ofxbeat's People

Contributors

darrenmothersele avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.