Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move and conslolidate voice count to a Storage atomic #7870

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/common/SurgeStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1364,9 +1364,11 @@ class alignas(16) SurgeStorage
bool oscReceiving{false};
bool oscSending{false};

int voiceCount; // TODO: use SurgeSynthesizer class to fetch synth->polydisplay directly from
// valueAt() in FormulaModulationHelper.cpp where it's needed and remove
// this and its assignment in SurgeSynthesizer.cpp
/*
* A bit of a cheat - this isn't really the storage, but is updated by the synth at render time.
* We put it here so LFOS can get it, which formula needs
*/
std::atomic<int> activeVoiceCount{0};

bool getOverrideDataHome(std::string &value);
void createUserDirectory();
Expand Down
5 changes: 2 additions & 3 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ SurgeSynthesizer::SurgeSynthesizer(PluginLayer *parent, const std::string &suppl
send[i][1].set_blocksize(BLOCK_SIZE);
}

polydisplay = 0;
storage.activeVoiceCount = 0;
refresh_editor = false;
patch_loaded = false;
storage.getPatch().category = "Init";
Expand Down Expand Up @@ -4822,8 +4822,7 @@ void SurgeSynthesizer::process()
}

storage.modRoutingMutex.unlock();
polydisplay = vcount;
storage.voiceCount = vcount;
storage.activeVoiceCount = vcount;

// TODO: FIX SCENE ASSUMPTION
if (play_scene[0])
Expand Down
1 change: 0 additions & 1 deletion src/common/SurgeSynthesizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ class alignas(16) SurgeSynthesizer
std::atomic<int> patchid_queue;

// updated in audio thread, read from UI, so have assignments be atomic
std::atomic<int> polydisplay;
std::atomic<int> hasUpdatedMidiCC;
std::atomic<int> modwheelCC, pitchbendMIDIVal, sustainpedalCC;
std::atomic<bool> midiSoftTakeover;
Expand Down
4 changes: 2 additions & 2 deletions src/common/dsp/modulators/FormulaModulationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ void valueAt(int phaseIntPart, float phaseFracPart, SurgeStorage *storage,
addi("cycle", phaseIntPart); // Alias cycle for intphase

// Fake a voice count of one for display calls
int voiceCount = storage->voiceCount;
if (voiceCount == 0)
int voiceCount = storage->activeVoiceCount;
if (voiceCount == 0 && s->is_display)
voiceCount = 1;
addi("voice_count", voiceCount);

Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,9 @@ void SurgeGUIEditor::idle()
{
int prior = polydisp->getPlayingVoiceCount();

if (prior != synth->polydisplay)
if (prior != synth->storage.activeVoiceCount)
{
polydisp->setPlayingVoiceCount(synth->polydisplay);
polydisp->setPlayingVoiceCount(synth->storage.activeVoiceCount);
polydisp->repaint();
}
}
Expand Down