Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
float_ranges.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2020-2022, 2024-2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
12
13#pragma once
14
15#include <cstdint>
16#include <span>
17
18namespace zrythm::utils::float_ranges
19{
20
24[[using gnu: hot]] void
25fill (std::span<float> buf, float val);
26
30[[using gnu: hot]] void
31clip (std::span<float> buf, float minf, float maxf);
32
36[[using gnu: hot]] void
37copy (std::span<float> dest, std::span<const float> src);
38
42[[using gnu: hot]] void
43mul_k2 (std::span<float> dest, float k);
44
48[[nodiscard]] float
49abs_max (std::span<const float> buf);
50
54float
55min (std::span<const float> buf);
56
60float
61max (std::span<const float> buf);
62
66[[using gnu: hot]] void
67add2 (std::span<float> dest, std::span<const float> src);
68
72[[using gnu: hot]] void
73product (std::span<float> dest, std::span<const float> src, float k);
74
78[[using gnu: hot]] void
79mix_product (std::span<float> dest, std::span<const float> src, float k);
80
84[[using gnu: hot]] void
85reverse (std::span<float> dest, std::span<const float> src);
86
91[[using gnu: hot]] void
92normalize (std::span<float> dest, std::span<const float> src);
93
109void
111 std::span<float> dest,
112 int32_t start_offset,
113 int32_t total_frames_to_fade,
114 float fade_from_multiplier);
115
128void
130 std::span<float> dest,
131 int32_t start_offset,
132 int32_t total_frames_to_fade,
133 float fade_to_multiplier);
134
146void
147make_mono (std::span<float> l, std::span<float> r, bool equal_power);
148
149}; // zrythm::utils::float_ranges
void linear_fade_in_from(std::span< float > dest, int32_t start_offset, int32_t total_frames_to_fade, float fade_from_multiplier)
Calculate linear fade by multiplying from 0 to 1 for total_frames_to_fade samples.
void fill(std::span< float > buf, float val)
Fill the buffer with the given value.
void mix_product(std::span< float > dest, std::span< const float > src, float k)
Calculate dest[i] = dest[i] + src[i] * k.
void make_mono(std::span< float > l, std::span< float > r, bool equal_power)
Makes the two signals mono.
void normalize(std::span< float > dest, std::span< const float > src)
Calculate normalized values: dst[i] = src[i] / (max { abs(src) }).
void clip(std::span< float > buf, float minf, float maxf)
Clamp the buffer to min/max.
float max(std::span< const float > buf)
Gets the maximum of the buffer.
void product(std::span< float > dest, std::span< const float > src, float k)
Calculate dest[i] = src[i] * k.
float min(std::span< const float > buf)
Gets the minimum of the buffer.
float abs_max(std::span< const float > buf)
Gets the maximum absolute value of the buffer (as amplitude).
void mul_k2(std::span< float > dest, float k)
Scale: dst[i] = dst[i] * k.
void add2(std::span< float > dest, std::span< const float > src)
Calculate dst[i] = dst[i] + src[i].
void reverse(std::span< float > dest, std::span< const float > src)
Reverse the order of samples: dst[i] <=> src[count - i - 1].
void linear_fade_out_to(std::span< float > dest, int32_t start_offset, int32_t total_frames_to_fade, float fade_to_multiplier)
Calculate linear fade by multiplying from 1 to 0 for total_frames_to_fade samples.
void copy(std::span< float > dest, std::span< const float > src)
Compute dest[i] = src[i].