mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 03:50:11 +02:00
Cache IAudioProcessor::canProcessSampleSize()
This commit is contained in:
@@ -13,6 +13,11 @@ Versioning](https://semver.org/spec/v2.0.0.html).
|
|||||||
- Added a timed cache for the `IPluginView::canResize()` VST3 function, so value
|
- Added a timed cache for the `IPluginView::canResize()` VST3 function, so value
|
||||||
will be remembered during an active resize. This makes resizing VST3 plugin
|
will be remembered during an active resize. This makes resizing VST3 plugin
|
||||||
editor windows more responsive.
|
editor windows more responsive.
|
||||||
|
- Add a cache for VST3 function calls where the host asks the plugin whether it
|
||||||
|
can process 32-bit or 64-bit floating point audio. Some hosts will call this
|
||||||
|
function every processing cycle even though the value doesn't change. Caching
|
||||||
|
this can significantly reduce the overhead of bridging VST3 plugins under
|
||||||
|
those hosts.
|
||||||
|
|
||||||
## [3.2.0] - 2021-05-03
|
## [3.2.0] - 2021-05-03
|
||||||
|
|
||||||
|
|||||||
@@ -139,10 +139,37 @@ tresult PLUGIN_API Vst3PluginProxyImpl::getBusArrangement(
|
|||||||
|
|
||||||
tresult PLUGIN_API
|
tresult PLUGIN_API
|
||||||
Vst3PluginProxyImpl::canProcessSampleSize(int32 symbolicSampleSize) {
|
Vst3PluginProxyImpl::canProcessSampleSize(int32 symbolicSampleSize) {
|
||||||
return bridge.send_audio_processor_message(
|
const auto request = YaAudioProcessor::CanProcessSampleSize{
|
||||||
YaAudioProcessor::CanProcessSampleSize{
|
.instance_id = instance_id(),
|
||||||
.instance_id = instance_id(),
|
.symbolic_sample_size = symbolicSampleSize};
|
||||||
.symbolic_sample_size = symbolicSampleSize});
|
|
||||||
|
{
|
||||||
|
std::lock_guard lock(function_result_cache_mutex);
|
||||||
|
if (auto it = function_result_cache.can_process_sample_size.find(
|
||||||
|
symbolicSampleSize);
|
||||||
|
it != function_result_cache.can_process_sample_size.end()) {
|
||||||
|
const bool log_response = bridge.logger.log_request(true, request);
|
||||||
|
if (log_response) {
|
||||||
|
bridge.logger.log_response(
|
||||||
|
true,
|
||||||
|
YaAudioProcessor::CanProcessSampleSize::Response(
|
||||||
|
it->second),
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *function_result_cache.parameter_count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const tresult result = bridge.send_audio_processor_message(request);
|
||||||
|
|
||||||
|
{
|
||||||
|
std::lock_guard lock(function_result_cache_mutex);
|
||||||
|
function_result_cache.can_process_sample_size[symbolicSampleSize] =
|
||||||
|
result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 PLUGIN_API Vst3PluginProxyImpl::getLatencySamples() {
|
uint32 PLUGIN_API Vst3PluginProxyImpl::getLatencySamples() {
|
||||||
|
|||||||
@@ -531,6 +531,11 @@ class Vst3PluginProxyImpl : public Vst3PluginProxy {
|
|||||||
* @see function_result_cache
|
* @see function_result_cache
|
||||||
*/
|
*/
|
||||||
struct FunctionResultCache {
|
struct FunctionResultCache {
|
||||||
|
/**
|
||||||
|
* Memoizes `IAudioProcessor::canProcessSampleSize()`, since some hosts
|
||||||
|
* call this every processing cycle.
|
||||||
|
*/
|
||||||
|
std::map<int32, tresult> can_process_sample_size;
|
||||||
/**
|
/**
|
||||||
* Memoizes `IEditController::getParameterCount()`.
|
* Memoizes `IEditController::getParameterCount()`.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user