HephAudio v3.1.0
A cross-platform C++ library for recording, playing, and processing audio on Windows, Android, Linux, iOS, and macOS.
Loading...
Searching...
No Matches
AudioBuffer.h
Go to the documentation of this file.
1#pragma once
2#include "HephAudioShared.h"
3#include "AudioFormatInfo.h"
6
9namespace HephAudio
10{
15 class HEPH_API AudioBuffer final : public Heph::SignedArithmeticBuffer<AudioBuffer, heph_audio_sample_t>
16 {
17 private:
18 size_t frameCount;
19 AudioFormatInfo formatInfo;
20
21 public:
24
32 AudioBuffer(size_t frameCount, const AudioChannelLayout& channelLayout, uint32_t sampleRate);
33
39 AudioBuffer(size_t frameCount, const AudioChannelLayout& channelLayout, uint32_t sampleRate, Heph::BufferFlags flags);
40
43
45 AudioBuffer(AudioBuffer&& rhs) noexcept;
46
49
50 AudioBuffer& operator=(const AudioBuffer& rhs);
51 AudioBuffer& operator=(AudioBuffer&& rhs) noexcept;
52 AudioBuffer operator<<(size_t rhs) const override;
53 AudioBuffer& operator<<=(size_t rhs) override;
54 AudioBuffer operator>>(size_t rhs) const override;
55 AudioBuffer& operator>>=(size_t rhs) override;
56 bool operator==(const AudioBuffer& rhs) const override;
57
62 heph_audio_sample_t* operator[](size_t frameIndex) const;
63
64 void Release() override;
65 AudioBuffer SubBuffer(size_t frameIndex, size_t frameCount) const override;
66 void Prepend(const AudioBuffer& rhs) override;
67 void Append(const AudioBuffer& rhs) override;
68 void Insert(const AudioBuffer& rhs, size_t frameIndex) override;
69 void Cut(size_t frameIndex, size_t frameCount) override;
70 void Replace(const AudioBuffer& rhs, size_t frameIndex, size_t frameCount) override;
71 void Resize(size_t newFrameCount) override;
72 void Reverse() override;
73
78 size_t FrameCount() const;
79
85
90 void SetChannelLayout(const AudioChannelLayout& channelLayout);
91
96 void SetSampleRate(uint32_t sampleRate);
97
98 private:
99 static inline bool ADD_EVENT_HANDLERS = false;
100 static void AddEventHandlers();
101 static void ResultCreatedEventHandler(const Heph::EventParams& params);
102 static void ResultCreatedEventHandlerBuffer(const Heph::EventParams& params);
103 };
104}
BufferFlags
Definition BufferBase.h:13
float heph_audio_sample_t
Definition HephAudioShared.h:127
#define HEPH_API
Definition HephShared.h:124
class for storing the audio samples in internal format.
Definition AudioBuffer.h:16
AudioBuffer & operator>>=(size_t rhs) override
AudioBuffer SubBuffer(size_t frameIndex, size_t frameCount) const override
void Cut(size_t frameIndex, size_t frameCount) override
AudioBuffer operator<<(size_t rhs) const override
AudioBuffer(size_t frameCount, const AudioChannelLayout &channelLayout, uint32_t sampleRate)
AudioBuffer & operator<<=(size_t rhs) override
void Resize(size_t newFrameCount) override
void SetSampleRate(uint32_t sampleRate)
void Reverse() override
AudioBuffer operator>>(size_t rhs) const override
const AudioFormatInfo & FormatInfo() const
size_t FrameCount() const
void SetChannelLayout(const AudioChannelLayout &channelLayout)
AudioBuffer(AudioBuffer &&rhs) noexcept
AudioBuffer(const AudioBuffer &rhs)
void Release() override
AudioBuffer(size_t frameCount, const AudioChannelLayout &channelLayout, uint32_t sampleRate, Heph::BufferFlags flags)
heph_audio_sample_t * operator[](size_t frameIndex) const
base class for buffers that store signed arithmetic types. Provides operations and methods for signed...
Definition ArithmeticBuffer.h:147
stores information about the channel layout.
Definition AudioChannelLayout.h:337
stores the properties of the audio signals
Definition AudioFormatInfo.h:20
stores the information required to handle an event.
Definition EventParams.h:16