RealtimeAnalyser.h [plain text]
#ifndef RealtimeAnalyser_h
#define RealtimeAnalyser_h
#include "AudioArray.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
namespace WebCore {
class AudioBus;
class FFTFrame;
class RealtimeAnalyser {
WTF_MAKE_NONCOPYABLE(RealtimeAnalyser);
public:
RealtimeAnalyser();
virtual ~RealtimeAnalyser();
void reset();
size_t fftSize() const { return m_fftSize; }
void setFftSize(size_t size);
unsigned frequencyBinCount() const { return m_fftSize / 2; }
void setMinDecibels(float k) { m_minDecibels = k; }
float minDecibels() const { return static_cast<float>(m_minDecibels); }
void setMaxDecibels(float k) { m_maxDecibels = k; }
float maxDecibels() const { return static_cast<float>(m_maxDecibels); }
void setSmoothingTimeConstant(float k) { m_smoothingTimeConstant = k; }
float smoothingTimeConstant() const { return static_cast<float>(m_smoothingTimeConstant); }
#if ENABLE(WEBGL)
void getFloatFrequencyData(Float32Array*);
void getByteFrequencyData(Uint8Array*);
void getByteTimeDomainData(Uint8Array*);
#endif
void writeInput(AudioBus*, size_t framesToProcess);
static const double DefaultSmoothingTimeConstant;
static const double DefaultMinDecibels;
static const double DefaultMaxDecibels;
static const unsigned DefaultFFTSize;
static const unsigned MaxFFTSize;
static const unsigned InputBufferSize;
private:
AudioFloatArray m_inputBuffer;
unsigned m_writeIndex;
size_t m_fftSize;
OwnPtr<FFTFrame> m_analysisFrame;
void doFFTAnalysis();
AudioFloatArray m_magnitudeBuffer;
AudioFloatArray& magnitudeBuffer() { return m_magnitudeBuffer; }
double m_smoothingTimeConstant;
double m_minDecibels;
double m_maxDecibels;
};
}
#endif // RealtimeAnalyser_h