5#ifndef MOSTLYHARMLESS_MOSTLYHARMLESS_AUDIOHELPERS_H
6#define MOSTLYHARMLESS_MOSTLYHARMLESS_AUDIOHELPERS_H
36 template <marvin::FloatType SampleType>
39 std::function<
void(
const clap_event_header* event)>&& eventCallback,
42 auto** channelArray =
static_cast<SampleType**
>(alloca(
sizeof(SampleType*) * numChannels));
43 size_t lastEventIndex{ 0 };
46 if (eventContext.
next() && eventContext.
next()->time ==
static_cast<std::uint32_t
>(i)) {
47 while (eventContext.
next() && eventContext.
next()->time ==
static_cast<std::uint32_t
>(i)) {
48 eventCallback(eventContext.
next());
51 for (
size_t channel = 0; channel < numChannels; ++channel) {
52 auto* offsetChannelPtr = rawBuff[channel] +
static_cast<std::ptrdiff_t
>(lastEventIndex);
53 channelArray[channel] = offsetChannelPtr;
55 const auto numSamples = i - lastEventIndex;
61 const auto remaining =
static_cast<std::int64_t
>(buffer.
getNumSamples()) -
static_cast<std::int64_t
>(lastEventIndex);
62 if (remaining <= 0)
return;
63 for (
size_t channel = 0; channel < numChannels; ++channel) {
64 auto* offsetChannelPtr = rawBuff[channel] +
static_cast<std::ptrdiff_t
>(lastEventIndex);
65 channelArray[channel] = offsetChannelPtr;
The top-level namespace, contains all things plugin-related.
Definition mostlyharmless_BusConfig.h:3
void runBlockDispatch(marvin::containers::BufferView< SampleType > buffer, mostly_harmless::events::InputEventContext eventContext, std::function< void(const clap_event_header *event)> &&eventCallback, std::function< void(marvin::containers::BufferView< SampleType >)> &&blockCallback)
Splits an input buffer into chunks and dispatches them, allowing for block based processing.
Definition mostlyharmless_AudioHelpers.h:37
Trivially copyable view into a preallocated SampleType**.
Definition marvin_BufferView.h:22
SampleType *const * getArrayOfWritePointers() noexcept
size_t getNumChannels() const noexcept
size_t getNumSamples() const noexcept
Trivially copyable wrapper around the clap-api provided clap_input_events queue, for easier iterating...
Definition mostlyharmless_InputEventContext.h:9
const clap_event_header_t * next() noexcept