annotate data/fileio/FFTFuzzyAdapter.h @ 674:920e3880f7b4

* Add TempWriteFile abstraction, use it when exporting audio to avoid clobbering existing file before export is complete
author Chris Cannam
date Tue, 29 Mar 2011 17:30:23 +0100
parents 1a42221a1522
children 59e7fe1b1003
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 #ifndef _FFT_FUZZY_ADAPTER_H_
Chris@148 17 #define _FFT_FUZZY_ADAPTER_H_
Chris@148 18
Chris@148 19 #include "FFTDataServer.h"
Chris@148 20
Chris@148 21 class FFTFuzzyAdapter
Chris@148 22 {
Chris@148 23 public:
Chris@148 24 FFTFuzzyAdapter(const DenseTimeValueModel *model,
Chris@148 25 int channel,
Chris@148 26 WindowType windowType,
Chris@148 27 size_t windowSize,
Chris@148 28 size_t windowIncrement,
Chris@148 29 size_t fftSize,
Chris@148 30 bool polar,
Chris@148 31 size_t fillFromColumn = 0);
Chris@148 32 ~FFTFuzzyAdapter();
Chris@148 33
Chris@148 34 size_t getWidth() const {
Chris@148 35 return m_server->getWidth() >> m_xshift;
Chris@148 36 }
Chris@148 37 size_t getHeight() const {
Chris@148 38 return m_server->getHeight() >> m_yshift;
Chris@148 39 }
Chris@148 40 float getMagnitudeAt(size_t x, size_t y) {
Chris@148 41 return m_server->getMagnitudeAt(x << m_xshift, y << m_yshift);
Chris@148 42 }
Chris@148 43 float getNormalizedMagnitudeAt(size_t x, size_t y) {
Chris@148 44 return m_server->getNormalizedMagnitudeAt(x << m_xshift, y << m_yshift);
Chris@148 45 }
Chris@148 46 float getMaximumMagnitudeAt(size_t x) {
Chris@148 47 return m_server->getMaximumMagnitudeAt(x << m_xshift);
Chris@148 48 }
Chris@148 49 float getPhaseAt(size_t x, size_t y) {
Chris@148 50 return m_server->getPhaseAt(x << m_xshift, y << m_yshift);
Chris@148 51 }
Chris@148 52 void getValuesAt(size_t x, size_t y, float &real, float &imaginary) {
Chris@148 53 m_server->getValuesAt(x << m_xshift, y << m_yshift, real, imaginary);
Chris@148 54 }
Chris@148 55 bool isColumnReady(size_t x) {
Chris@148 56 return m_server->isColumnReady(x << m_xshift);
Chris@148 57 }
Chris@148 58 bool isLocalPeak(size_t x, size_t y) {
Chris@148 59 float mag = getMagnitudeAt(x, y);
Chris@148 60 if (y > 0 && mag < getMagnitudeAt(x, y - 1)) return false;
Chris@148 61 if (y < getHeight() - 1 && mag < getMagnitudeAt(x, y + 1)) return false;
Chris@148 62 return true;
Chris@148 63 }
Chris@148 64 bool isOverThreshold(size_t x, size_t y, float threshold) {
Chris@148 65 return getMagnitudeAt(x, y) > threshold;
Chris@148 66 }
Chris@148 67
Chris@148 68 size_t getFillCompletion() const { return m_server->getFillCompletion(); }
Chris@148 69 size_t getFillExtent() const { return m_server->getFillExtent(); }
Chris@148 70
Chris@148 71 private:
Chris@148 72 FFTFuzzyAdapter(const FFTFuzzyAdapter &); // not implemented
Chris@148 73 FFTFuzzyAdapter &operator=(const FFTFuzzyAdapter &); // not implemented
Chris@148 74
Chris@148 75 FFTDataServer *m_server;
Chris@148 76 int m_xshift;
Chris@148 77 int m_yshift;
Chris@148 78 };
Chris@148 79
Chris@148 80 #endif