FFTFuzzyAdapter.cpp

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #include "FFTFuzzyAdapter.h"
00017 
00018 #include <cassert>
00019 
00020 FFTFuzzyAdapter::FFTFuzzyAdapter(const DenseTimeValueModel *model,
00021                                  int channel,
00022                                  WindowType windowType,
00023                                  size_t windowSize,
00024                                  size_t windowIncrement,
00025                                  size_t fftSize,
00026                                  bool polar,
00027                                  size_t fillFromColumn) :
00028     m_server(0),
00029     m_xshift(0),
00030     m_yshift(0)
00031 {
00032     m_server = FFTDataServer::getFuzzyInstance(model,
00033                                                channel,
00034                                                windowType,
00035                                                windowSize,
00036                                                windowIncrement,
00037                                                fftSize,
00038                                                polar,
00039                                                fillFromColumn);
00040 
00041     size_t xratio = windowIncrement / m_server->getWindowIncrement();
00042     size_t yratio = m_server->getFFTSize() / fftSize;
00043 
00044     while (xratio > 1) {
00045         if (xratio & 0x1) {
00046             std::cerr << "ERROR: FFTFuzzyAdapter: Window increment ratio "
00047                       << windowIncrement << " / "
00048                       << m_server->getWindowIncrement()
00049                       << " must be a power of two" << std::endl;
00050             assert(!(xratio & 0x1));
00051         }
00052         ++m_xshift;
00053         xratio >>= 1;
00054     }
00055 
00056     while (yratio > 1) {
00057         if (yratio & 0x1) {
00058             std::cerr << "ERROR: FFTFuzzyAdapter: FFT size ratio "
00059                       << m_server->getFFTSize() << " / " << fftSize
00060                       << " must be a power of two" << std::endl;
00061             assert(!(yratio & 0x1));
00062         }
00063         ++m_yshift;
00064         yratio >>= 1;
00065     }
00066 }
00067 
00068 FFTFuzzyAdapter::~FFTFuzzyAdapter()
00069 {
00070     FFTDataServer::releaseInstance(m_server);
00071 }
00072 

Generated on Wed Feb 20 15:45:25 2008 for SonicVisualiser by  doxygen 1.5.1