mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-16 13:40:05 +02:00
Implement YaProcessData reading
This commit is contained in:
@@ -20,10 +20,9 @@
|
||||
|
||||
YaAudioBusBuffers::YaAudioBusBuffers() {}
|
||||
|
||||
YaAudioBusBuffers::YaAudioBusBuffers(
|
||||
Steinberg::Vst::SymbolicSampleSizes sample_size,
|
||||
size_t num_channels,
|
||||
size_t num_samples)
|
||||
YaAudioBusBuffers::YaAudioBusBuffers(int32 sample_size,
|
||||
size_t num_channels,
|
||||
size_t num_samples)
|
||||
: buffers(sample_size == Steinberg::Vst::SymbolicSampleSizes::kSample64
|
||||
? decltype(buffers)(std::vector<std::vector<double>>(
|
||||
num_channels,
|
||||
@@ -33,7 +32,7 @@ YaAudioBusBuffers::YaAudioBusBuffers(
|
||||
std::vector<float>(num_samples, 0.0)))) {}
|
||||
|
||||
YaAudioBusBuffers::YaAudioBusBuffers(
|
||||
Steinberg::Vst::SymbolicSampleSizes sample_size,
|
||||
int32 sample_size,
|
||||
int32 num_samples,
|
||||
const Steinberg::Vst::AudioBusBuffers& data)
|
||||
: silence_flags(data.silenceFlags) {
|
||||
@@ -67,27 +66,56 @@ Steinberg::Vst::AudioBusBuffers& YaAudioBusBuffers::get() {
|
||||
reconstructed_buffers.silenceFlags = silence_flags;
|
||||
std::visit(overload{
|
||||
[&](std::vector<std::vector<double>>& buffers) {
|
||||
double_buffer_pointers.clear();
|
||||
buffer_pointers.clear();
|
||||
for (auto& buffer : buffers) {
|
||||
double_buffer_pointers.push_back(buffer.data());
|
||||
buffer_pointers.push_back(buffer.data());
|
||||
}
|
||||
|
||||
reconstructed_buffers.numChannels = buffers.size();
|
||||
reconstructed_buffers.channelBuffers64 =
|
||||
double_buffer_pointers.data();
|
||||
reinterpret_cast<double**>(buffer_pointers.data());
|
||||
},
|
||||
[&](std::vector<std::vector<float>>& buffers) {
|
||||
float_buffer_pointers.clear();
|
||||
buffer_pointers.clear();
|
||||
for (auto& buffer : buffers) {
|
||||
float_buffer_pointers.push_back(buffer.data());
|
||||
buffer_pointers.push_back(buffer.data());
|
||||
}
|
||||
|
||||
reconstructed_buffers.numChannels = buffers.size();
|
||||
reconstructed_buffers.channelBuffers32 =
|
||||
float_buffer_pointers.data();
|
||||
reinterpret_cast<float**>(buffer_pointers.data());
|
||||
},
|
||||
},
|
||||
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
|
||||
* reconstruct the output buffers during `YaProcessData::get()`.
|
||||
*/
|
||||
YaAudioBusBuffers(Steinberg::Vst::SymbolicSampleSizes sample_size,
|
||||
YaAudioBusBuffers(int32 sample_size,
|
||||
size_t num_channels,
|
||||
size_t num_samples);
|
||||
|
||||
@@ -60,7 +60,7 @@ class YaAudioBusBuffers {
|
||||
* field determines which variant of that union to use. Similarly the
|
||||
* `ProcessData`' `numSamples` field determines the extent of these arrays.
|
||||
*/
|
||||
YaAudioBusBuffers(Steinberg::Vst::SymbolicSampleSizes sample_size,
|
||||
YaAudioBusBuffers(int32 sample_size,
|
||||
int32 num_samples,
|
||||
const Steinberg::Vst::AudioBusBuffers& data);
|
||||
|
||||
@@ -96,13 +96,11 @@ class YaAudioBusBuffers {
|
||||
*/
|
||||
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
|
||||
// here to have at least some resemblance of type safety.
|
||||
union {
|
||||
std::vector<float*> float_buffer_pointers;
|
||||
std::vector<double*> double_buffer_pointers;
|
||||
};
|
||||
/**
|
||||
* We need these during the reconstruction process to provide a pointer to
|
||||
* an array of pointers to the actual buffers.
|
||||
*/
|
||||
std::vector<void*> buffer_pointers;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
Steinberg::Vst::ProcessModes process_mode;
|
||||
int32 process_mode;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user