comparison data/fft/FFTFuzzyAdapter.cpp @ 148:1a42221a1522

* Reorganising code base. This revision will not compile.
author Chris Cannam
date Mon, 31 Jul 2006 11:49:58 +0000
parents
children
comparison
equal deleted inserted replaced
147:3a13b0d4934e 148:1a42221a1522
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
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 #include "FFTFuzzyAdapter.h"
17
18 #include <cassert>
19
20 FFTFuzzyAdapter::FFTFuzzyAdapter(const DenseTimeValueModel *model,
21 int channel,
22 WindowType windowType,
23 size_t windowSize,
24 size_t windowIncrement,
25 size_t fftSize,
26 bool polar,
27 size_t fillFromColumn) :
28 m_server(0),
29 m_xshift(0),
30 m_yshift(0)
31 {
32 m_server = FFTDataServer::getFuzzyInstance(model,
33 channel,
34 windowType,
35 windowSize,
36 windowIncrement,
37 fftSize,
38 polar,
39 fillFromColumn);
40
41 size_t xratio = windowIncrement / m_server->getWindowIncrement();
42 size_t yratio = m_server->getFFTSize() / fftSize;
43
44 while (xratio > 1) {
45 if (xratio & 0x1) {
46 std::cerr << "ERROR: FFTFuzzyAdapter: Window increment ratio "
47 << windowIncrement << " / "
48 << m_server->getWindowIncrement()
49 << " must be a power of two" << std::endl;
50 assert(!(xratio & 0x1));
51 }
52 ++m_xshift;
53 xratio >>= 1;
54 }
55
56 while (yratio > 1) {
57 if (yratio & 0x1) {
58 std::cerr << "ERROR: FFTFuzzyAdapter: FFT size ratio "
59 << m_server->getFFTSize() << " / " << fftSize
60 << " must be a power of two" << std::endl;
61 assert(!(yratio & 0x1));
62 }
63 ++m_yshift;
64 yratio >>= 1;
65 }
66 }
67
68 FFTFuzzyAdapter::~FFTFuzzyAdapter()
69 {
70 FFTDataServer::releaseInstance(m_server);
71 }
72