|
LMMS
|
A basic LMMS ring buffer for single-thread use. For thread and realtime safe alternative see LocklessRingBuffer. More...
#include <RingBuffer.h>
Public Member Functions | |
| RingBuffer (f_cnt_t size) | |
| Constructs a ringbuffer of specified size, will not care about samplerate changes. | |
| RingBuffer (float size) | |
| Constructs a ringbuffer of specified samplerate-dependent size, which will be updated when samplerate changes. | |
| ~RingBuffer () override | |
| void | reset () |
| Clears the ringbuffer of any data and resets the position to 0. | |
| void | changeSize (f_cnt_t size) |
| Changes the size of the ringbuffer. Clears all data. | |
| void | changeSize (float size) |
| Changes the size of the ringbuffer. Clears all data. | |
| void | setSamplerateAware (bool b) |
| Sets whether the ringbuffer size is adjusted for samplerate when samplerate changes. | |
| void | advance () |
| Advances the position by one period. | |
| void | movePosition (f_cnt_t amount) |
| Moves position forwards/backwards by an amount of frames. | |
| void | movePosition (float amount) |
| Moves position forwards/backwards by an amount of milliseconds. | |
| void | pop (SampleFrame *dst) |
| Destructively reads a period-sized buffer from the current position, writes it to a specified destination, and advances the position by one period. | |
| void | read (SampleFrame *dst, f_cnt_t offset=0) |
| Reads a period-sized buffer from the ringbuffer and writes it to a specified destination. | |
| void | read (SampleFrame *dst, float offset) |
| Reads a period-sized buffer from the ringbuffer and writes it to a specified destination. | |
| void | read (SampleFrame *dst, f_cnt_t offset, f_cnt_t length) |
| Reads a buffer of specified size from the ringbuffer and writes it to a specified destination. | |
| void | read (SampleFrame *dst, float offset, f_cnt_t length) |
| Reads a buffer of specified size from the ringbuffer and writes it to a specified destination. | |
| void | write (SampleFrame *src, f_cnt_t offset=0, f_cnt_t length=0) |
| Writes a buffer of sampleframes to the ringbuffer at specified position. | |
| void | write (SampleFrame *src, float offset, f_cnt_t length=0) |
| Writes a buffer of sampleframes to the ringbuffer at specified position. | |
| void | writeAdding (SampleFrame *src, f_cnt_t offset=0, f_cnt_t length=0) |
| Mixes a buffer of sampleframes additively to the ringbuffer at specified position. | |
| void | writeAdding (SampleFrame *src, float offset, f_cnt_t length=0) |
| Mixes a buffer of sampleframes additively to the ringbuffer at specified position. | |
| void | writeAddingMultiplied (SampleFrame *src, f_cnt_t offset, f_cnt_t length, float level) |
| Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames. | |
| void | writeAddingMultiplied (SampleFrame *src, float offset, f_cnt_t length, float level) |
| Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames. | |
| void | writeSwappedAddingMultiplied (SampleFrame *src, f_cnt_t offset, f_cnt_t length, float level) |
| Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames, with swapped channels. | |
| void | writeSwappedAddingMultiplied (SampleFrame *src, float offset, f_cnt_t length, float level) |
| Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames, with swapped channels. | |
Protected Slots | |
| void | updateSamplerate () |
Private Member Functions | |
| f_cnt_t | msToFrames (float ms) |
Private Attributes | |
| const f_cnt_t | m_fpp |
| sample_rate_t | m_samplerate |
| size_t | m_size |
| SampleFrame * | m_buffer |
| volatile unsigned int | m_position |
A basic LMMS ring buffer for single-thread use. For thread and realtime safe alternative see LocklessRingBuffer.
| lmms::RingBuffer::RingBuffer | ( | f_cnt_t | size | ) |
Constructs a ringbuffer of specified size, will not care about samplerate changes.
| size | The size of the buffer in frames. The actual size will be size + period size |
| lmms::RingBuffer::RingBuffer | ( | float | size | ) |
Constructs a ringbuffer of specified samplerate-dependent size, which will be updated when samplerate changes.
| size | The size of the buffer in milliseconds. The actual size will be size + period size |
|
override |
| void lmms::RingBuffer::advance | ( | ) |
Advances the position by one period.
Changes the size of the ringbuffer. Clears all data.
| size | New size in frames |
| void lmms::RingBuffer::changeSize | ( | float | size | ) |
Changes the size of the ringbuffer. Clears all data.
| size | New size in milliseconds |
Moves position forwards/backwards by an amount of frames.
| amount | Number of frames to move, may be negative |
| void lmms::RingBuffer::movePosition | ( | float | amount | ) |
Moves position forwards/backwards by an amount of milliseconds.
| amount | Number of milliseconds to move, may be negative |
|
inlineprivate |
| void lmms::RingBuffer::pop | ( | SampleFrame * | dst | ) |
Destructively reads a period-sized buffer from the current position, writes it to a specified destination, and advances the position by one period.
| dst | Destination pointer |
| void lmms::RingBuffer::read | ( | SampleFrame * | dst, |
| f_cnt_t | offset, | ||
| f_cnt_t | length ) |
Reads a buffer of specified size from the ringbuffer and writes it to a specified destination.
| dst | Destination pointer |
| offset | Offset in frames against current position, may be negative |
| length | Length in frames of the buffer to read - must not be higher than the size of the ringbuffer! |
| void lmms::RingBuffer::read | ( | SampleFrame * | dst, |
| f_cnt_t | offset = 0 ) |
Reads a period-sized buffer from the ringbuffer and writes it to a specified destination.
| dst | Destination pointer |
| offset | Offset in frames against current position, may be negative |
| void lmms::RingBuffer::read | ( | SampleFrame * | dst, |
| float | offset ) |
Reads a period-sized buffer from the ringbuffer and writes it to a specified destination.
| dst | Destination pointer |
| offset | Offset in milliseconds against current position, may be negative |
| void lmms::RingBuffer::read | ( | SampleFrame * | dst, |
| float | offset, | ||
| f_cnt_t | length ) |
Reads a buffer of specified size from the ringbuffer and writes it to a specified destination.
| dst | Destination pointer |
| offset | Offset in milliseconds against current position, may be negative |
| length | Length in frames of the buffer to read - must not be higher than the size of the ringbuffer! |
| void lmms::RingBuffer::reset | ( | ) |
Clears the ringbuffer of any data and resets the position to 0.
| void lmms::RingBuffer::setSamplerateAware | ( | bool | b | ) |
Sets whether the ringbuffer size is adjusted for samplerate when samplerate changes.
| b | True if samplerate should affect buffer size |
|
protectedslot |
| void lmms::RingBuffer::write | ( | SampleFrame * | src, |
| f_cnt_t | offset = 0, | ||
| f_cnt_t | length = 0 ) |
Writes a buffer of sampleframes to the ringbuffer at specified position.
| src | Pointer to the source buffer |
| offset | Offset in frames against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! |
| void lmms::RingBuffer::write | ( | SampleFrame * | src, |
| float | offset, | ||
| f_cnt_t | length = 0 ) |
Writes a buffer of sampleframes to the ringbuffer at specified position.
| src | Pointer to the source buffer |
| offset | Offset in milliseconds against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! |
| void lmms::RingBuffer::writeAdding | ( | SampleFrame * | src, |
| f_cnt_t | offset = 0, | ||
| f_cnt_t | length = 0 ) |
Mixes a buffer of sampleframes additively to the ringbuffer at specified position.
| src | Pointer to the source buffer |
| offset | Offset in frames against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! |
| void lmms::RingBuffer::writeAdding | ( | SampleFrame * | src, |
| float | offset, | ||
| f_cnt_t | length = 0 ) |
Mixes a buffer of sampleframes additively to the ringbuffer at specified position.
| src | Pointer to the source buffer |
| offset | Offset in milliseconds against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! |
| void lmms::RingBuffer::writeAddingMultiplied | ( | SampleFrame * | src, |
| f_cnt_t | offset, | ||
| f_cnt_t | length, | ||
| float | level ) |
Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames.
| src | Pointer to the source buffer |
| offset | Offset in frames against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! |
| level | Multiplier applied to the frames before they're written to the ringbuffer |
| void lmms::RingBuffer::writeAddingMultiplied | ( | SampleFrame * | src, |
| float | offset, | ||
| f_cnt_t | length, | ||
| float | level ) |
Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames.
| src | Pointer to the source buffer |
| offset | Offset in milliseconds against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used |
| level | Multiplier applied to the frames before they're written to the ringbuffer |
| void lmms::RingBuffer::writeSwappedAddingMultiplied | ( | SampleFrame * | src, |
| f_cnt_t | offset, | ||
| f_cnt_t | length, | ||
| float | level ) |
Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames, with swapped channels.
| src | Pointer to the source buffer |
| offset | Offset in frames against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used - must not be higher than the size of the ringbuffer! |
| level | Multiplier applied to the frames before they're written to the ringbuffer |
| void lmms::RingBuffer::writeSwappedAddingMultiplied | ( | SampleFrame * | src, |
| float | offset, | ||
| f_cnt_t | length, | ||
| float | level ) |
Mixes a buffer of sampleframes additively to the ringbuffer at specified position, with a specified multiplier applied to the frames, with swapped channels.
| src | Pointer to the source buffer |
| offset | Offset in milliseconds against current position, may NOT be negative |
| length | Length of the source buffer, if zero, period size is used |
| level | Multiplier applied to the frames before they're written to the ringbuffer |
|
private |
|
private |
|
private |
|
private |