Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
sample_voice_renderer.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <span>
5
10
11namespace pulp::audio {
12
14 bool active = false;
16 double position_frames = 0.0;
17 double host_sample_rate = 0.0;
18 double playback_rate = 1.0;
19 float gain = 1.0f;
20 std::uint32_t fade_out_frames = 0;
21 std::uint32_t fade_out_position = 0;
22 bool use_playback_region = false;
24};
25
31
33 // Frames where sample playback advanced and wrote/accumulated a value.
34 std::uint64_t rendered_frames = 0;
35 // Frames not rendered because the voice was inactive, invalid, or ended
36 // before the requested block completed.
37 std::uint64_t silent_frames = 0;
38 bool finished = false;
39};
40
42public:
43 // This adapter owns pool resolution, optional envelope integration, steal
44 // fades, and accumulate/overwrite behavior. Use LoopRenderer for new
45 // cursor-owned rich-loop playback.
46 // RT-safe when state.sample's borrowed store remains valid, destination and
47 // channel_scratch are caller-owned, and any envelope has been prepared.
48 // If provided, the envelope must be per-voice state, not shared across
49 // concurrently rendered voices.
50 // Without an explicit playback region this scalar path renders a full-sample
51 // one-shot using options.interpolation. With a playback region it honors
52 // start/end, playback_mode, source_sample_rate, and interpolation. Crossfade
53 // and snap metadata are validated as part of LoopRegion, but crossfaded
54 // rendering remains a separate loop-renderer concern.
55 // Channel mapping follows LoopReader: mono sources duplicate across outputs,
56 // while outputs beyond a multichannel source's channel count remain silent.
57 //
58 // position_frames is always a source-frame coordinate. Callers that use a
59 // nonzero region start should initialize position_frames to region.start_frame
60 // for forward/one-shot playback or end_frame - 1 for reverse playback.
61 // playback_rate must be positive; reverse regions use a negative internal
62 // step while keeping the public voice state policy simple.
65 BufferView<float> destination,
66 std::uint64_t frames,
67 std::span<const float*> channel_scratch,
68 const SampleVoiceRenderOptions& options = {}) noexcept;
69
71 std::uint32_t fade_frames) noexcept;
72};
73
74} // namespace pulp::audio
Definition instrument_envelope.hpp:26
Non-owning view over multi-channel audio sample data.
Definition buffer.hpp:30
Definition sample_voice_renderer.hpp:41
static void begin_fade_out(SampleVoiceRenderState &state, std::uint32_t fade_frames) noexcept
static SampleVoiceRenderResult render(SampleVoiceRenderState &state, BufferView< float > destination, std::uint64_t frames, std::span< const float * > channel_scratch, const SampleVoiceRenderOptions &options={}) noexcept
Definition analyzer_provider.hpp:12
LoopInterpolationMode
Definition loop_types.hpp:20
@ Linear
Definition loop_types.hpp:22
SequencerStateChannel is the audio-safe transport for a plugin's structured NON-parameter state: the ...
Definition audio_device_manager.hpp:48
Definition loop_types.hpp:42
Definition sample_pool.hpp:23
Definition sample_voice_renderer.hpp:26
bool accumulate
Definition sample_voice_renderer.hpp:27
LoopInterpolationMode interpolation
Definition sample_voice_renderer.hpp:29
AhdsrEnvelope * envelope
Definition sample_voice_renderer.hpp:28
Definition sample_voice_renderer.hpp:32
std::uint64_t silent_frames
Definition sample_voice_renderer.hpp:37
bool finished
Definition sample_voice_renderer.hpp:38
std::uint64_t rendered_frames
Definition sample_voice_renderer.hpp:34
Definition sample_voice_renderer.hpp:13
double host_sample_rate
Definition sample_voice_renderer.hpp:17
LoopRegion playback_region
Definition sample_voice_renderer.hpp:23
double position_frames
Definition sample_voice_renderer.hpp:16
double playback_rate
Definition sample_voice_renderer.hpp:18
std::uint32_t fade_out_frames
Definition sample_voice_renderer.hpp:20
SamplePoolResolution sample
Definition sample_voice_renderer.hpp:15
std::uint32_t fade_out_position
Definition sample_voice_renderer.hpp:21
bool active
Definition sample_voice_renderer.hpp:14
bool use_playback_region
Definition sample_voice_renderer.hpp:22
float gain
Definition sample_voice_renderer.hpp:19