svcore  1.9
FFTFileCacheWriter.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006-2009 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _FFT_FILE_CACHE_WRITER_H_
17 #define _FFT_FILE_CACHE_WRITER_H_
18 
19 #include "FFTCacheStorageType.h"
20 #include "FFTCacheWriter.h"
21 #include "data/fileio/MatrixFile.h"
22 
24 {
25 public:
26  FFTFileCacheWriter(QString fileBase,
27  FFTCache::StorageType storageType,
28  int width, int height);
30 
31  int getWidth() const;
32  int getHeight() const;
33 
34  void setColumnAt(int x, float *mags, float *phases, float factor);
35  void setColumnAt(int x, float *reals, float *imags);
36 
37  static int getCacheSize(int width, int height,
39 
40  bool haveSetColumnAt(int x) const;
41 
42  void allColumnsWritten();
43 
44  QString getFileBase() const;
46 
47 protected:
48  char *m_writebuf;
49 
50  void setNormalizationFactorToWritebuf(float newfactor) {
51  int h = m_mfc->getHeight();
52  if (h < m_factorSize) return;
54  ((float *)m_writebuf)[h - 1] = newfactor;
55  } else {
56  union {
57  float f;
58  uint16_t u[2];
59  } factor;
60  factor.f = newfactor;
61  ((uint16_t *)m_writebuf)[h - 2] = factor.u[0];
62  ((uint16_t *)m_writebuf)[h - 1] = factor.u[1];
63  }
64  }
65 
66  QString m_fileBase;
70 };
71 
72 #endif
FFTFileCacheWriter(QString fileBase, FFTCache::StorageType storageType, int width, int height)
QString getFileBase() const
FFTCache::StorageType getStorageType() const
int getHeight() const
Definition: MatrixFile.h:68
void setColumnAt(int x, float *mags, float *phases, float factor)
bool haveSetColumnAt(int x) const
FFTCache::StorageType m_storageType
void setNormalizationFactorToWritebuf(float newfactor)
static int getCacheSize(int width, int height, FFTCache::StorageType type)