annotate data/fileio/FFTFuzzyAdapter.cpp @ 489:82ab61fa9223
* Reorganise our sparql queries on the basis that Redland must be
available, not only optional. So for anything querying the pool
of data about plugins, we use a single datastore and model which
is initialised at the outset by PluginRDFIndexer and then queried
directly; for anything that "reads from a file" (e.g. loading
annotations) we query directly using Rasqal, going to the
datastore when we need additional plugin-related information.
This may improve performance, but mostly it simplifies the code
and fixes a serious issue with RDF import in the previous versions
(namely that multiple sequential RDF imports would end up sharing
the same RDF data pool!)
author |
Chris Cannam |
date |
Fri, 21 Nov 2008 16:12:29 +0000 |
parents |
1a42221a1522 |
children |
e802e550a1f2 |
rev |
line source |
Chris@148
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@148
|
2
|
Chris@148
|
3 /*
|
Chris@148
|
4 Sonic Visualiser
|
Chris@148
|
5 An audio file viewer and annotation editor.
|
Chris@148
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@148
|
7 This file copyright 2006 Chris Cannam.
|
Chris@148
|
8
|
Chris@148
|
9 This program is free software; you can redistribute it and/or
|
Chris@148
|
10 modify it under the terms of the GNU General Public License as
|
Chris@148
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@148
|
12 License, or (at your option) any later version. See the file
|
Chris@148
|
13 COPYING included with this distribution for more information.
|
Chris@148
|
14 */
|
Chris@148
|
15
|
Chris@148
|
16 #include "FFTFuzzyAdapter.h"
|
Chris@148
|
17
|
Chris@148
|
18 #include <cassert>
|
Chris@148
|
19
|
Chris@148
|
20 FFTFuzzyAdapter::FFTFuzzyAdapter(const DenseTimeValueModel *model,
|
Chris@148
|
21 int channel,
|
Chris@148
|
22 WindowType windowType,
|
Chris@148
|
23 size_t windowSize,
|
Chris@148
|
24 size_t windowIncrement,
|
Chris@148
|
25 size_t fftSize,
|
Chris@148
|
26 bool polar,
|
Chris@148
|
27 size_t fillFromColumn) :
|
Chris@148
|
28 m_server(0),
|
Chris@148
|
29 m_xshift(0),
|
Chris@148
|
30 m_yshift(0)
|
Chris@148
|
31 {
|
Chris@148
|
32 m_server = FFTDataServer::getFuzzyInstance(model,
|
Chris@148
|
33 channel,
|
Chris@148
|
34 windowType,
|
Chris@148
|
35 windowSize,
|
Chris@148
|
36 windowIncrement,
|
Chris@148
|
37 fftSize,
|
Chris@148
|
38 polar,
|
Chris@148
|
39 fillFromColumn);
|
Chris@148
|
40
|
Chris@148
|
41 size_t xratio = windowIncrement / m_server->getWindowIncrement();
|
Chris@148
|
42 size_t yratio = m_server->getFFTSize() / fftSize;
|
Chris@148
|
43
|
Chris@148
|
44 while (xratio > 1) {
|
Chris@148
|
45 if (xratio & 0x1) {
|
Chris@148
|
46 std::cerr << "ERROR: FFTFuzzyAdapter: Window increment ratio "
|
Chris@148
|
47 << windowIncrement << " / "
|
Chris@148
|
48 << m_server->getWindowIncrement()
|
Chris@148
|
49 << " must be a power of two" << std::endl;
|
Chris@148
|
50 assert(!(xratio & 0x1));
|
Chris@148
|
51 }
|
Chris@148
|
52 ++m_xshift;
|
Chris@148
|
53 xratio >>= 1;
|
Chris@148
|
54 }
|
Chris@148
|
55
|
Chris@148
|
56 while (yratio > 1) {
|
Chris@148
|
57 if (yratio & 0x1) {
|
Chris@148
|
58 std::cerr << "ERROR: FFTFuzzyAdapter: FFT size ratio "
|
Chris@148
|
59 << m_server->getFFTSize() << " / " << fftSize
|
Chris@148
|
60 << " must be a power of two" << std::endl;
|
Chris@148
|
61 assert(!(yratio & 0x1));
|
Chris@148
|
62 }
|
Chris@148
|
63 ++m_yshift;
|
Chris@148
|
64 yratio >>= 1;
|
Chris@148
|
65 }
|
Chris@148
|
66 }
|
Chris@148
|
67
|
Chris@148
|
68 FFTFuzzyAdapter::~FFTFuzzyAdapter()
|
Chris@148
|
69 {
|
Chris@148
|
70 FFTDataServer::releaseInstance(m_server);
|
Chris@148
|
71 }
|
Chris@148
|
72
|