18 AudioSampleProcessor (
23 auto out_ref = dependencies.port_registry_.create_object<
dsp::AudioPort> (
24 u8
"Stereo Out", PortFlow::Output, AudioPort::BusLayout::Stereo, 2);
25 out_ref.get_object_as<
dsp::AudioPort> ()->set_symbol (u8
"stereo_out");
26 add_output_port (out_ref);
27 set_name (u8
"Audio Sample Processor");
35 struct PlayableSampleSingleChannel
37 using UnmutableSampleSpan = std::span<const float>;
38 PlayableSampleSingleChannel (
39 UnmutableSampleSpan buf,
40 uint8_t channel_index,
42 units::sample_u32_t start_offset,
43 std::source_location source_location)
45 start_offset_ (start_offset), source_location_ (source_location)
68 std::source_location source_location_;
71 using QueueSingleChannelSampleCallback =
84 if (sample.buf_.empty ()) [[unlikely]]
90 samples_to_play_.emplace_back (sample);
91 if (queue_sample_cb_.has_value ())
93 std::invoke (queue_sample_cb_.value (), sample);
97 void set_queue_sample_callback (QueueSingleChannelSampleCallback cb)
99 queue_sample_cb_ = std::move (cb);
102 auto get_output_audio_port_non_rt ()
const
107 auto get_output_audio_port_rt ()
const {
return audio_out_; }
112 const dsp::TempoMap &tempo_map)
noexcept override;
114 void custom_prepare_for_processing (
116 units::sample_rate_t sample_rate,
117 units::sample_u32_t max_block_length)
override
119 samples_to_play_.clear ();
120 audio_out_ = get_output_ports ()[0].get_object_as<
dsp::AudioPort> ();
123 void custom_release_resources ()
override
125 samples_to_play_.clear ();
126 audio_out_ =
nullptr;
135 boost::container::static_vector<PlayableSampleSingleChannel, 128>
143 std::optional<QueueSingleChannelSampleCallback> queue_sample_cb_;
145 AudioPort * audio_out_{};
void custom_process_block(dsp::graph::EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) noexcept override
Custom processor logic after processing all owned parameters.