HephAudio v3.0.6
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
HephAudio::AudioBuffer Class Referencefinal

class for storing the audio samples in internal format. More...

#include <AudioBuffer.h>

Inheritance diagram for HephAudio::AudioBuffer:
Heph::SignedArithmeticBuffer< AudioBuffer, heph_audio_sample_t > Heph::ArithmeticBuffer< AudioBuffer, heph_audio_sample_t > Heph::BufferUnaryMinusOperator< AudioBuffer, heph_audio_sample_t > Heph::BufferBase< AudioBuffer, heph_audio_sample_t > Heph::BufferArithmeticOperators< AudioBuffer, heph_audio_sample_t > Heph::BufferArithmeticOperators< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t > Heph::BufferDivisionOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t > Heph::BufferMultiplicationOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t > Heph::BufferSubtractionOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t > Heph::BufferAdditionOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t > Heph::BufferDivisionOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t > Heph::BufferMultiplicationOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t > Heph::BufferSubtractionOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t > Heph::BufferAdditionOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t >

Public Member Functions

 AudioBuffer ()
 
 AudioBuffer (size_t frameCount, const AudioChannelLayout &channelLayout, uint32_t sampleRate)
 
 AudioBuffer (size_t frameCount, const AudioChannelLayout &channelLayout, uint32_t sampleRate, Heph::BufferFlags flags)
 
 AudioBuffer (const AudioBuffer &rhs)
 
 AudioBuffer (AudioBuffer &&rhs) noexcept
 
 ~AudioBuffer ()
 
AudioBufferoperator= (const AudioBuffer &rhs)
 
AudioBufferoperator= (AudioBuffer &&rhs) noexcept
 
AudioBuffer operator<< (size_t rhs) const override
 
AudioBufferoperator<<= (size_t rhs) override
 
AudioBuffer operator>> (size_t rhs) const override
 
AudioBufferoperator>>= (size_t rhs) override
 
bool operator== (const AudioBuffer &rhs) const override
 
heph_audio_sample_toperator[] (size_t frameIndex) const
 
void Release () override
 
AudioBuffer SubBuffer (size_t frameIndex, size_t frameCount) const override
 
void Prepend (const AudioBuffer &rhs) override
 
void Append (const AudioBuffer &rhs) override
 
void Insert (const AudioBuffer &rhs, size_t frameIndex) override
 
void Cut (size_t frameIndex, size_t frameCount) override
 
void Replace (const AudioBuffer &rhs, size_t frameIndex, size_t frameCount) override
 
void Resize (size_t newFrameCount) override
 
void Reverse () override
 
size_t FrameCount () const
 
const AudioFormatInfoFormatInfo () const
 
void SetChannelLayout (const AudioChannelLayout &channelLayout)
 
void SetSampleRate (uint32_t sampleRate)
 
- Public Member Functions inherited from Heph::SignedArithmeticBuffer< AudioBuffer, heph_audio_sample_t >
virtual ~SignedArithmeticBuffer ()=default
 
void Invert ()
 
heph_audio_sample_t AbsMax () const
 
- Public Member Functions inherited from Heph::ArithmeticBuffer< AudioBuffer, heph_audio_sample_t >
virtual ~ArithmeticBuffer ()=default
 
heph_audio_sample_t Min () const
 
heph_audio_sample_t Max () const
 
double Rms () const
 
- Public Member Functions inherited from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >
virtual ~BufferBase ()
 
virtual bool operator== (const AudioBuffer &rhs) const
 
virtual bool operator!= (const AudioBuffer &rhs) const
 
heph_audio_sample_toperator[] (size_t index) const
 
size_t Size () const
 
size_t SizeAsByte () const
 
heph_audio_sample_tAt (size_t index) const
 
virtual bool IsEmpty () const
 
virtual void Reset ()
 
virtual void Prepend (const AudioBuffer &rhs)
 
virtual void Append (const AudioBuffer &rhs)
 
virtual void Insert (const AudioBuffer &rhs, size_t index)
 
virtual void Replace (const AudioBuffer &rhs, size_t index)
 
virtual void Replace (const AudioBuffer &rhs, size_t index, size_t size)
 
heph_audio_sample_tbegin () const
 
heph_audio_sample_tend () const
 
- Public Member Functions inherited from Heph::BufferArithmeticOperators< AudioBuffer, heph_audio_sample_t >
 BufferArithmeticOperators (const BufferArithmeticOperators &)=delete
 
BufferArithmeticOperatorsoperator= (const BufferArithmeticOperators &)=delete
 
- Public Member Functions inherited from Heph::BufferAdditionOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t >
 BufferAdditionOperator (const BufferAdditionOperator &)=delete
 
BufferAdditionOperatoroperator= (const BufferAdditionOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferSubtractionOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t >
 BufferSubtractionOperator (const BufferSubtractionOperator &)=delete
 
BufferSubtractionOperatoroperator= (const BufferSubtractionOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferMultiplicationOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t >
 BufferMultiplicationOperator (const BufferMultiplicationOperator &)=delete
 
BufferMultiplicationOperatoroperator= (const BufferMultiplicationOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferDivisionOperator< AudioBuffer, heph_audio_sample_t, heph_audio_sample_t, heph_audio_sample_t >
 BufferDivisionOperator (const BufferDivisionOperator &)=delete
 
BufferDivisionOperatoroperator= (const BufferDivisionOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferArithmeticOperators< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t >
 BufferArithmeticOperators (const BufferArithmeticOperators &)=delete
 
BufferArithmeticOperatorsoperator= (const BufferArithmeticOperators &)=delete
 
- Public Member Functions inherited from Heph::BufferAdditionOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t >
 BufferAdditionOperator (const BufferAdditionOperator &)=delete
 
BufferAdditionOperatoroperator= (const BufferAdditionOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferSubtractionOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t >
 BufferSubtractionOperator (const BufferSubtractionOperator &)=delete
 
BufferSubtractionOperatoroperator= (const BufferSubtractionOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferMultiplicationOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t >
 BufferMultiplicationOperator (const BufferMultiplicationOperator &)=delete
 
BufferMultiplicationOperatoroperator= (const BufferMultiplicationOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferDivisionOperator< AudioBuffer, heph_audio_sample_t, AudioBuffer, heph_audio_sample_t >
 BufferDivisionOperator (const BufferDivisionOperator &)=delete
 
BufferDivisionOperatoroperator= (const BufferDivisionOperator &)=delete
 
- Public Member Functions inherited from Heph::BufferUnaryMinusOperator< AudioBuffer, heph_audio_sample_t >
 BufferUnaryMinusOperator (const BufferUnaryMinusOperator &)=delete
 
BufferUnaryMinusOperatoroperator= (const BufferUnaryMinusOperator &)=delete
 

Friends

class AudioProcessor
 

Additional Inherited Members

- Protected Member Functions inherited from Heph::SignedArithmeticBuffer< AudioBuffer, heph_audio_sample_t >
 SignedArithmeticBuffer ()
 
 SignedArithmeticBuffer (size_t size)
 
 SignedArithmeticBuffer (size_t size, BufferFlags flags)
 
 SignedArithmeticBuffer (const std::initializer_list< heph_audio_sample_t > &rhs)
 
 SignedArithmeticBuffer (const SignedArithmeticBuffer &rhs)
 
 SignedArithmeticBuffer (SignedArithmeticBuffer &&rhs) noexcept
 
- Protected Member Functions inherited from Heph::ArithmeticBuffer< AudioBuffer, heph_audio_sample_t >
 ArithmeticBuffer ()
 
 ArithmeticBuffer (size_t size)
 
 ArithmeticBuffer (size_t size, BufferFlags flags)
 
 ArithmeticBuffer (const std::initializer_list< heph_audio_sample_t > &rhs)
 
 ArithmeticBuffer (const ArithmeticBuffer &rhs)
 
 ArithmeticBuffer (ArithmeticBuffer &&rhs) noexcept
 
- Protected Member Functions inherited from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >
 BufferBase ()
 
 BufferBase (size_t size)
 
 BufferBase (size_t size, BufferFlags flags)
 
 BufferBase (const std::initializer_list< heph_audio_sample_t > &rhs)
 
 BufferBase (const BufferBase &rhs)
 
 BufferBase (BufferBase &&rhs) noexcept
 
AudioBuffer & operator= (const std::initializer_list< heph_audio_sample_t > &rhs)
 
AudioBuffer & operator= (const AudioBuffer &rhs)
 
AudioBuffer & operator= (AudioBuffer &&rhs) noexcept
 
- Static Protected Member Functions inherited from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >
static size_t SizeAsByte (size_t size)
 
static heph_audio_sample_tSubBuffer (heph_audio_sample_t *pThisData, size_t thisSize_byte, size_t index_byte, size_t subBufferSize_byte)
 
static heph_audio_sample_tPrepend (heph_audio_sample_t *pThisData, size_t thisSize_byte, heph_audio_sample_t *pRhsData, size_t rhsSize_byte)
 
static heph_audio_sample_tAppend (heph_audio_sample_t *pThisData, size_t thisSize_byte, heph_audio_sample_t *pRhsData, size_t rhsSize_byte)
 
static heph_audio_sample_tInsert (heph_audio_sample_t *pThisData, size_t thisSize_byte, heph_audio_sample_t *pRhsData, size_t rhsSize_byte, size_t index_byte)
 
static heph_audio_sample_tCut (heph_audio_sample_t *pThisData, size_t thisSize_byte, size_t index_byte, size_t &cutSize_byte)
 
static void Replace (heph_audio_sample_t *pThisData, size_t thisSize_byte, heph_audio_sample_t *pRhsData, size_t rhsSize_byte, size_t index_byte)
 
static std::enable_if< std::is_class< U >::value >::type Initialize (U *pData, U *pDataEnd)
 
static std::enable_if<!std::is_class< U >::value >::type Initialize (U *pData, U *pDataEnd)
 
static heph_audio_sample_tAllocate (size_t size_byte)
 
static heph_audio_sample_tAllocateUninitialized (size_t size_byte)
 
- Protected Attributes inherited from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >
heph_audio_sample_tpData
 
size_t size
 
- Static Protected Attributes inherited from Heph::ArithmeticBuffer< AudioBuffer, heph_audio_sample_t >
static constexpr heph_audio_sample_t MIN_ELEMENT
 
static constexpr heph_audio_sample_t MAX_ELEMENT
 

Detailed Description

class for storing the audio samples in internal format.

Constructor & Destructor Documentation

◆ AudioBuffer() [1/5]

HephAudio::AudioBuffer::AudioBuffer ( )

creates a new instance and initializes it with default values.

◆ AudioBuffer() [2/5]

HephAudio::AudioBuffer::AudioBuffer ( size_t frameCount,
const AudioChannelLayout & channelLayout,
uint32_t sampleRate )

creates a new instance and initializes it with the provided values.

Parameters
frameCountnumber of frames the buffer stores.
channelLayoutchannel layout of the buffer.
sampleRatesample rate of the buffer.

◆ AudioBuffer() [3/5]

HephAudio::AudioBuffer::AudioBuffer ( size_t frameCount,
const AudioChannelLayout & channelLayout,
uint32_t sampleRate,
Heph::BufferFlags flags )

creates a new instance and initializes it with the provided values.

Parameters
frameCountnumber of frames the buffer stores.
channelLayoutchannel layout of the buffer.
sampleRatesample rate of the buffer.
flagsflags.

◆ AudioBuffer() [4/5]

HephAudio::AudioBuffer::AudioBuffer ( const AudioBuffer & rhs)

creates a new instance and copies the rhs's data to it.

Parameters
rhsinstance whose data will be copied.

◆ AudioBuffer() [5/5]

HephAudio::AudioBuffer::AudioBuffer ( AudioBuffer && rhs)
noexcept

creates a new instance and moves the rhs's data to it.

Parameters
rhsinstance whose data will be moved.

◆ ~AudioBuffer()

HephAudio::AudioBuffer::~AudioBuffer ( )

releases the resources and destroys the instance.

Member Function Documentation

◆ operator<<()

AudioBuffer HephAudio::AudioBuffer::operator<< ( size_t rhs) const
overridevirtual

creates a copy of the current buffer that is shifted to the left.

Parameters
rhsnumber of elements to shift.
Exceptions
InsufficientMemoryException

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ operator<<=()

AudioBuffer & HephAudio::AudioBuffer::operator<<= ( size_t rhs)
overridevirtual

shifts the current buffer to the left.

Parameters
rhsnumber of elements to shift.

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ operator>>()

AudioBuffer HephAudio::AudioBuffer::operator>> ( size_t rhs) const
overridevirtual

creates a copy of the current buffer that is shifted to the right.

Parameters
rhsnumber of elements to shift.
Exceptions
InsufficientMemoryException

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ operator>>=()

AudioBuffer & HephAudio::AudioBuffer::operator>>= ( size_t rhs)
overridevirtual

shifts the current buffer to the right.

Parameters
rhsnumber of elements to shift.

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ operator[]()

heph_audio_sample_t * HephAudio::AudioBuffer::operator[] ( size_t frameIndex) const

gets the pointer to the first sample of the audio frame at the provided index.

◆ Release()

void HephAudio::AudioBuffer::Release ( )
overridevirtual

releases the resources.

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ SubBuffer()

AudioBuffer HephAudio::AudioBuffer::SubBuffer ( size_t index,
size_t size ) const
overridevirtual

gets the desired part of the buffer as a new instance.

Parameters
indexindex of the first element of the sub buffer.
sizenumber of elements the sub buffer will store.
Exceptions
InvalidArgumentException
InsufficientMemoryException

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ Cut()

void HephAudio::AudioBuffer::Cut ( size_t index,
size_t size )
overridevirtual

removes the desired portion of the buffer.

Parameters
indexindex of the first element that will be removed.
sizenumber of elements to remove.
Exceptions
InvalidArgumentException

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ Resize()

void HephAudio::AudioBuffer::Resize ( size_t newSize)
overridevirtual

changes the size of the buffer.
if new size is less than the old, excess elements from the end will be removed.

Exceptions
InsufficientMemoryException

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ Reverse()

void HephAudio::AudioBuffer::Reverse ( )
overridevirtual

reverses the buffer (first element to last and vice versa).

Reimplemented from Heph::BufferBase< AudioBuffer, heph_audio_sample_t >.

◆ FrameCount()

size_t HephAudio::AudioBuffer::FrameCount ( ) const

gets the number of audio frames the buffer stores.

◆ FormatInfo()

const AudioFormatInfo & HephAudio::AudioBuffer::FormatInfo ( ) const

gets the AudioFormatInfo of the buffer.

◆ SetChannelLayout()

void HephAudio::AudioBuffer::SetChannelLayout ( const AudioChannelLayout & channelLayout)

changes the channel layout of the buffer.

◆ SetSampleRate()

void HephAudio::AudioBuffer::SetSampleRate ( uint32_t sampleRate)

changes the sample rate of the buffer.