annotate data/fileio/FFTFuzzyAdapter.cpp @ 998:e25dc8d57565

Add descriptions for writers; add housekeeping options to Sonic Annotator to list writers and formats
author Chris Cannam
date Mon, 13 Oct 2014 14:44:51 +0100
parents 59e7fe1b1003
children
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@929 23 int windowSize,
Chris@929 24 int windowIncrement,
Chris@929 25 int fftSize,
Chris@148 26 bool polar,
Chris@929 27 int 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@929 41 int xratio = windowIncrement / m_server->getWindowIncrement();
Chris@929 42 int yratio = m_server->getFFTSize() / fftSize;
Chris@148 43
Chris@148 44 while (xratio > 1) {
Chris@148 45 if (xratio & 0x1) {
Chris@843 46 cerr << "ERROR: FFTFuzzyAdapter: Window increment ratio "
Chris@148 47 << windowIncrement << " / "
Chris@148 48 << m_server->getWindowIncrement()
Chris@843 49 << " must be a power of two" << 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@843 58 cerr << "ERROR: FFTFuzzyAdapter: FFT size ratio "
Chris@148 59 << m_server->getFFTSize() << " / " << fftSize
Chris@843 60 << " must be a power of two" << 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