kwave
18.07.70
|
#include <Stripe.h>
Classes | |
class | List |
class | MappedArray |
class | StripeStorage |
Public Member Functions | |
Stripe () | |
Stripe (const Stripe &other) | |
Stripe (sample_index_t start) | |
Stripe (sample_index_t start, const Kwave::SampleArray &samples) | |
Stripe (sample_index_t start, Stripe &stripe, unsigned int offset) | |
virtual | ~Stripe () |
sample_index_t | start () const |
void | setStart (sample_index_t start) |
unsigned int | length () const |
sample_index_t | end () const |
unsigned int | resize (unsigned int length, bool initialize=true) |
unsigned int | append (const Kwave::SampleArray &samples, unsigned int offset, unsigned int count) |
void | deleteRange (unsigned int offset, unsigned int length) |
void | overwrite (unsigned int offset, const Kwave::SampleArray &source, unsigned int srcoff, unsigned int srclen) |
bool | combine (unsigned int offset, Kwave::Stripe &other) |
unsigned int | read (Kwave::SampleArray &buffer, unsigned int dstoff, unsigned int offset, unsigned int length) |
void | minMax (unsigned int first, unsigned int last, sample_t &min, sample_t &max) |
Stripe & | operator<< (const Kwave::SampleArray &samples) |
bool | operator== (const Stripe &other) const |
Stripe & | operator= (const Stripe &other) |
Private Member Functions | |
unsigned int | resizeStorage (unsigned int length) |
sample_t * | mapStorage () |
void | unmapStorage () |
Private Attributes | |
QMutex | m_lock |
QExplicitlySharedDataPointer< StripeStorage > | m_data |
Kwave::Stripe::Stripe | ( | ) |
Default constructor. Creates an empty stripe with zero-length.
Definition at line 204 of file Stripe.cpp.
Kwave::Stripe::Stripe | ( | const Stripe & | other | ) |
Kwave::Stripe::Stripe | ( | sample_index_t | start | ) |
Constructor. Creates a new zero-length stripe.
start | position within the track |
Definition at line 217 of file Stripe.cpp.
References m_data, and start().
Kwave::Stripe::Stripe | ( | sample_index_t | start, |
const Kwave::SampleArray & | samples | ||
) |
Constructor. Creates a stripe that already contains samples, copied from a buffer with samples.
start | position within the track |
samples | array with initial samples |
Definition at line 224 of file Stripe.cpp.
References append(), m_data, Kwave::SampleArray::size(), and start().
Kwave::Stripe::Stripe | ( | sample_index_t | start, |
Kwave::Stripe & | stripe, | ||
unsigned int | offset | ||
) |
Constructor. Creates a stripe that already contains samples, copied from another stripe with offset.
start | position within the track |
stripe | source stripe to copy from |
offset | offset within the source stripe |
Definition at line 232 of file Stripe.cpp.
References Kwave::SampleArray::data(), length(), m_data, read(), resize(), resizeStorage(), and start().
|
virtual |
unsigned int Kwave::Stripe::append | ( | const Kwave::SampleArray & | samples, |
unsigned int | offset, | ||
unsigned int | count | ||
) |
Appends an array of samples to the end of the stripe.
samples | array with the samples |
offset | the offset within the array |
count | number of samples in the array |
Definition at line 381 of file Stripe.cpp.
References Kwave::MemoryManager::instance(), m_data, m_lock, resizeStorage(), Kwave::SampleArray::size(), and Kwave::MemoryManager::writeTo().
Referenced by Kwave::Track::appendAfter(), operator<<(), and Stripe().
bool Kwave::Stripe::combine | ( | unsigned int | offset, |
Kwave::Stripe & | other | ||
) |
Combine this stripe with another stripe
offset | the offset within this stripe to put the other stripe |
other | reference to another stripe |
Definition at line 457 of file Stripe.cpp.
References Kwave::SampleArray::constData(), Kwave::SampleArray::data(), length(), m_data, m_lock, MEMCPY, resizeStorage(), and Kwave::SampleArray::size().
Referenced by Kwave::Track::defragment().
void Kwave::Stripe::deleteRange | ( | unsigned int | offset, |
unsigned int | length | ||
) |
Deletes a range of samples
offset | index of the first sample, relative to the start of the stripe [0...length()-1] |
length | number of samples |
Definition at line 414 of file Stripe.cpp.
References Kwave::Stripe::MappedArray::copy(), m_data, m_lock, and resizeStorage().
Referenced by Kwave::Track::stripes(), and Kwave::Track::unlockedDelete().
sample_index_t Kwave::Stripe::end | ( | ) | const |
Returns the position of the last sample of the stripe, same as (start() + length() ? (length() - 1))
Definition at line 282 of file Stripe.cpp.
References m_data.
Referenced by Kwave::Track::appendAfter(), Kwave::Track::defragment(), Kwave::Track::dump(), Kwave::Track::insertSpace(), Kwave::Track::mergeStripe(), Kwave::SampleReader::minMax(), operator==(), Kwave::SampleReader::readSamples(), Kwave::DebugPlugin::run(), Kwave::Track::stripes(), Kwave::Track::unlockedDelete(), and Kwave::Track::writeSamples().
unsigned int Kwave::Stripe::length | ( | ) | const |
Returns the current length of the stripe in samples.
Definition at line 276 of file Stripe.cpp.
References m_data.
Referenced by Kwave::Track::appendAfter(), combine(), Kwave::Track::defragment(), Kwave::Track::dump(), Kwave::Track::insertSpace(), Kwave::SampleReader::minMax(), Kwave::Stripe::MappedArray::read(), Kwave::SampleReader::readSamples(), resize(), resizeStorage(), Kwave::Track::splitStripe(), Stripe(), Kwave::Track::stripes(), Kwave::Track::Track(), Kwave::Track::unlockedDelete(), Kwave::Track::unlockedLength(), and Kwave::Track::writeSamples().
|
private |
maps the storage into memory
Definition at line 601 of file Stripe.cpp.
References m_data.
Referenced by Kwave::Stripe::MappedArray::MappedArray().
void Kwave::Stripe::minMax | ( | unsigned int | first, |
unsigned int | last, | ||
sample_t & | min, | ||
sample_t & | max | ||
) |
Returns the minimum and maximum sample value within a range of samples.
first | index of the first sample |
last | index of the last sample |
min | receives the lowest value (must be initialized) |
max | receives the highest value (must be initialized) |
Definition at line 537 of file Stripe.cpp.
References Kwave::SampleArray::constData(), m_data, and m_lock.
Referenced by Kwave::SampleReader::minMax().
Kwave::Stripe & Kwave::Stripe::operator<< | ( | const Kwave::SampleArray & | samples | ) |
Operator for appending an array of samples to the end of the stripe.
Definition at line 577 of file Stripe.cpp.
References append(), and Kwave::SampleArray::size().
Kwave::Stripe & Kwave::Stripe::operator= | ( | const Stripe & | other | ) |
bool Kwave::Stripe::operator== | ( | const Stripe & | other | ) | const |
compare operator
Definition at line 587 of file Stripe.cpp.
References end(), and start().
void Kwave::Stripe::overwrite | ( | unsigned int | offset, |
const Kwave::SampleArray & | source, | ||
unsigned int | srcoff, | ||
unsigned int | srclen | ||
) |
Copies the content of an array of samples into the stripe.
offset | the offset within the stripe (target) |
source | array of samples to be copied |
srcoff | offset within the source array |
srclen | length of the data in the source array |
Definition at line 487 of file Stripe.cpp.
References Kwave::MemoryManager::instance(), m_data, m_lock, and Kwave::MemoryManager::writeTo().
unsigned int Kwave::Stripe::read | ( | Kwave::SampleArray & | buffer, |
unsigned int | dstoff, | ||
unsigned int | offset, | ||
unsigned int | length | ||
) |
Reads out samples from the stripe into a buffer
buffer | array for samples to be read (destination) |
dstoff | offset within the destination buffer |
offset | the offset within the stripe (source) |
length | number of samples to read |
Definition at line 502 of file Stripe.cpp.
References Kwave::MemoryManager::instance(), m_data, m_lock, and Kwave::MemoryManager::readFrom().
Referenced by Kwave::SampleReader::readSamples(), Stripe(), and Kwave::Stripe::StripeStorage::StripeStorage().
unsigned int Kwave::Stripe::resize | ( | unsigned int | length, |
bool | initialize = true |
||
) |
Resizes the stripe to a new number of samples. If the array size is reduced, samples from the end are thrown away. If the size is increased, samples with zero value will be added to the end.
length | new length of the array [samples] |
initialize | if true, initialize all new areas with zeroes if the size has been increased (default = true) |
Definition at line 339 of file Stripe.cpp.
References Kwave::SampleArray::data(), length(), m_data, m_lock, resizeStorage(), and Kwave::SampleArray::size().
Referenced by Kwave::Track::appendStripe(), Kwave::Track::insertSpace(), Kwave::Track::splitStripe(), Stripe(), Kwave::Track::stripes(), and Kwave::Track::Track().
|
private |
Resizes the internal storage.
length | the new length in samples |
Definition at line 289 of file Stripe.cpp.
References Kwave::MemoryManager::free(), Kwave::MemoryManager::instance(), length(), and m_data.
Referenced by append(), combine(), deleteRange(), resize(), and Stripe().
void Kwave::Stripe::setStart | ( | sample_index_t | start | ) |
Sets a new start position for the stripe
Definition at line 268 of file Stripe.cpp.
References m_data, m_lock, and start().
Referenced by Kwave::Track::moveRight(), Kwave::Track::stripes(), and Kwave::Track::unlockedDelete().
sample_index_t Kwave::Stripe::start | ( | ) | const |
Returns the start position of the stripe within the track.
Definition at line 262 of file Stripe.cpp.
References m_data.
Referenced by Kwave::Track::defragment(), Kwave::Track::dump(), Kwave::Track::insertSpace(), Kwave::Track::mergeStripe(), Kwave::SampleReader::minMax(), Kwave::Track::moveRight(), operator==(), Kwave::SampleReader::readSamples(), Kwave::DebugPlugin::run(), setStart(), Kwave::Track::splitStripe(), Stripe(), Kwave::Track::stripes(), Kwave::Track::unlockedDelete(), Kwave::Track::unlockedLength(), and Kwave::Track::writeSamples().
|
private |
unmaps the storage from memory
Definition at line 607 of file Stripe.cpp.
References m_data.
Referenced by Kwave::Stripe::MappedArray::~MappedArray().
|
private |
pointer to the shared data
Definition at line 358 of file Stripe.h.
Referenced by append(), combine(), deleteRange(), end(), length(), mapStorage(), minMax(), operator=(), overwrite(), read(), resize(), resizeStorage(), setStart(), start(), Stripe(), and unmapStorage().
|
private |
mutex for locking map/unmap
Definition at line 355 of file Stripe.h.
Referenced by append(), combine(), deleteRange(), minMax(), overwrite(), read(), resize(), setStart(), and ~Stripe().