sfFDN
Loading...
Searching...
No Matches
audio_buffer.h
1// Copyright (C) 2025 Alexandre St-Onge
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "attributes.h"
6
7#include <cstddef>
8#include <cstdint>
9#include <iterator>
10#include <span>
11
12namespace sfFDN
13{
20{
21 public:
23 AudioBuffer() noexcept SFFDN_NONBLOCKING;
24
26 explicit AudioBuffer(std::span<float> buffer) noexcept SFFDN_NONBLOCKING;
27
35 AudioBuffer(uint32_t frame_size, uint32_t channels, std::span<float> buffer) noexcept SFFDN_NONBLOCKING;
36
41 uint32_t SampleCount() const noexcept SFFDN_NONBLOCKING;
42
47 uint32_t ChannelCount() const noexcept SFFDN_NONBLOCKING;
48
53 float* Data() noexcept SFFDN_NONBLOCKING;
54
59 const float* Data() const noexcept SFFDN_NONBLOCKING;
60
66 std::span<const float> GetChannelSpan(uint32_t channel) const noexcept SFFDN_NONBLOCKING;
67
73 std::span<float> GetChannelSpan(uint32_t channel) noexcept SFFDN_NONBLOCKING;
74
80 AudioBuffer GetChannelBuffer(uint32_t channel) const noexcept SFFDN_NONBLOCKING;
81
83 AudioBuffer Offset(uint32_t offset, uint32_t frame_size) const noexcept SFFDN_NONBLOCKING;
84
85 private:
86 uint32_t frame_size_;
87 uint32_t channel_count_;
88 std::span<float> buffer_;
89
90 uint32_t offset_;
91 uint32_t chunk_size_;
92};
93} // namespace sfFDN
A class representing an audio buffer with multiple channels of non-interleaved audio data.
Definition audio_buffer.h:20
uint32_t ChannelCount() const noexcept SFFDN_NONBLOCKING
Returns the number of channels in the audio buffer.
AudioBuffer Offset(uint32_t offset, uint32_t frame_size) const noexcept SFFDN_NONBLOCKING
Returns a new AudioBuffer where every channel is offset by a certain number of samples.
uint32_t SampleCount() const noexcept SFFDN_NONBLOCKING
Returns the number of samples in one channel of the audio buffer.
AudioBuffer GetChannelBuffer(uint32_t channel) const noexcept SFFDN_NONBLOCKING
Returns an AudioBuffer object representing the audio data for a specific channel.
std::span< const float > GetChannelSpan(uint32_t channel) const noexcept SFFDN_NONBLOCKING
Returns a span representing the audio data for a specific channel.
float * Data() noexcept SFFDN_NONBLOCKING
Provides direct access to the audio data.
AudioBuffer() noexcept SFFDN_NONBLOCKING
Constructs an empty audio buffer.