Object to hold some number of audio samples.
More...
#include <audio.h>
Object to hold some number of audio samples.
This object is meant to hold some number of audio samples described by an AudioDesc. The sample data is stored in a shared Buffer. When shared ownership is needed, use Audio::Ptr.
- Example
Describes an audio format including sample type, rate, and channel count.
Definition audiodesc.h:28
Object to hold some number of audio samples.
Definition audio.h:35
SharedPtr< Audio > Ptr
Shared pointer type for Audio.
Definition audio.h:39
promeki::List< Audio > List
List of Audio values.
Definition audio.h:42
const AudioDesc & desc() const
Returns the AudioDesc that describes the audio contained in this object.
Definition audio.h:79
◆ Audio()
Constructs an Audio object for the given descriptor and sample count.
- Parameters
-
| desc | Audio descriptor specifying format, sample rate, and channels. |
| samples | Number of samples to allocate. |
| ms | Memory space to allocate the buffer from. |
◆ buffer() [1/2]
Returns a mutable reference to the buffer shared pointer.
- Returns
- A mutable reference to the Buffer shared pointer.
◆ buffer() [2/2]
Returns a const reference to the buffer that holds the audio data.
- Returns
- A const reference to the Buffer shared pointer.
◆ convertTo()
Converts this Audio to a different sample format.
Returns a new Audio object with the same sample rate, channel count, and sample count but with audio data converted to the target format. When the source is native float, this is a single-pass conversion.
- Parameters
-
- Returns
- A new Audio object in the target format, or an invalid Audio on failure.
◆ data()
| T * Audio::data |
( |
| ) |
const |
|
inline |
Returns the audio data pointer cast to the given type.
- Template Parameters
-
| T | The sample data type to cast to (e.g. float, int16_t). |
- Returns
- A typed pointer to the audio sample data.
◆ desc()
Returns the AudioDesc that describes the audio contained in this object.
- Returns
- A const reference to the AudioDesc.
◆ frames()
| size_t Audio::frames |
( |
| ) |
const |
|
inline |
Returns the total number of sample frames (samples times channels).
- Returns
- The frame count.
◆ isNative()
| bool Audio::isNative |
( |
| ) |
const |
|
inline |
Returns true if the audio is in the native float32 format for this system.
- Returns
- true if the format is native float32.
◆ isValid()
| bool Audio::isValid |
( |
| ) |
const |
|
inline |
Returns true if the object is valid.
- Returns
- true if the audio descriptor is valid.
◆ maxSamples()
| size_t Audio::maxSamples |
( |
| ) |
const |
|
inline |
Returns the maximum number of samples this object can contain.
- Returns
- The maximum sample count.
◆ resize()
Resizes the sample count to a value between 0 and maxSamples().
- Parameters
-
- Returns
- true if successful, false if val exceeds maxSamples().
◆ samples()
| size_t Audio::samples |
( |
| ) |
const |
|
inline |
Returns the number of samples, irrespective of the channel count.
- Returns
- The number of samples.
The documentation for this class was generated from the following file: