qm-dsp 1.8
DetectionFunction.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3/*
4 QM DSP Library
5
6 Centre for Digital Music, Queen Mary, University of London.
7 This file 2005-2006 Christian Landone.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14*/
15
16#ifndef DETECTIONFUNCTION_H
17#define DETECTIONFUNCTION_H
18
19#include "maths/MathUtilities.h"
20#include "maths/MathAliases.h"
22#include "base/Window.h"
23
24#define DF_HFC (1)
25#define DF_SPECDIFF (2)
26#define DF_PHASEDEV (3)
27#define DF_COMPLEXSD (4)
28#define DF_BROADBAND (5)
29
30struct DFConfig{
31 unsigned int stepSize; // DF step in samples
32 unsigned int frameLength; // DF analysis window - usually 2*step. Must be even!
33 int DFType; // type of detection function ( see defines )
34 double dbRise; // only used for broadband df (and required for it)
35 bool adaptiveWhitening; // perform adaptive whitening
36 double whiteningRelaxCoeff; // if < 0, a sensible default will be used
37 double whiteningFloor; // if < 0, a sensible default will be used
38};
39
41{
42public:
43 double* getSpectrumMagnitude();
45 virtual ~DetectionFunction();
46
51 double processTimeDomain(const double* samples);
52
57 double processFrequencyDomain(const double* reals, const double* imags);
58
59private:
60 void whiten();
61 double runDF();
62
63 double HFC( unsigned int length, double* src);
64 double specDiff( unsigned int length, double* src);
65 double phaseDev(unsigned int length, double *srcPhase);
66 double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase);
67 double broadband(unsigned int length, double *srcMagnitude);
68
69private:
70 void initialise( DFConfig Config );
71 void deInitialise();
72
74 unsigned int m_dataLength;
75 unsigned int m_halfLength;
76 unsigned int m_stepSize;
77 double m_dbRise;
81
82 double* m_magHistory;
85 double* m_magPeaks;
86
87 double* m_windowed; // Array for windowed analysis frame
88 double* m_magnitude; // Magnitude of analysis frame ( frequency domain )
89 double* m_thetaAngle;// Phase of analysis frame ( frequency domain )
90 double* m_unwrapped; // Unwrapped phase of analysis frame
91
93 PhaseVocoder* m_phaseVoc; // Phase Vocoder
94};
95
96#endif
unsigned int m_stepSize
PhaseVocoder * m_phaseVoc
unsigned int m_dataLength
double broadband(unsigned int length, double *srcMagnitude)
Window< double > * m_window
double complexSD(unsigned int length, double *srcMagnitude, double *srcPhase)
unsigned int m_halfLength
double specDiff(unsigned int length, double *src)
double phaseDev(unsigned int length, double *srcPhase)
void initialise(DFConfig Config)
double processFrequencyDomain(const double *reals, const double *imags)
Process a single frequency-domain frame, provided as frameLength/2+1 real and imaginary component val...
double HFC(unsigned int length, double *src)
double processTimeDomain(const double *samples)
Process a single time-domain frame of audio, provided as frameLength samples.
Various shaped windows for sample frame conditioning, including cosine windows (Hann etc) and triangu...
Definition Window.h:41
double whiteningRelaxCoeff
unsigned int stepSize
bool adaptiveWhitening
double whiteningFloor
unsigned int frameLength