Start new models bypassed. Prevent silentSamples from overflowing.

This commit is contained in:
Mike Oliphant
2025-11-11 07:23:47 -08:00
parent d998b95e45
commit eeaeeecf24
2 changed files with 16 additions and 4 deletions
+14 -3
View File
@@ -187,8 +187,17 @@ namespace NAM {
nam->currentModelPath = msg->path; nam->currentModelPath = msg->path;
assert(nam->currentModelPath.capacity() >= MAX_FILE_NAME + 1); assert(nam->currentModelPath.capacity() >= MAX_FILE_NAME + 1);
nam->silentSamples = 0; if (nam->currentModel != nullptr)
nam->smartBypassed = false; {
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 // send reply
nam->schedule->schedule_work(nam->schedule->handle, sizeof(reply), &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) if (smartBypassed)
{ {
for (unsigned int i = 0; i < n_samples; i++) for (unsigned int i = 0; i < n_samples; i++)
+2 -1
View File
@@ -80,6 +80,7 @@ namespace NAM {
bool initialize(double rate, const LV2_Feature* const* features) noexcept; bool initialize(double rate, const LV2_Feature* const* features) noexcept;
void set_max_buffer_size(int size) noexcept; void set_max_buffer_size(int size) noexcept;
void activate() noexcept;
void process(uint32_t n_samples) noexcept; void process(uint32_t n_samples) noexcept;
void write_current_path(); void write_current_path();
@@ -122,6 +123,6 @@ namespace NAM {
int32_t maxBufferSize = 512; int32_t maxBufferSize = 512;
float bypassThresholdLinear = 0; float bypassThresholdLinear = 0;
uint32_t silentSamples = 0; uint32_t silentSamples = 0;
bool smartBypassed = false; bool smartBypassed = true;
}; };
} }