mirror of
https://github.com/mikeoliphant/neural-amp-modeler-lv2.git
synced 2026-05-06 19:50:11 +02:00
Start new models bypassed. Prevent silentSamples from overflowing.
This commit is contained in:
+14
-3
@@ -187,8 +187,17 @@ namespace NAM {
|
||||
nam->currentModelPath = msg->path;
|
||||
assert(nam->currentModelPath.capacity() >= MAX_FILE_NAME + 1);
|
||||
|
||||
nam->silentSamples = 0;
|
||||
nam->smartBypassed = false;
|
||||
if (nam->currentModel != nullptr)
|
||||
{
|
||||
int receptiveFieldSize = nam->currentModel->GetReceptiveFieldSize();
|
||||
|
||||
if (receptiveFieldSize > -1)
|
||||
{
|
||||
// A newly loaded model is prewarmed to have a silent sample history
|
||||
nam->silentSamples = receptiveFieldSize;
|
||||
nam->smartBypassed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// send reply
|
||||
nam->schedule->schedule_work(nam->schedule->handle, sizeof(reply), &reply);
|
||||
@@ -268,8 +277,10 @@ namespace NAM {
|
||||
}
|
||||
}
|
||||
|
||||
if (silentSamples > (uint32_t)receptiveFieldSamples)
|
||||
if (silentSamples >= (uint32_t)receptiveFieldSamples)
|
||||
{
|
||||
silentSamples = (uint32_t)receptiveFieldSamples; // Prevent silentSamples growing and eventually overflowing uint32
|
||||
|
||||
if (smartBypassed)
|
||||
{
|
||||
for (unsigned int i = 0; i < n_samples; i++)
|
||||
|
||||
+2
-1
@@ -80,6 +80,7 @@ namespace NAM {
|
||||
|
||||
bool initialize(double rate, const LV2_Feature* const* features) noexcept;
|
||||
void set_max_buffer_size(int size) noexcept;
|
||||
void activate() noexcept;
|
||||
void process(uint32_t n_samples) noexcept;
|
||||
|
||||
void write_current_path();
|
||||
@@ -122,6 +123,6 @@ namespace NAM {
|
||||
int32_t maxBufferSize = 512;
|
||||
float bypassThresholdLinear = 0;
|
||||
uint32_t silentSamples = 0;
|
||||
bool smartBypassed = false;
|
||||
bool smartBypassed = true;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user