mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-09 20:29:10 +02:00
Implement YaProcessData reading
This commit is contained in:
@@ -20,10 +20,9 @@
|
|||||||
|
|
||||||
YaAudioBusBuffers::YaAudioBusBuffers() {}
|
YaAudioBusBuffers::YaAudioBusBuffers() {}
|
||||||
|
|
||||||
YaAudioBusBuffers::YaAudioBusBuffers(
|
YaAudioBusBuffers::YaAudioBusBuffers(int32 sample_size,
|
||||||
Steinberg::Vst::SymbolicSampleSizes sample_size,
|
size_t num_channels,
|
||||||
size_t num_channels,
|
size_t num_samples)
|
||||||
size_t num_samples)
|
|
||||||
: buffers(sample_size == Steinberg::Vst::SymbolicSampleSizes::kSample64
|
: buffers(sample_size == Steinberg::Vst::SymbolicSampleSizes::kSample64
|
||||||
? decltype(buffers)(std::vector<std::vector<double>>(
|
? decltype(buffers)(std::vector<std::vector<double>>(
|
||||||
num_channels,
|
num_channels,
|
||||||
@@ -33,7 +32,7 @@ YaAudioBusBuffers::YaAudioBusBuffers(
|
|||||||
std::vector<float>(num_samples, 0.0)))) {}
|
std::vector<float>(num_samples, 0.0)))) {}
|
||||||
|
|
||||||
YaAudioBusBuffers::YaAudioBusBuffers(
|
YaAudioBusBuffers::YaAudioBusBuffers(
|
||||||
Steinberg::Vst::SymbolicSampleSizes sample_size,
|
int32 sample_size,
|
||||||
int32 num_samples,
|
int32 num_samples,
|
||||||
const Steinberg::Vst::AudioBusBuffers& data)
|
const Steinberg::Vst::AudioBusBuffers& data)
|
||||||
: silence_flags(data.silenceFlags) {
|
: silence_flags(data.silenceFlags) {
|
||||||
@@ -67,27 +66,56 @@ Steinberg::Vst::AudioBusBuffers& YaAudioBusBuffers::get() {
|
|||||||
reconstructed_buffers.silenceFlags = silence_flags;
|
reconstructed_buffers.silenceFlags = silence_flags;
|
||||||
std::visit(overload{
|
std::visit(overload{
|
||||||
[&](std::vector<std::vector<double>>& buffers) {
|
[&](std::vector<std::vector<double>>& buffers) {
|
||||||
double_buffer_pointers.clear();
|
buffer_pointers.clear();
|
||||||
for (auto& buffer : buffers) {
|
for (auto& buffer : buffers) {
|
||||||
double_buffer_pointers.push_back(buffer.data());
|
buffer_pointers.push_back(buffer.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
reconstructed_buffers.numChannels = buffers.size();
|
reconstructed_buffers.numChannels = buffers.size();
|
||||||
reconstructed_buffers.channelBuffers64 =
|
reconstructed_buffers.channelBuffers64 =
|
||||||
double_buffer_pointers.data();
|
reinterpret_cast<double**>(buffer_pointers.data());
|
||||||
},
|
},
|
||||||
[&](std::vector<std::vector<float>>& buffers) {
|
[&](std::vector<std::vector<float>>& buffers) {
|
||||||
float_buffer_pointers.clear();
|
buffer_pointers.clear();
|
||||||
for (auto& buffer : buffers) {
|
for (auto& buffer : buffers) {
|
||||||
float_buffer_pointers.push_back(buffer.data());
|
buffer_pointers.push_back(buffer.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
reconstructed_buffers.numChannels = buffers.size();
|
reconstructed_buffers.numChannels = buffers.size();
|
||||||
reconstructed_buffers.channelBuffers32 =
|
reconstructed_buffers.channelBuffers32 =
|
||||||
float_buffer_pointers.data();
|
reinterpret_cast<float**>(buffer_pointers.data());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
buffers);
|
buffers);
|
||||||
|
|
||||||
return reconstructed_buffers;
|
return reconstructed_buffers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
YaProcessData::YaProcessData() {}
|
||||||
|
|
||||||
|
YaProcessData::YaProcessData(const Steinberg::Vst::ProcessData& process_data)
|
||||||
|
: process_mode(process_data.processMode),
|
||||||
|
symbolic_sample_size(process_data.symbolicSampleSize),
|
||||||
|
num_samples(process_data.numSamples),
|
||||||
|
outputs_num_channels(process_data.numOutputs),
|
||||||
|
input_parameter_changes(*process_data.inputParameterChanges),
|
||||||
|
input_events(process_data.inputEvents ? std::make_optional<YaEventList>(
|
||||||
|
*process_data.inputEvents)
|
||||||
|
: std::nullopt),
|
||||||
|
process_context(process_data.processContext
|
||||||
|
? std::make_optional<Steinberg::Vst::ProcessContext>(
|
||||||
|
*process_data.processContext)
|
||||||
|
: std::nullopt) {
|
||||||
|
for (int i = 0; i < process_data.numInputs; i++) {
|
||||||
|
inputs.emplace_back(symbolic_sample_size, num_samples,
|
||||||
|
process_data.inputs[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the number of channels for each output so we can recreate these
|
||||||
|
// buffers in the Wine plugin host
|
||||||
|
for (int i = 0; i < process_data.numOutputs; i++) {
|
||||||
|
outputs_num_channels[i] = process_data.outputs[i].numChannels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Reconstruction
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class YaAudioBusBuffers {
|
|||||||
* Create a new, zero initialize audio bus buffers object. Used to
|
* Create a new, zero initialize audio bus buffers object. Used to
|
||||||
* reconstruct the output buffers during `YaProcessData::get()`.
|
* reconstruct the output buffers during `YaProcessData::get()`.
|
||||||
*/
|
*/
|
||||||
YaAudioBusBuffers(Steinberg::Vst::SymbolicSampleSizes sample_size,
|
YaAudioBusBuffers(int32 sample_size,
|
||||||
size_t num_channels,
|
size_t num_channels,
|
||||||
size_t num_samples);
|
size_t num_samples);
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class YaAudioBusBuffers {
|
|||||||
* field determines which variant of that union to use. Similarly the
|
* field determines which variant of that union to use. Similarly the
|
||||||
* `ProcessData`' `numSamples` field determines the extent of these arrays.
|
* `ProcessData`' `numSamples` field determines the extent of these arrays.
|
||||||
*/
|
*/
|
||||||
YaAudioBusBuffers(Steinberg::Vst::SymbolicSampleSizes sample_size,
|
YaAudioBusBuffers(int32 sample_size,
|
||||||
int32 num_samples,
|
int32 num_samples,
|
||||||
const Steinberg::Vst::AudioBusBuffers& data);
|
const Steinberg::Vst::AudioBusBuffers& data);
|
||||||
|
|
||||||
@@ -96,13 +96,11 @@ class YaAudioBusBuffers {
|
|||||||
*/
|
*/
|
||||||
Steinberg::Vst::AudioBusBuffers reconstructed_buffers;
|
Steinberg::Vst::AudioBusBuffers reconstructed_buffers;
|
||||||
|
|
||||||
// Used in reconstructed_buffers, because we need to store pointers to the
|
/**
|
||||||
// inner vectors in `buffers`. We're using a union instead of void pointers
|
* We need these during the reconstruction process to provide a pointer to
|
||||||
// here to have at least some resemblance of type safety.
|
* an array of pointers to the actual buffers.
|
||||||
union {
|
*/
|
||||||
std::vector<float*> float_buffer_pointers;
|
std::vector<void*> buffer_pointers;
|
||||||
std::vector<double*> double_buffer_pointers;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A bitfield for silent channels copied directly from the input struct.
|
* A bitfield for silent channels copied directly from the input struct.
|
||||||
@@ -195,7 +193,7 @@ class YaProcessData {
|
|||||||
/**
|
/**
|
||||||
* The processing mode copied directly from the input struct.
|
* The processing mode copied directly from the input struct.
|
||||||
*/
|
*/
|
||||||
Steinberg::Vst::ProcessModes process_mode;
|
int32 process_mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The symbolic sample size (see `Steinberg::Vst::SymbolicSampleSizes`) is
|
* The symbolic sample size (see `Steinberg::Vst::SymbolicSampleSizes`) is
|
||||||
@@ -203,7 +201,7 @@ class YaProcessData {
|
|||||||
* union of array of either single or double precision floating point
|
* union of array of either single or double precision floating point
|
||||||
* arrays. This field determines which of those variants should be used.
|
* arrays. This field determines which of those variants should be used.
|
||||||
*/
|
*/
|
||||||
Steinberg::Vst::SymbolicSampleSizes symbolic_sample_size;
|
int32 symbolic_sample_size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of samples in each audio buffer.
|
* The number of samples in each audio buffer.
|
||||||
|
|||||||
Reference in New Issue
Block a user