annotate data/fft/FFTCache.h @ 501:ca208281238b

...
author Chris Cannam
date Thu, 04 Dec 2008 17:15:15 +0000
parents 115f60df1e4d
children 6066bde1c126
rev   line source
Chris@152 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@152 2
Chris@152 3 /*
Chris@152 4 Sonic Visualiser
Chris@152 5 An audio file viewer and annotation editor.
Chris@152 6 Centre for Digital Music, Queen Mary, University of London.
Chris@152 7 This file copyright 2006 Chris Cannam.
Chris@152 8
Chris@152 9 This program is free software; you can redistribute it and/or
Chris@152 10 modify it under the terms of the GNU General Public License as
Chris@152 11 published by the Free Software Foundation; either version 2 of the
Chris@152 12 License, or (at your option) any later version. See the file
Chris@152 13 COPYING included with this distribution for more information.
Chris@152 14 */
Chris@152 15
Chris@152 16 #ifndef _FFT_CACHE_H_
Chris@152 17 #define _FFT_CACHE_H_
Chris@152 18
Chris@152 19 #include <cstdlib>
Chris@152 20 #include <cmath>
Chris@152 21
Chris@152 22 #include <stdint.h>
Chris@152 23
Chris@152 24 class FFTCache
Chris@152 25 {
Chris@152 26 public:
Chris@152 27 virtual ~FFTCache() { }
Chris@152 28
Chris@152 29 virtual size_t getWidth() const = 0;
Chris@152 30 virtual size_t getHeight() const = 0;
Chris@152 31
Chris@152 32 virtual void resize(size_t width, size_t height) = 0;
Chris@152 33 virtual void reset() = 0; // zero-fill or 1-fill as appropriate without changing size
Chris@152 34
Chris@152 35 virtual float getMagnitudeAt(size_t x, size_t y) const = 0;
Chris@152 36 virtual float getNormalizedMagnitudeAt(size_t x, size_t y) const = 0;
Chris@152 37 virtual float getMaximumMagnitudeAt(size_t x) const = 0;
Chris@152 38 virtual float getPhaseAt(size_t x, size_t y) const = 0;
Chris@152 39
Chris@152 40 virtual void getValuesAt(size_t x, size_t y, float &real, float &imaginary) const = 0;
Chris@152 41
Chris@152 42 virtual bool haveSetColumnAt(size_t x) const = 0;
Chris@152 43
Chris@152 44 // may modify argument arrays
Chris@152 45 virtual void setColumnAt(size_t x, float *mags, float *phases, float factor) = 0;
Chris@152 46
Chris@152 47 // may modify argument arrays
Chris@152 48 virtual void setColumnAt(size_t x, float *reals, float *imags) = 0;
Chris@152 49
Chris@152 50 virtual void suspend() { }
Chris@152 51
Chris@408 52 enum StorageType {
Chris@408 53 Compact, // 16 bits normalized polar
Chris@408 54 Rectangular, // floating point real+imag
Chris@408 55 Polar // floating point mag+phase
Chris@408 56 };
Chris@408 57 virtual StorageType getStorageType() = 0;
Chris@408 58
Chris@359 59 enum Type { MemoryCache, FileCache };
Chris@359 60 virtual Type getType() = 0;
Chris@359 61
Chris@152 62 protected:
Chris@152 63 FFTCache() { }
Chris@152 64 };
Chris@152 65
Chris@152 66
Chris@152 67 #endif