|
Tabula Sonora 0.1.0
A native C++20 implementation of the Roland Sound Canvas VA synth voice
|
Wave playback: decode, then resample at a moving rate while honouring the loop. More...
#include <tabulasonora/sampler.hpp>
Public Member Functions | |
| Sampler (const WaveRom &rom, const Interpolator &interpolator) | |
| Creates the sampler over a ROM and resampler, both of which must outlive it. | |
| const DecodedWave * | decode (const WaveDescriptor &descriptor) |
| Decodes a wave, caching the result. | |
| std::vector< float > | play (const DecodedWave &wave, int sample_count, double ratio) const |
| Plays a wave at a constant rate. | |
| std::vector< float > | play_variable (const DecodedWave &wave, int sample_count, std::span< const double > ratios) const |
| Plays a wave at a rate that changes per sample; a shorter input holds its last value. | |
Wave playback: decode, then resample at a moving rate while honouring the loop.
Looping happens in the delta domain — the index rewinds while the predictor carries on — so loops, ping-pong and reverse are all seamless by construction with no crossfade anywhere.
Decoded waves are cached and never evicted. The working set is bounded by how many distinct waves a song touches, and every voice playing a wave shares one copy, so the cache is also what keeps a dense passage from decoding the same megabyte repeatedly.
Not thread-safe: decode mutates the cache. Both renderers drive it from one thread.
|
inline |
Creates the sampler over a ROM and resampler, both of which must outlive it.
|
nodiscard |
Decodes a wave, caching the result.
Returns nullptr when the descriptor has no usable data. The returned pointer stays valid for the sampler's lifetime.
|
nodiscard |
Plays a wave at a constant rate.
|
nodiscard |
Plays a wave at a rate that changes per sample; a shorter input holds its last value.
Vibrato and pitch envelopes are applied by integrating the instantaneous rate into the read position, so the first sample always reads position zero.