mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Add logging for IAudioProcessor::process()
This is super verbose, but I'm sure it's going to be useful at some point.
This commit is contained in:
+91
-11
@@ -119,12 +119,60 @@ void Vst3Logger::log_request(bool is_host_vst,
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
const YaAudioProcessor::Process& request) {
|
||||
// TODO: Only log this on log level 2
|
||||
log_request_base(is_host_vst, [&](auto& message) {
|
||||
// TODO: Log about the process data
|
||||
message << "<IAudioProcessor* #" << request.instance_id
|
||||
<< ">::process(TODO)";
|
||||
});
|
||||
log_request_base(
|
||||
is_host_vst, Logger::Verbosity::all_events, [&](auto& message) {
|
||||
// This is incredibly verbose, but if you're really a plugin that
|
||||
// handles processing in a weird way you're going to need all of
|
||||
// this
|
||||
|
||||
std::ostringstream num_input_channels;
|
||||
num_input_channels << "[";
|
||||
for (bool is_first = true;
|
||||
const auto& buffers : request.data.inputs) {
|
||||
num_input_channels << (is_first ? "" : ", ")
|
||||
<< buffers.num_channels();
|
||||
is_first = false;
|
||||
}
|
||||
num_input_channels << "]";
|
||||
|
||||
std::ostringstream num_output_channels;
|
||||
num_output_channels << "[";
|
||||
for (bool is_first = true;
|
||||
const auto& num_channels : request.data.outputs_num_channels) {
|
||||
num_output_channels << (is_first ? "" : ", ") << num_channels;
|
||||
is_first = false;
|
||||
}
|
||||
num_output_channels << "]";
|
||||
|
||||
message << "<IAudioProcessor* #" << request.instance_id
|
||||
<< ">::process(data = <ProcessData with input_channels = "
|
||||
<< num_input_channels.str()
|
||||
<< ", output_channels = " << num_output_channels.str()
|
||||
<< ", num_samples = " << request.data.process_mode
|
||||
<< ", input_parameter_changes = <IParameterChanges* for "
|
||||
<< request.data.input_parameter_changes.num_parameters()
|
||||
<< " parameters>, output_parameter_changes = "
|
||||
<< (request.data.output_parameter_changes_supported
|
||||
? "<IParameterChanges*>"
|
||||
: "nullptr")
|
||||
<< ", input_events = ";
|
||||
if (request.data.input_events) {
|
||||
message << "<IEventList* with "
|
||||
<< request.data.input_events->num_events()
|
||||
<< " events>";
|
||||
} else {
|
||||
message << "nullptr";
|
||||
}
|
||||
message << ", output_events = "
|
||||
<< (request.data.output_events_supported ? "<IEventList*>"
|
||||
: "nullptr")
|
||||
<< ", process_context = "
|
||||
<< (request.data.process_context ? "<ProcessContext*>"
|
||||
: "nullptr")
|
||||
<< ", process_mode = " << request.data.process_mode
|
||||
<< ", symbolic_sample_size = "
|
||||
<< request.data.symbolic_sample_size << ">)";
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_request(bool is_host_vst,
|
||||
@@ -284,12 +332,44 @@ void Vst3Logger::log_response(
|
||||
void Vst3Logger::log_response(
|
||||
bool is_host_vst,
|
||||
const YaAudioProcessor::ProcessResponse& response) {
|
||||
// TODO: Only log this on verbosity level 2
|
||||
log_response_base(is_host_vst, [&](auto& message) {
|
||||
message << response.result.string();
|
||||
log_response_base(
|
||||
is_host_vst, Logger::Verbosity::all_events, [&](auto& message) {
|
||||
message << response.result.string();
|
||||
|
||||
// TODO: Log response
|
||||
});
|
||||
// This is incredibly verbose, but if you're really a plugin that
|
||||
// handles processing in a weird way you're going to need all of
|
||||
// this
|
||||
|
||||
std::ostringstream num_output_channels;
|
||||
num_output_channels << "[";
|
||||
for (bool is_first = true;
|
||||
const auto& buffers : response.output_data.outputs) {
|
||||
num_output_channels << (is_first ? "" : ", ")
|
||||
<< buffers.num_channels();
|
||||
is_first = false;
|
||||
}
|
||||
num_output_channels << "]";
|
||||
|
||||
message << "<AudioBusBuffers array with "
|
||||
<< num_output_channels.str() << " channels>";
|
||||
|
||||
if (response.output_data.output_parameter_changes) {
|
||||
message << ", <IParameterChanges* for "
|
||||
<< response.output_data.output_parameter_changes
|
||||
->num_parameters()
|
||||
<< " parameters>";
|
||||
} else {
|
||||
message << ", host does not support parameter outputs";
|
||||
}
|
||||
|
||||
if (response.output_data.output_events) {
|
||||
message << ", <IEventList* with "
|
||||
<< response.output_data.output_events->num_events()
|
||||
<< " events>";
|
||||
} else {
|
||||
message << ", host does not support event outputs";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Vst3Logger::log_response(bool is_host_vst,
|
||||
|
||||
@@ -115,9 +115,10 @@ class Vst3Logger {
|
||||
* every logging function so we don't have to repeat it everywhere.
|
||||
*/
|
||||
template <std::invocable<std::ostringstream&> F>
|
||||
void log_request_base(bool is_host_vst, F callback) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >=
|
||||
Logger::Verbosity::most_events)) {
|
||||
void log_request_base(bool is_host_vst,
|
||||
Logger::Verbosity min_verbosity,
|
||||
F callback) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >= min_verbosity)) {
|
||||
std::ostringstream message;
|
||||
if (is_host_vst) {
|
||||
message << "[host -> vst] >> ";
|
||||
@@ -130,14 +131,20 @@ class Vst3Logger {
|
||||
}
|
||||
}
|
||||
|
||||
template <std::invocable<std::ostringstream&> F>
|
||||
void log_request_base(bool is_host_vst, F callback) {
|
||||
log_request_base(is_host_vst, Logger::Verbosity::most_events, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a response with a standard prefix based on the boolean flag we pass
|
||||
* to every logging function so we don't have to repeat it everywhere.
|
||||
*/
|
||||
template <std::invocable<std::ostringstream&> F>
|
||||
void log_response_base(bool is_host_vst, F callback) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >=
|
||||
Logger::Verbosity::most_events)) {
|
||||
void log_response_base(bool is_host_vst,
|
||||
Logger::Verbosity min_verbosity,
|
||||
F callback) {
|
||||
if (BOOST_UNLIKELY(logger.verbosity >= min_verbosity)) {
|
||||
std::ostringstream message;
|
||||
if (is_host_vst) {
|
||||
message << "[host -> vst] ";
|
||||
@@ -149,4 +156,10 @@ class Vst3Logger {
|
||||
log(message.str());
|
||||
}
|
||||
}
|
||||
|
||||
template <std::invocable<std::ostringstream&> F>
|
||||
void log_response_base(bool is_host_vst, F callback) {
|
||||
log_response_base(is_host_vst, Logger::Verbosity::most_events,
|
||||
callback);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -190,8 +190,10 @@ YaEventList::YaEventList(Steinberg::Vst::IEventList& event_list) {
|
||||
}
|
||||
}
|
||||
|
||||
YaEventList::~YaEventList() {
|
||||
FUNKNOWN_DTOR
|
||||
YaEventList::~YaEventList(){FUNKNOWN_DTOR}
|
||||
|
||||
size_t YaEventList::num_events() const {
|
||||
return events.size();
|
||||
}
|
||||
|
||||
void YaEventList::write_back_outputs(
|
||||
|
||||
@@ -227,6 +227,11 @@ class YaEventList : public Steinberg::Vst::IEventList {
|
||||
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
|
||||
/**
|
||||
* Return the number of events we store. Used in debug logs.
|
||||
*/
|
||||
size_t num_events() const;
|
||||
|
||||
/**
|
||||
* Write these events an output events queue on the `ProcessData` object
|
||||
* provided by the host.
|
||||
|
||||
@@ -41,6 +41,10 @@ IMPLEMENT_FUNKNOWN_METHODS(YaParameterChanges,
|
||||
Steinberg::Vst::IParameterChanges::iid)
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
size_t YaParameterChanges::num_parameters() const {
|
||||
return queues.size();
|
||||
}
|
||||
|
||||
void YaParameterChanges::write_back_outputs(
|
||||
Steinberg::Vst::IParameterChanges& output_queues) const {
|
||||
for (auto& queue : queues) {
|
||||
|
||||
@@ -45,6 +45,12 @@ class YaParameterChanges : public Steinberg::Vst::IParameterChanges {
|
||||
|
||||
DECLARE_FUNKNOWN_METHODS
|
||||
|
||||
/**
|
||||
* Return the number of parameter we have parameter change queues for. Used
|
||||
* in debug logs.
|
||||
*/
|
||||
size_t num_parameters() const;
|
||||
|
||||
/**
|
||||
* Write these changes back to an output parameter changes queue on the
|
||||
* `ProcessData` object provided by the host.
|
||||
|
||||
@@ -92,6 +92,11 @@ Steinberg::Vst::AudioBusBuffers YaAudioBusBuffers::get() {
|
||||
return reconstructed_buffers;
|
||||
}
|
||||
|
||||
size_t YaAudioBusBuffers::num_channels() const {
|
||||
return std::visit([&](const auto& buffers) { return buffers.size(); },
|
||||
buffers);
|
||||
}
|
||||
|
||||
void YaAudioBusBuffers::write_back_outputs(
|
||||
Steinberg::Vst::AudioBusBuffers& output_buffers) const {
|
||||
output_buffers.silenceFlags = silence_flags;
|
||||
|
||||
@@ -72,6 +72,11 @@ class YaAudioBusBuffers {
|
||||
*/
|
||||
Steinberg::Vst::AudioBusBuffers get();
|
||||
|
||||
/**
|
||||
* Return the number of channels in `buffers`. Only used for debug logs.
|
||||
*/
|
||||
size_t num_channels() const;
|
||||
|
||||
/**
|
||||
* Write these buffers and the silence flag back to an `AudioBusBuffers
|
||||
* object provided by the host.
|
||||
@@ -203,7 +208,6 @@ class YaProcessData {
|
||||
// of the `output*` fields defined below it
|
||||
}
|
||||
|
||||
private:
|
||||
// These fields are input and context data read from the original
|
||||
// `ProcessData` object
|
||||
|
||||
@@ -266,6 +270,7 @@ class YaProcessData {
|
||||
*/
|
||||
std::optional<Steinberg::Vst::ProcessContext> process_context;
|
||||
|
||||
private:
|
||||
// These are the same fields as in `YaProcessDataResponse`. We'll generate
|
||||
// these as part of creating `reconstructed_process_data`, and they will be
|
||||
// moved into a response object during `move_outputs_to_response()`.
|
||||
|
||||
Reference in New Issue
Block a user