Browse Source

Add ability to toggle master module in Audio.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
4023367874
1 changed files with 13 additions and 15 deletions
  1. +13
    -15
      src/core/Audio.cpp

+ 13
- 15
src/core/Audio.cpp View File

@@ -36,8 +36,15 @@ struct AudioPort : audio::Port {
outputSrc.setQuality(6);
}

void setMaster() {
APP->engine->setMasterModule(module);
void setMaster(bool master = true) {
if (master) {
APP->engine->setMasterModule(module);
}
else {
// Unset master only if module is currently master
if (isMaster())
APP->engine->setMasterModule(NULL);
}
}

bool isMaster() {
@@ -166,6 +173,7 @@ struct AudioPort : audio::Port {
deviceSampleRate = 0.f;
engineInputBuffer.clear();
engineOutputBuffer.clear();
setMaster(false);
// DEBUG("onStopStream");
}
};
@@ -385,16 +393,6 @@ struct Audio : Module {
if (dcFilterJ)
dcFilterEnabled = json_boolean_value(dcFilterJ);
}

/** Must be called when the Engine mutex is unlocked.
*/
void setMaster() {
APP->engine->setMasterModule(this);
}

bool isMaster() {
return APP->engine->getMasterModule() == this;
}
};


@@ -550,9 +548,9 @@ struct AudioWidget : ModuleWidget {

menu->addChild(new MenuSeparator);

menu->addChild(createCheckMenuItem("Master audio module", "",
[=]() {return module->isMaster();},
[=]() {module->setMaster();}
menu->addChild(createBoolMenuItem("Master audio module", "",
[=]() {return module->port.isMaster();},
[=](bool master) {module->port.setMaster(master);}
));

menu->addChild(createBoolPtrMenuItem("DC blocker", "", &module->dcFilterEnabled));


Loading…
Cancel
Save