kwave
18.07.70
|
#include <OverViewCache.h>
Classes | |
struct | MinMax |
Public Types | |
typedef QVector< MinMax > | MinMaxArray |
Signals | |
void | changed () |
Public Member Functions | |
OverViewCache (Kwave::SignalManager &signal, sample_index_t src_offset, sample_index_t src_length, const QList< unsigned int > *src_tracks) | |
virtual | ~OverViewCache () |
int | getMinMax (int width, MinMaxArray &minmax) |
virtual QImage | getOverView (int width, int height, const QColor &fg, const QColor &bg, double gain=1.0) |
Protected Types | |
enum | CacheState { Invalid = 0, Fuzzy, Valid, Unused } |
Protected Slots | |
void | slotTrackInserted (const QUuid &track_id) |
void | slotTrackDeleted (const QUuid &track_id) |
void | slotLengthChanged (sample_index_t new_length) |
void | slotInvalidated (const QUuid *track_id, sample_index_t first, sample_index_t last) |
Private Member Functions | |
void | scaleUp () |
void | scaleDown () |
void | invalidateCache (const QUuid *uuid, unsigned int first, unsigned int last) |
Private Attributes | |
Kwave::SignalManager & | m_signal |
Kwave::SelectionTracker | m_selection |
QHash< QUuid, QVector< sample_t > > | m_min |
QHash< QUuid, QVector< sample_t > > | m_max |
QHash< QUuid, QVector< CacheState > > | m_state |
MinMaxArray | m_minmax |
quint64 | m_scale |
QMutex | m_lock |
Fixed-size cache for multi-track sample data. Automatically updates itself if data has been changed, inserted or deleted. Optimized for speed!
Definition at line 50 of file OverViewCache.h.
typedef QVector<MinMax> Kwave::OverViewCache::MinMaxArray |
Definition at line 60 of file OverViewCache.h.
|
protected |
State of a cache entry
Enumerator | |
---|---|
Invalid | |
Fuzzy | |
Valid | |
Unused |
Definition at line 142 of file OverViewCache.h.
Kwave::OverViewCache::OverViewCache | ( | Kwave::SignalManager & | signal, |
sample_index_t | src_offset, | ||
sample_index_t | src_length, | ||
const QList< unsigned int > * | src_tracks | ||
) |
Constructor
signal | reference to a SignalManager with the source |
src_offset | first sample index in the source. optional, default=0 |
src_length | number of samples in the source. optional, default=0 (whole signal) |
src_tracks | list of selected source tracks optional, default=0 (whole signal) |
Definition at line 37 of file OverViewCache.cpp.
References Kwave::SelectionTracker::allTracks(), Kwave::connect(), m_selection, slotInvalidated(), slotLengthChanged(), slotTrackDeleted(), and slotTrackInserted().
|
virtual |
Destructor
Definition at line 67 of file OverViewCache.cpp.
References m_lock, m_max, m_min, and m_state.
|
signal |
emitted whenever the cache content has changed
Referenced by slotInvalidated(), slotTrackDeleted(), and slotTrackInserted().
int Kwave::OverViewCache::getMinMax | ( | int | width, |
MinMaxArray & | minmax | ||
) |
Get an array with min/max sample values
width | number of min/max entries to fill |
minmax | array that receives the minmax values |
Definition at line 258 of file OverViewCache.cpp.
References Kwave::SelectionTracker::allTracks(), Kwave::SignalManager::allTracks(), CACHE_SIZE, Kwave::MultiTrackReader::isEmpty(), Kwave::SelectionTracker::last(), Kwave::SelectionTracker::length(), m_lock, m_max, m_min, m_scale, m_selection, m_signal, m_state, Kwave::SampleReader::minMax(), Kwave::SelectionTracker::offset(), SAMPLE_MAX, SAMPLE_MIN, Kwave::SinglePassForward, Kwave::toUint(), Unused, Kwave::SignalManager::uuidOfTrack(), and Valid.
Referenced by getOverView(), and Kwave::NoiseDialog::updateDisplay().
|
virtual |
Renders an overview into a QImage.
width | the width of the bitmap in pixels |
height | the width of the bitmap in pixels |
fg | foreground color |
bg | background color |
gain | additional y scaling factor (optional, default = 1.0) |
Definition at line 371 of file OverViewCache.cpp.
References getMinMax(), m_lock, m_minmax, SAMPLE_MAX, and Kwave::toInt().
Referenced by Kwave::OverViewWidget::calculateBitmap(), Kwave::SonagramPlugin::refreshOverview(), and Kwave::VolumeDialog::updateDisplay().
|
private |
Marks a range of cache entries of a track as invalid
uuid | ID of the track to invalidate or null for "all tracks" |
first | index of the first entry |
last | index of the last entry (will be truncated to CACHE_SIZE-1) |
Definition at line 151 of file OverViewCache.cpp.
References CACHE_SIZE, Invalid, and m_state.
Referenced by scaleDown(), slotInvalidated(), and slotTrackInserted().
|
private |
Expands the cache to hold less samples per entry. As this process loses accuracy, the cache must be "polished" in a second step.
Definition at line 139 of file OverViewCache.cpp.
References CACHE_SIZE, invalidateCache(), Kwave::SelectionTracker::length(), m_scale, and m_selection.
Referenced by slotLengthChanged(), and slotTrackInserted().
|
private |
Compresses the cache to hold more samples per entry.
Definition at line 77 of file OverViewCache.cpp.
References CACHE_SIZE, Kwave::SelectionTracker::length(), m_max, m_min, m_scale, m_selection, m_state, SAMPLE_MAX, SAMPLE_MIN, Kwave::toUint(), and Unused.
Referenced by slotLengthChanged(), and slotTrackInserted().
|
protectedslot |
Connected to the selection tracker's sigInvalidated.
track_id | UUID of the track or null for "all tracks" |
first | index of the first invalidated sample |
last | index of the last invalidated sample |
Definition at line 217 of file OverViewCache.cpp.
References CACHE_SIZE, changed(), invalidateCache(), m_lock, m_scale, m_selection, Kwave::SelectionTracker::offset(), Kwave::round_up(), SAMPLE_INDEX_MAX, and Kwave::toUint().
Referenced by OverViewCache().
|
protectedslot |
Connected to the selection tracker's sigLengthChanged.
new_length | new length of the selection in samples |
Definition at line 246 of file OverViewCache.cpp.
References CACHE_SIZE, m_lock, m_scale, scaleDown(), and scaleUp().
Referenced by OverViewCache().
|
protectedslot |
Connected to the selection tracker's sigTrackInserted.
track_id | unique ID of the track |
Definition at line 205 of file OverViewCache.cpp.
References changed(), m_lock, m_max, m_min, and m_state.
Referenced by OverViewCache().
|
protectedslot |
Connected to the selection tracker's sigTrackInserted.
track_id | unique ID of the track |
Definition at line 176 of file OverViewCache.cpp.
References CACHE_SIZE, changed(), invalidateCache(), Kwave::SelectionTracker::length(), m_lock, m_max, m_min, m_scale, m_selection, m_state, SAMPLE_MAX, SAMPLE_MIN, scaleDown(), scaleUp(), and Unused.
Referenced by OverViewCache().
|
private |
mutex for threadsafe access to the cache
Definition at line 197 of file OverViewCache.h.
Referenced by getMinMax(), getOverView(), slotInvalidated(), slotLengthChanged(), slotTrackDeleted(), slotTrackInserted(), and ~OverViewCache().
|
private |
list of maximum value arrays, one array per track
Definition at line 185 of file OverViewCache.h.
Referenced by getMinMax(), scaleUp(), slotTrackDeleted(), slotTrackInserted(), and ~OverViewCache().
|
private |
list of minimum value arrays, one array per track
Definition at line 182 of file OverViewCache.h.
Referenced by getMinMax(), scaleUp(), slotTrackDeleted(), slotTrackInserted(), and ~OverViewCache().
|
private |
list of min/max pairs, cached internally for getOverView
Definition at line 191 of file OverViewCache.h.
Referenced by getOverView().
|
private |
number of samples per cache entry
Definition at line 194 of file OverViewCache.h.
Referenced by getMinMax(), scaleDown(), scaleUp(), slotInvalidated(), slotLengthChanged(), and slotTrackInserted().
|
private |
selection tracker
Definition at line 179 of file OverViewCache.h.
Referenced by getMinMax(), OverViewCache(), scaleDown(), scaleUp(), slotInvalidated(), and slotTrackInserted().
|
private |
signal with the data to be shown
Definition at line 176 of file OverViewCache.h.
Referenced by getMinMax().
|
private |
bitmask for "validity" of the min/max values
Definition at line 188 of file OverViewCache.h.
Referenced by getMinMax(), invalidateCache(), scaleUp(), slotTrackDeleted(), slotTrackInserted(), and ~OverViewCache().