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
PROPERTYCurrent beats per minute. If the current result is too far from the reality you can do three things:
- Set bpm to zero. This forces the analyzer to "forget" the last bpm and may find the correct value within 10 seconds.
- 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.
- Set bpm to a negative value. This will "hard reset" the analyzer and so it will start fresh.
Type | Min | Max | Default | float |
---|
keyIndex
PROPERTYThe 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.
Type | Min | Max | Default | int |
---|
samplerate
PROPERTYSample rate in Hz.
Type | Min | Max | Default | unsigned int |
---|
silence
PROPERTYIf 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.
Type | Min | Max | Default | bool |
---|
Methods
constructor
METHODCreates a LiveAnalyzer instance.ParametersReturnsName Type Default Description samplerate unsigned int
The initial sample rate in Hz. Type Description Superpowered::LiveAnalyzer
The constructed instance. process
METHODProcesses some audio. This method can be used in a real-time audio thread.ParametersReturnsName Type Default Description input float *
Pointer to floating point numbers. 32-bit interleaved stereo input. numberOfFrames unsigned int
Number of frames to process. None
is not supported here.