|
HART
0.2.0
High level Audio Regression and Testing
|
Container for audio data. More...
#include <hart_audio_buffer.hpp>
Public Member Functions | |
| AudioBuffer (size_t numChannels=0, size_t numFrames=0, double sampleRateHz=nan< double >()) | |
| Creates an audio buffer. | |
| AudioBuffer (const AudioBuffer &other) | |
| Creates an audio buffer by copying. | |
| AudioBuffer (AudioBuffer &&other) | |
| Creates an audio buffer by moving. | |
| ~AudioBuffer ()=default | |
| The destructor. | |
| AudioBuffer & | operator= (const AudioBuffer &other) |
| Creates an audio buffer by copy-assigning. | |
| AudioBuffer & | operator= (AudioBuffer &&other) |
| Creates an audio buffer by move-assigning. | |
| const SampleType *const * | getArrayOfReadPointers () const |
| Gets a raw pointer to the read-only audio data. | |
| SampleType *const * | getArrayOfWritePointers () |
| Gets a raw pointer to the mutable audio data. | |
| size_t | getNumChannels () const |
| Get number of channels. | |
| size_t | getNumFrames () const |
| Get number of frames (samples) | |
| void | setNumFrames (size_t newNumFrames) |
| Resizes the buffer to hold a new number of frames per channel. | |
| bool | hasSampleRate () const |
| Check if a specific sample rate was assigned to the audio buffer. | |
| double | getSampleRateHz () const |
| Get a sample rate metadata. | |
| double | getLengthSeconds () const |
| Get a duration of the audio buffer. | |
| SampleType * | operator[] (size_t channel) |
| Get a raw pointer to a specific channel's mutable audio data. | |
| const SampleType * | operator[] (size_t channel) const |
| Get a raw pointer to a specific channel's read-only audio data. | |
| void | appendFrom (const AudioBuffer< SampleType > &otherBuffer) |
| Appends data from another buffer. | |
| void | erase () |
| Clears the buffer. | |
| SampleType | getMagnitude (size_t channel, size_t startFrame, size_t numFrames) const |
| Get the maximum absolute value in the buffer in a specific channel. | |
| SampleType | getMagnitude (size_t startFrame, size_t numFrames) const |
| Get the maximum absolute value in the buffer across all channels. | |
| void | copyFrom (size_t destChannel, size_t destStartFrame, const AudioBuffer &source, size_t sourceChannel, size_t sourceStartFrame, size_t numFrames) |
| Copies audio from another buffer. | |
| void | copyFrom (size_t destChannel, size_t destStartFrame, const SampleType *source, size_t numFrames) |
| Copies audio from another generic audio buffer. | |
| void | clear () |
| Clears the entire buffer. | |
| void | clear (size_t channel, size_t startFrame, size_t numFrames) |
| Clears a specific section of a given channel. | |
| void | represent (std::ostream &stream) const |
| Prints readable representation of the audio buffer. | |
Static Public Member Functions | |
| static AudioBuffer | emptyLike (const AudioBuffer &other) |
Creates an empty audio buffer with the same number of channels, frames and sample rate as the other buffer. | |
Container for audio data.
Definition at line 20 of file hart_audio_buffer.hpp.
|
inline |
Creates an audio buffer.
| numChannels | Initial number of channels |
| numFrames | Numbers of frames (samples) to be allocated in each channel |
| sampleRateHz | Metadata for sample rate (in Hz) in which the data whould be interpreted, whenever applicable |
Definition at line 27 of file hart_audio_buffer.hpp.
|
inline |
Creates an audio buffer by copying.
Definition at line 38 of file hart_audio_buffer.hpp.
|
inline |
Creates an audio buffer by moving.
Definition at line 49 of file hart_audio_buffer.hpp.
|
default |
The destructor.
|
inline |
Creates an audio buffer by copy-assigning.
Definition at line 63 of file hart_audio_buffer.hpp.
|
inline |
Creates an audio buffer by move-assigning.
Definition at line 81 of file hart_audio_buffer.hpp.
|
inline |
Gets a raw pointer to the read-only audio data.
Definition at line 98 of file hart_audio_buffer.hpp.
|
inline |
Gets a raw pointer to the mutable audio data.
Definition at line 105 of file hart_audio_buffer.hpp.
|
inlinestatic |
Creates an empty audio buffer with the same number of channels, frames and sample rate as the other buffer.
| other | Reference buffer |
Definition at line 113 of file hart_audio_buffer.hpp.
|
inline |
Get number of channels.
Definition at line 122 of file hart_audio_buffer.hpp.
|
inline |
Get number of frames (samples)
Definition at line 126 of file hart_audio_buffer.hpp.
|
inline |
Resizes the buffer to hold a new number of frames per channel.
Resizing behaviour:
| newNumFrames | New number of frames per channel |
Definition at line 136 of file hart_audio_buffer.hpp.
|
inline |
Check if a specific sample rate was assigned to the audio buffer.
true if there is a specific sample rate value, false otherwise Definition at line 169 of file hart_audio_buffer.hpp.
|
inline |
Get a sample rate metadata.
hasSampleRate() if you're not sure if the buffer has a specific sample rate Definition at line 177 of file hart_audio_buffer.hpp.
|
inline |
Get a duration of the audio buffer.
hasSampleRate() to check if the buffer has a specific sample rate, otherwise the duration is unknown. Definition at line 186 of file hart_audio_buffer.hpp.
|
inline |
Get a raw pointer to a specific channel's mutable audio data.
Definition at line 199 of file hart_audio_buffer.hpp.
|
inline |
Get a raw pointer to a specific channel's read-only audio data.
Definition at line 207 of file hart_audio_buffer.hpp.
|
inline |
Appends data from another buffer.
getArrayOfReadPointers(), getArrayOfWritePointers() and the "`[]`" operator, so make sure to keep those external pointers up to date. | otherBuffer | A buffer to append from |
Definition at line 216 of file hart_audio_buffer.hpp.
|
inline |
Clears the buffer.
The number of frames after this operaion will be zero, but channel number will persist.
Definition at line 244 of file hart_audio_buffer.hpp.
|
inline |
Get the maximum absolute value in the buffer in a specific channel.
| channel | Channel of which the magnitude should be measured |
| startFrame | The beginnig of the range of the frames to look for magnitude |
| numFrames | Number of frames, beginning with startFrame, to look for the magnitude |
Definition at line 263 of file hart_audio_buffer.hpp.
|
inline |
Get the maximum absolute value in the buffer across all channels.
| startFrame | The beginnig of the range of the frames to look for magnitude |
| numFrames | Number of frames, beginning with startFrame, to look for the magnitude |
Definition at line 285 of file hart_audio_buffer.hpp.
|
inline |
Copies audio from another buffer.
| destChannel | Channel within this buffer to copy the frames to |
| destStartFrame | Start frame within this buffer's channel |
| source | Source buffer to read from |
| sourceChannel | Channel within the source buffer to read from |
| sourceStartFrame | Offset within the source buffer's channel to start reading frames from |
| numFrames | Number of frames to copy |
Definition at line 315 of file hart_audio_buffer.hpp.
|
inline |
Copies audio from another generic audio buffer.
| destChannel | Channel within this buffer to copy the frames to |
| destStartFrame | Start frame within this buffer's channel |
| source | Pointer to the source sample data, must contain at least numFrames samples |
| numFrames | Number of frames to copy |
Definition at line 338 of file hart_audio_buffer.hpp.
|
inline |
Clears the entire buffer.
Sets all frames in all channels to zeros, keeping the sample rate value intact
Definition at line 351 of file hart_audio_buffer.hpp.
|
inline |
Clears a specific section of a given channel.
Overwrites a selected section of the channel with zeros
| channel | Cnannel in which to clear a frame range |
| startFrame | Start of the frame range to clear (inclusive) |
| numFrames | Amount of frames to clear |
Definition at line 361 of file hart_audio_buffer.hpp.
|
inline |
Prints readable representation of the audio buffer.
| stream | String stream to append the representation to |
Definition at line 374 of file hart_audio_buffer.hpp.