Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
Loading...
Searching...
No Matches
interpolator.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <cstdint>
6#include <span>
7#include <utility>
8
9namespace ts {
10
26public:
28 static constexpr int phase_count = 128;
29
31 static constexpr int tap_count = 4;
32
34 explicit Interpolator(const TableSet& tables) : coefficients_(tables.interp_coef()) {}
35
41 [[nodiscard]] float sample(std::span<const float> buffer, double position) const noexcept;
42
48 [[nodiscard]] float
49 sample_ring(std::span<const float> ring, std::int64_t index, double fraction) const noexcept;
50
52 void resample(std::span<const float> buffer,
53 std::span<const double> positions,
54 std::span<float> destination) const noexcept;
55
56private:
57 std::span<const float> coefficients_;
58};
59
66class PanLaw {
67public:
69 static constexpr int centre = 64;
70
72 explicit PanLaw(const TableSet& tables) : table_(tables.pan()) {}
73
77 [[nodiscard]] std::pair<double, double> gains(int pan) const noexcept;
78
79private:
80 std::span<const std::uint8_t> table_;
81};
82
83} // namespace ts
void resample(std::span< const float > buffer, std::span< const double > positions, std::span< float > destination) const noexcept
Resamples a buffer at a series of fractional positions.
Interpolator(const TableSet &tables)
Creates the resampler over a loaded table set, which must outlive it.
Definition interpolator.hpp:34
static constexpr int tap_count
Taps per phase row.
Definition interpolator.hpp:31
static constexpr int phase_count
Number of phase rows in the kernel.
Definition interpolator.hpp:28
float sample_ring(std::span< const float > ring, std::int64_t index, double fraction) const noexcept
Reads one sample from a power-of-two ring buffer at an absolute index.
float sample(std::span< const float > buffer, double position) const noexcept
Reads one sample at a fractional position.
static constexpr int centre
Pan value that sounds centred.
Definition interpolator.hpp:69
PanLaw(const TableSet &tables)
Creates the pan law over a loaded table set, which must outlive it.
Definition interpolator.hpp:72
std::pair< double, double > gains(int pan) const noexcept
The left and right gains for a pan position, 0 to 127, with 64 centred.
The static tables the engine needs, loaded from SCCore.dll or from a directory of extracted ....
Definition table_set.hpp:30
Definition control_decode.hpp:7
@ pan
Definition control_decode.hpp:20