Class: Live Analyzer

Overview

Performs continuous bpm and key detection. The update frequency is 2 seconds.

Warning: High memory usage! This class allocates 320 x samplerate bytes. Example: 48000 Hz x 320 = 15 MB.

How to implement

#include "SuperpoweredAnalyzer.h"
void initLiveAnalyzer() {
liveAnalyzer = new Superpowered::LiveAnalyzer(44100);
liveAnalyzer->bpm = 0;
}
void processAudio(float *interleavedInput, float *interleavedOutput, unsigned int numberOfFrames) {
liveAnalyzer->process(interleavedInput, numberOfFrames);
float bpm = liveAnalyzer->bpm;
int keyIndex = liveAnalyzer->keyIndex;
float silence = liveAnalyzer->silence;
...
}

Properties

bpm

PROPERTY

Current beats per minute. If the current result is too far from the reality you can do three things:

  1. Set bpm to zero. This forces the analyzer to "forget" the last bpm and may find the correct value within 10 seconds.
  2. Set bpm to an estimated value. This forces the analyzer to "forget" the last bpm and use your estimate instead. It may find the correct value within 4 seconds.
  3. Set bpm to a negative value. This will "hard reset" the analyzer and so it will start fresh.

TypeMinMaxDefault
float

keyIndex

PROPERTY
The dominant key (chord) of the music. 0..11 are major keys from A to G#, 12..23 are minor keys from A to G#. -1: unknown. Check the static constants in this header for musical, Camelot and Open Key notations.
TypeMinMaxDefault
int

samplerate

PROPERTY
Sample rate in Hz.
TypeMinMaxDefault
unsigned int

silence

PROPERTY
If true, bpm and key detection is paused, because the analyzer detects a longer silence period (more than 1 seconds of digital silence or 8 seconds below -48 decibels). If false, bpm and key detection is under progress.
TypeMinMaxDefault
bool

Methods

  • constructor

    METHOD
    Creates a LiveAnalyzer instance.
    Parameters
    NameTypeDefaultDescription
    samplerateunsigned intThe initial sample rate in Hz.
    Returns
    TypeDescription
    Superpowered::LiveAnalyzerThe constructed instance.
  • process

    METHOD
    Processes some audio. This method can be used in a real-time audio thread.
    Parameters
    NameTypeDefaultDescription
    inputfloat *Pointer to floating point numbers. 32-bit interleaved stereo input.
    numberOfFramesunsigned intNumber of frames to process.
    Returns
    None
Javascript

is not supported here.

v2.7.2