comparison base/MatrixFileCache.h @ 87:7de62a884810

* Start factoring out the spectrogram's FFT cache into a separate set of classes that will permit a choice of disk or memory cache strategies
author Chris Cannam
date Tue, 02 May 2006 12:27:41 +0000
parents
children c4e163f911dd
comparison
equal deleted inserted replaced
86:e076e676439b 87:7de62a884810
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 Chris Cannam.
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 _MATRIX_FILE_CACHE_H_
17 #define _MATRIX_FILE_CACHE_H_
18
19 #include <sys/types.h>
20 #include <QString>
21
22 // This class is _not_ thread safe. Each instance must only be used
23 // within a single thread. You may however have as many instances as
24 // you like referring to the same file in separate threads.
25
26 class MatrixFileCache
27 {
28 public:
29 enum Mode { ReadOnly, ReadWrite };
30
31 MatrixFileCache(QString fileBase, Mode mode);
32 virtual ~MatrixFileCache();
33
34 size_t getWidth() const;
35 size_t getHeight() const;
36
37 void resize(size_t width, size_t height);
38 void reset();
39
40 void setRangeOfInterest(size_t x, size_t width);
41
42 float getValueAt(size_t x, size_t y) const;
43 void getColumnAt(size_t x, float *values) const;
44 // float getColumnMaximum(size_t x) const;
45 // float getColumnMinimum(size_t x) const;
46
47 void setValueAt(size_t x, size_t y, float value);
48 void setColumnAt(size_t x, float *values);
49
50 protected:
51 int m_fd;
52 Mode m_mode;
53 size_t m_width;
54 size_t m_height;
55 size_t m_rx;
56 size_t m_rw;
57 float **m_range;
58 size_t m_headerSize;
59
60 mutable off_t m_off;
61
62 bool seekTo(size_t x, size_t y) const;
63 };
64
65 #endif
66