![]() |
HulaLoop
Simple cross-platform audio loopback and recording.
|
HulaLoop wrapper class for PortAudio ring buffer. More...
#include <HulaRingBuffer.h>
Public Member Functions | |
| HulaRingBuffer (float maxDuration) | |
| Create a new ring buffer. More... | |
| ring_buffer_size_t | read (SAMPLE *data, ring_buffer_size_t maxSamples) |
| Read up to maxSamples from the ring buffer into the memory pointed to by data. More... | |
| ring_buffer_size_t | directRead (ring_buffer_size_t maxSamples, void **dataPtr1, ring_buffer_size_t *size1, void **dataPtr2, ring_buffer_size_t *size2) |
| Fetch direct pointers to memory within the ring buffer. More... | |
| ring_buffer_size_t | write (const SAMPLE *data, ring_buffer_size_t maxSamples) |
| Add data to the ring buffer. More... | |
| ~HulaRingBuffer () | |
| Destructor for the ring buffer. More... | |
HulaLoop wrapper class for PortAudio ring buffer.
| HulaRingBuffer::HulaRingBuffer | ( | float | maxDuration | ) |
Create a new ring buffer.
The ring buffer's size is determined using the formula:
| maxDuration | The maximum length in seconds that the ring buffer should be capable of holding. |
| ring_buffer_size_t HulaRingBuffer::directRead | ( | ring_buffer_size_t | maxSamples, |
| void ** | dataPtr1, | ||
| ring_buffer_size_t * | size1, | ||
| void ** | dataPtr2, | ||
| ring_buffer_size_t * | size2 | ||
| ) |
Fetch direct pointers to memory within the ring buffer.
This can be used to avoid allocating a secondary container. The second pointer/size pair is for when the ring buffer has split data between its tail and head. If the requested maxBytes are continuous in the underlying memory, only the first pointer/size pair is used.
| maxSamples | Desired number of samples. |
| dataPtr1 | The address where the first pointer should be stored. |
| size1 | Number of elements available from dataPtr1. |
| dataPtr2 | The address where the second pointer (if required) will be stored. nullptr if not used. |
| size2 | Number of elements available from dataPtr2. |
| ring_buffer_size_t HulaRingBuffer::read | ( | SAMPLE * | data, |
| ring_buffer_size_t | maxSamples | ||
| ) |
Read up to maxSamples from the ring buffer into the memory pointed to by data.
| data | Pointer to allocated memory of at least maxSamples size. |
| maxSamples | Desired number of samples. |
| ring_buffer_size_t HulaRingBuffer::write | ( | const SAMPLE * | data, |
| ring_buffer_size_t | maxSamples | ||
| ) |
Add data to the ring buffer.
| data | Array of samples to write to the ring buffer. |
| maxSamples | Number of samples contained in the array. |
1.8.11