Skip to content

Commit

Permalink
Process module outputs all at once, to mitigate multiple cores readin…
Browse files Browse the repository at this point in the history
…g and writing the same jack at the same time
  • Loading branch information
danngreen committed Jan 8, 2025
1 parent b61f23f commit 5569407
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 4 additions & 2 deletions firmware/src/core_a7/aux_core_player.hh
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ struct AuxPlayer {

void play_modules() {

for (auto module_i : module_ids) {
patch_player.process_module_outputs(module_i);
}

for (auto module_i : module_ids) {
patch_player.step_module(module_i);
}
Expand All @@ -45,13 +49,11 @@ struct AuxPlayer {
module_ids.clear();

auto num_modules = SMPControl::read<SMPRegister::NumModulesInPatch>();
// pr_dbg("Core 2 will play %u modules:\n", num_modules);

if (num_modules < module_ids.max_size()) {
for (auto i = 0u; i < num_modules; i++) {
auto id = SMPControl::read(i + 2);
module_ids.push_back(id);
// pr_dbg("%u\n", id);
}

} else
Expand Down
11 changes: 8 additions & 3 deletions firmware/src/patch_play/patch_player.hh
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ public:

else if (num_modules > 2) {
smp.update_modules();
for (auto module_i : core_balancer.cores.parts[0]) {
process_module_outputs(module_i);
}
for (auto module_i : core_balancer.cores.parts[0]) {
step_module(module_i);
}
Expand All @@ -223,14 +226,16 @@ public:
update_midi_pulses();
}

void process_module_outputs(unsigned module_i) {
for (auto &out : cables.outs[module_i])
out.val = modules[module_i]->get_output(out.jack_id);
}

void step_module(unsigned module_i) {
for (auto const &in : cables.ins[module_i])
modules[module_i]->set_input(in.jack_id, cables.outs[in.out_module_id][in.out_cache_idx].val);

modules[module_i]->update();

for (auto &out : cables.outs[module_i])
out.val = modules[module_i]->get_output(out.jack_id);
}

void update_patch_singlecore() {
Expand Down

0 comments on commit 5569407

Please sign in to comment.