-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Move all file operations to a background thread to prevent audio glitches during synthesis and preset management.
Relevant code:
Preset file operations (likely to cause audio glitches if blocking):
Source/PluginProcessor.cpp:269-283
// Rename a preset
void SimdSynthAudioProcessor::changeProgramName(int index, const juce::String &newName) {
if (index >= 0 && index < presetNames.size()) {
juce::File oldFile = juce::File::getSpecialLocation(juce::File::userApplicationDataDirectory)
.getChildFile("SimdSynth/Presets")
.getChildFile(presetNames[index] + ".json");
juce::File newFile = juce::File::getSpecialLocation(juce::File::userApplicationDataDirectory)
.getChildFile("SimdSynth/Presets")
.getChildFile(newName + ".json");
if (oldFile.existsAsFile()) {
oldFile.moveFileTo(newFile);
presetNames[index] = newName;
}
}
}Main audio thread:
Source/PluginProcessor.cpp:556-572
void SimdSynthAudioProcessor::processBlock(juce::AudioBuffer<float> &buffer, juce::MidiBuffer &midiMessages) {
juce::ScopedNoDenormals noDenormals;
auto totalNumOutputChannels = getTotalNumOutputChannels();
buffer.clear();
// Prepare oversampled buffer
juce::dsp::AudioBlock<float> block(buffer);
auto oversampledBlock = oversampling->processSamplesUp(block);
float sampleRate = filter.sampleRate * oversampling->getOversamplingFactor();
double blockStartTime = currentTime;
// Update parameters for inactive voices
for (int i = 0; i < MAX_VOICE_POLYPHONY; ++i) {
if (!voices[i].active) {
voices[i].wavetableType = static_cast<int>(*wavetableTypeParam);
voices[i].attack = *attackTimeParam;
voices[i].decay = *decayTimeParam;
voices[i].sustain = *sustainLevelParam;
/*...*/
}
/*...*/
}Any blocking I/
Metadata
Metadata
Assignees
Labels
No labels