c@116
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@116
|
2 /*
|
c@116
|
3 Constant-Q library
|
c@116
|
4 Copyright (c) 2013-2014 Queen Mary, University of London
|
c@116
|
5
|
c@116
|
6 Permission is hereby granted, free of charge, to any person
|
c@116
|
7 obtaining a copy of this software and associated documentation
|
c@116
|
8 files (the "Software"), to deal in the Software without
|
c@116
|
9 restriction, including without limitation the rights to use, copy,
|
c@116
|
10 modify, merge, publish, distribute, sublicense, and/or sell copies
|
c@116
|
11 of the Software, and to permit persons to whom the Software is
|
c@116
|
12 furnished to do so, subject to the following conditions:
|
c@116
|
13
|
c@116
|
14 The above copyright notice and this permission notice shall be
|
c@116
|
15 included in all copies or substantial portions of the Software.
|
c@116
|
16
|
c@116
|
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
c@116
|
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
c@116
|
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
c@116
|
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
c@116
|
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
c@116
|
22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
c@116
|
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
c@116
|
24
|
c@116
|
25 Except as contained in this notice, the names of the Centre for
|
c@116
|
26 Digital Music; Queen Mary, University of London; and Chris Cannam
|
c@116
|
27 shall not be used in advertising or otherwise to promote the sale,
|
c@116
|
28 use or other dealings in this Software without prior written
|
c@116
|
29 authorization.
|
c@116
|
30 */
|
c@116
|
31
|
c@116
|
32 #ifndef CQSPECTROGRAM_H
|
c@116
|
33 #define CQSPECTROGRAM_H
|
c@116
|
34
|
c@116
|
35 #include "ConstantQ.h"
|
c@116
|
36
|
c@116
|
37 class CQSpectrogram : public CQBase
|
c@116
|
38 {
|
c@116
|
39 public:
|
c@116
|
40 enum Interpolation {
|
c@116
|
41 InterpolateZeros, // leave empty cells as zero
|
c@116
|
42 InterpolateHold, // repeat prior cell
|
c@116
|
43 InterpolateLinear, // linear interpolation between consecutive time cells
|
c@116
|
44 };
|
c@116
|
45
|
c@127
|
46 CQSpectrogram(CQParameters params, Interpolation interpolation);
|
c@116
|
47 virtual ~CQSpectrogram();
|
c@116
|
48
|
c@116
|
49 virtual double getSampleRate() const { return m_cq.getSampleRate(); }
|
c@116
|
50 virtual int getBinsPerOctave() const { return m_cq.getBinsPerOctave(); }
|
c@116
|
51 virtual int getOctaves() const { return m_cq.getOctaves(); }
|
c@116
|
52 virtual int getTotalBins() const { return m_cq.getTotalBins(); }
|
c@116
|
53 virtual int getColumnHop() const { return m_cq.getColumnHop(); }
|
c@116
|
54 virtual int getLatency() const { return m_cq.getLatency(); }
|
c@116
|
55 virtual double getMaxFrequency() const { return m_cq.getMaxFrequency(); }
|
c@116
|
56 virtual double getMinFrequency() const { return m_cq.getMinFrequency(); }
|
c@116
|
57 virtual double getBinFrequency(int bin) const { return m_cq.getBinFrequency(bin); }
|
c@116
|
58
|
c@116
|
59 RealBlock process(const RealSequence &);
|
c@116
|
60 RealBlock getRemainingOutput();
|
c@116
|
61
|
c@116
|
62 private:
|
c@116
|
63 ConstantQ m_cq;
|
c@116
|
64 Interpolation m_interpolation;
|
c@116
|
65
|
c@116
|
66 RealBlock m_buffer;
|
c@116
|
67 RealBlock postProcess(const ComplexBlock &, bool insist);
|
c@116
|
68 RealBlock fetchHold(bool insist);
|
c@116
|
69 RealBlock fetchLinear(bool insist);
|
c@116
|
70 RealBlock linearInterpolated(const RealBlock &, int, int);
|
c@116
|
71 RealColumn m_prevColumn;
|
c@116
|
72 };
|
c@116
|
73
|
c@116
|
74 #endif
|