update qm-dsp library
[ardour.git] / libs / qm-dsp / dsp / signalconditioning / DFProcess.h
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     Modifications:
10
11     - delta threshold
12     Description: add delta threshold used as offset in the smoothed
13     detection function
14     Author: Mathieu Barthet
15     Date: June 2010
16
17     This program is free software; you can redistribute it and/or
18     modify it under the terms of the GNU General Public License as
19     published by the Free Software Foundation; either version 2 of the
20     License, or (at your option) any later version.  See the file
21     COPYING included with this distribution for more information.
22 */
23
24 #ifndef CDFPROCESS_H
25 #define CDFPROCESS_H
26
27 #include <stdio.h>
28 #include "FiltFilt.h"
29
30 struct DFProcConfig{
31     unsigned int length; 
32     unsigned int LPOrd; 
33     double *LPACoeffs; 
34     double *LPBCoeffs; 
35     unsigned int winPre;
36     unsigned int winPost; 
37     double AlphaNormParam;
38     bool isMedianPositive;
39     float delta; //delta threshold used as an offset when computing the smoothed detection function
40
41     DFProcConfig() :
42         length(0),
43         LPOrd(0),
44         LPACoeffs(NULL),
45         LPBCoeffs(NULL),
46         winPre(0),
47         winPost(0),
48         AlphaNormParam(0),
49         isMedianPositive(false),
50         delta(0)
51     {
52     }
53 };
54
55 class DFProcess  
56 {
57 public:
58     DFProcess( DFProcConfig Config );
59     virtual ~DFProcess();
60
61     void process( double* src, double* dst );
62
63         
64 private:
65     void initialise( DFProcConfig Config );
66     void deInitialise();
67     void removeDCNormalize( double *src, double*dst );
68     void medianFilter( double* src, double* dst );
69
70     int m_length;
71     int m_FFOrd;
72
73     int m_winPre;
74     int m_winPost;
75
76     double m_alphaNormParam;
77
78     double* filtSrc;
79     double* filtDst;
80
81     double* m_filtScratchIn;
82     double* m_filtScratchOut;
83
84     FilterConfig m_FilterConfigParams;
85
86     FiltFilt* m_FiltFilt;
87
88     bool m_isMedianPositive;
89     float m_delta; //add delta threshold
90 };
91
92 #endif