9#include "utils/format.h"
10#include "utils/logger.h"
11#include "utils/types.h"
13namespace zrythm::utils::audio
31constexpr std::array<std::pair<int, BitDepth>, 4> bit_depth_map = {
32 std::pair{ 8, BitDepth::BIT_DEPTH_8 },
33 std::pair{ 16, BitDepth::BIT_DEPTH_16 },
34 std::pair{ 24, BitDepth::BIT_DEPTH_24 },
35 std::pair{ 32, BitDepth::BIT_DEPTH_32 }
39bit_depth_enum_to_int (BitDepth depth)
42 std::ranges::find (bit_depth_map, depth, &std::pair<int, BitDepth>::second);
43 z_return_val_if_fail (it != bit_depth_map.end (), -1);
48bit_depth_int_to_enum (
int depth)
51 std::ranges::find (bit_depth_map, depth, &std::pair<int, BitDepth>::first);
52 z_return_val_if_fail (it != bit_depth_map.end (), BitDepth::BIT_DEPTH_16);
61get_num_frames (
const fs::path &filepath);
68 std::span<const float> src1,
69 std::span<const float> src2,
89frames_silent (std::span<const float> src);
100 unsigned int samplerate,
101 std::vector<float> &candidates);
104audio_file_is_silent (
const fs::path &filepath);
112class AudioBuffer :
public juce::AudioBuffer<audio_sample_type_t>
115 AudioBuffer () =
default;
116 AudioBuffer (
int num_channels,
int num_frames_per_channel)
117 : juce::AudioBuffer<audio_sample_type_t> (num_channels, num_frames_per_channel)
130 static std::unique_ptr<AudioBuffer>
149 void invert_phase ();
150 void normalize_peak ();
155DEFINE_ENUM_FORMATTER (
156 zrythm::utils::audio::BitDepth,
158 QT_TR_NOOP_UTF8 (
"8 bit"),
159 QT_TR_NOOP_UTF8 (
"16 bit"),
160 QT_TR_NOOP_UTF8 (
"24 bit"),
161 QT_TR_NOOP_UTF8 (
"32 bit"));
void deinterleave_samples(size_t num_channels)
De-interleaves the samples in this buffer from interleaved format to non-interleaved (planar) format.
static std::unique_ptr< AudioBuffer > from_interleaved(const float *src, size_t num_frames, size_t num_channels)
Creates an AudioBuffer from interleaved audio data.
void interleave_samples()
Interleaves the samples in this buffer from non-interleaved (planar) format to interleaved format.
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.