svcore
1.9
|
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 #ifndef _FFT_FUZZY_ADAPTER_H_ 00017 #define _FFT_FUZZY_ADAPTER_H_ 00018 00019 #include "FFTDataServer.h" 00020 00021 class FFTFuzzyAdapter 00022 { 00023 public: 00024 FFTFuzzyAdapter(const DenseTimeValueModel *model, 00025 int channel, 00026 WindowType windowType, 00027 int windowSize, 00028 int windowIncrement, 00029 int fftSize, 00030 bool polar, 00031 int fillFromColumn = 0); 00032 ~FFTFuzzyAdapter(); 00033 00034 int getWidth() const { 00035 return m_server->getWidth() >> m_xshift; 00036 } 00037 int getHeight() const { 00038 return m_server->getHeight() >> m_yshift; 00039 } 00040 float getMagnitudeAt(int x, int y) { 00041 return m_server->getMagnitudeAt(x << m_xshift, y << m_yshift); 00042 } 00043 float getNormalizedMagnitudeAt(int x, int y) { 00044 return m_server->getNormalizedMagnitudeAt(x << m_xshift, y << m_yshift); 00045 } 00046 float getMaximumMagnitudeAt(int x) { 00047 return m_server->getMaximumMagnitudeAt(x << m_xshift); 00048 } 00049 float getPhaseAt(int x, int y) { 00050 return m_server->getPhaseAt(x << m_xshift, y << m_yshift); 00051 } 00052 void getValuesAt(int x, int y, float &real, float &imaginary) { 00053 m_server->getValuesAt(x << m_xshift, y << m_yshift, real, imaginary); 00054 } 00055 bool isColumnReady(int x) { 00056 return m_server->isColumnReady(x << m_xshift); 00057 } 00058 bool isLocalPeak(int x, int y) { 00059 float mag = getMagnitudeAt(x, y); 00060 if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false; 00061 if (y < getHeight() - 1 && mag < getMagnitudeAt(x, y + 1)) return false; 00062 return true; 00063 } 00064 bool isOverThreshold(int x, int y, float threshold) { 00065 return getMagnitudeAt(x, y) > threshold; 00066 } 00067 00068 int getFillCompletion() const { return m_server->getFillCompletion(); } 00069 int getFillExtent() const { return m_server->getFillExtent(); } 00070 00071 private: 00072 FFTFuzzyAdapter(const FFTFuzzyAdapter &); // not implemented 00073 FFTFuzzyAdapter &operator=(const FFTFuzzyAdapter &); // not implemented 00074 00075 FFTDataServer *m_server; 00076 int m_xshift; 00077 int m_yshift; 00078 }; 00079 00080 #endif