@@ -59,7 +59,6 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
PortWidget* getInput(int portId); | PortWidget* getInput(int portId); | ||||
PortWidget* getOutput(int portId); | PortWidget* getOutput(int portId); | ||||
/** Serializes/unserializes the module state */ | |||||
json_t* toJson(); | json_t* toJson(); | ||||
void fromJson(json_t* rootJ); | void fromJson(json_t* rootJ); | ||||
void copyClipboard(); | void copyClipboard(); | ||||
@@ -83,7 +83,7 @@ struct Engine { | |||||
Module* getModule(int64_t moduleId); | Module* getModule(int64_t moduleId); | ||||
void resetModule(Module* module); | void resetModule(Module* module); | ||||
void randomizeModule(Module* module); | void randomizeModule(Module* module); | ||||
void bypassModule(Module* module, bool bypassed); | |||||
void bypassModule(Module* module, bool bypass); | |||||
/** Serializes/deserializes with locking, ensuring that Module::process() is not called during toJson()/fromJson(). | /** Serializes/deserializes with locking, ensuring that Module::process() is not called during toJson()/fromJson(). | ||||
*/ | */ | ||||
json_t* moduleToJson(Module* module); | json_t* moduleToJson(Module* module); | ||||
@@ -320,7 +320,7 @@ struct Module { | |||||
/** private */ | /** private */ | ||||
float& cpuTime(); | float& cpuTime(); | ||||
/** private */ | /** private */ | ||||
bool& bypassed(); | |||||
bool& bypass(); | |||||
}; | }; | ||||
@@ -101,7 +101,7 @@ struct ModuleMove : ModuleAction { | |||||
struct ModuleBypass : ModuleAction { | struct ModuleBypass : ModuleAction { | ||||
bool bypassed; | |||||
bool bypass; | |||||
void undo() override; | void undo() override; | ||||
void redo() override; | void redo() override; | ||||
ModuleBypass() { | ModuleBypass() { | ||||
@@ -108,7 +108,7 @@ json_t* CableWidget::toJson() { | |||||
void CableWidget::fromJson(json_t* rootJ) { | void CableWidget::fromJson(json_t* rootJ) { | ||||
json_t* colorJ = json_object_get(rootJ, "color"); | json_t* colorJ = json_object_get(rootJ, "color"); | ||||
if (colorJ) { | if (colorJ) { | ||||
// v0.6.0 and earlier patches use JSON objects. Just ignore them if so and use the existing cable color. | |||||
// In <=v0.6.0, patches used JSON objects. Just ignore them if so and use the existing cable color. | |||||
if (json_is_string(colorJ)) | if (json_is_string(colorJ)) | ||||
color = color::fromHexString(json_string_value(colorJ)); | color = color::fromHexString(json_string_value(colorJ)); | ||||
} | } | ||||
@@ -380,7 +380,7 @@ ModuleWidget::~ModuleWidget() { | |||||
void ModuleWidget::draw(const DrawArgs& args) { | void ModuleWidget::draw(const DrawArgs& args) { | ||||
nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | ||||
if (module && module->bypassed()) { | |||||
if (module && module->bypass()) { | |||||
nvgGlobalAlpha(args.vg, 0.33); | nvgGlobalAlpha(args.vg, 0.33); | ||||
} | } | ||||
@@ -926,12 +926,12 @@ void ModuleWidget::cloneAction() { | |||||
void ModuleWidget::bypassAction() { | void ModuleWidget::bypassAction() { | ||||
assert(module); | assert(module); | ||||
APP->engine->bypassModule(module, !module->bypassed()); | |||||
APP->engine->bypassModule(module, !module->bypass()); | |||||
// history::ModuleBypass | // history::ModuleBypass | ||||
history::ModuleBypass* h = new history::ModuleBypass; | history::ModuleBypass* h = new history::ModuleBypass; | ||||
h->moduleId = module->id; | h->moduleId = module->id; | ||||
h->bypassed = module->bypassed(); | |||||
h->bypass = module->bypass(); | |||||
APP->history->push(h); | APP->history->push(h); | ||||
} | } | ||||
@@ -999,7 +999,7 @@ void ModuleWidget::createContextMenu() { | |||||
ModuleBypassItem* bypassItem = new ModuleBypassItem; | ModuleBypassItem* bypassItem = new ModuleBypassItem; | ||||
bypassItem->text = "Bypass"; | bypassItem->text = "Bypass"; | ||||
bypassItem->rightText = RACK_MOD_CTRL_NAME "+E"; | bypassItem->rightText = RACK_MOD_CTRL_NAME "+E"; | ||||
if (module && module->bypassed()) | |||||
if (module && module->bypass()) | |||||
bypassItem->rightText = CHECKMARK_STRING " " + bypassItem->rightText; | bypassItem->rightText = CHECKMARK_STRING " " + bypassItem->rightText; | ||||
bypassItem->moduleWidget = this; | bypassItem->moduleWidget = this; | ||||
menu->addChild(bypassItem); | menu->addChild(bypassItem); | ||||
@@ -344,7 +344,7 @@ static void Engine_stepModulesWorker(Engine* that, int threadId) { | |||||
} | } | ||||
// Step module | // Step module | ||||
if (!module->bypassed()) | |||||
if (!module->bypass()) | |||||
module->process(processArgs); | module->process(processArgs); | ||||
else | else | ||||
module->processBypass(processArgs); | module->processBypass(processArgs); | ||||
@@ -786,21 +786,21 @@ void Engine::randomizeModule(Module* module) { | |||||
} | } | ||||
void Engine::bypassModule(Module* module, bool bypassed) { | |||||
void Engine::bypassModule(Module* module, bool bypass) { | |||||
ExclusiveSharedLock lock(internal->mutex); | ExclusiveSharedLock lock(internal->mutex); | ||||
assert(module); | assert(module); | ||||
if (module->bypassed() == bypassed) | |||||
if (module->bypass() == bypass) | |||||
return; | return; | ||||
// Clear outputs and set to 1 channel | // Clear outputs and set to 1 channel | ||||
for (Output& output : module->outputs) { | for (Output& output : module->outputs) { | ||||
// This zeros all voltages, but the channel is set to 1 if connected | // This zeros all voltages, but the channel is set to 1 if connected | ||||
output.setChannels(0); | output.setChannels(0); | ||||
} | } | ||||
// Set bypassed | |||||
module->bypassed() = bypassed; | |||||
// Set bypass state | |||||
module->bypass() = bypass; | |||||
// Trigger event | // Trigger event | ||||
if (bypassed) { | |||||
if (bypass) { | |||||
Module::BypassEvent eBypass; | Module::BypassEvent eBypass; | ||||
module->onBypass(eBypass); | module->onBypass(eBypass); | ||||
} | } | ||||
@@ -12,7 +12,7 @@ struct Module::Internal { | |||||
Only written when CPU timing is enabled, since time measurement is expensive. | Only written when CPU timing is enabled, since time measurement is expensive. | ||||
*/ | */ | ||||
float cpuTime = 0.f; | float cpuTime = 0.f; | ||||
bool bypassed = false; | |||||
bool bypass = false; | |||||
}; | }; | ||||
@@ -97,9 +97,9 @@ json_t* Module::toJson() { | |||||
if (paramsJ) | if (paramsJ) | ||||
json_object_set_new(rootJ, "params", paramsJ); | json_object_set_new(rootJ, "params", paramsJ); | ||||
// bypassed | |||||
if (internal->bypassed) | |||||
json_object_set_new(rootJ, "bypassed", json_boolean(true)); | |||||
// bypass | |||||
if (internal->bypass) | |||||
json_object_set_new(rootJ, "bypass", json_boolean(true)); | |||||
// leftModuleId | // leftModuleId | ||||
if (leftExpander.moduleId >= 0) | if (leftExpander.moduleId >= 0) | ||||
@@ -162,16 +162,13 @@ void Module::fromJson(json_t* rootJ) { | |||||
if (paramsJ) | if (paramsJ) | ||||
paramsFromJson(paramsJ); | paramsFromJson(paramsJ); | ||||
// bypassed | |||||
json_t* bypassedJ = json_object_get(rootJ, "bypassed"); | |||||
// legacy "bypass" in v0.6 or early v1 (don't remember) | |||||
if (!bypassedJ) | |||||
bypassedJ = json_object_get(rootJ, "bypass"); | |||||
// bypass | |||||
json_t* bypassJ = json_object_get(rootJ, "bypass"); | |||||
// legacy "disabled" in v1 | // legacy "disabled" in v1 | ||||
if (!bypassedJ) | |||||
bypassedJ = json_object_get(rootJ, "disabled"); | |||||
if (bypassedJ) | |||||
internal->bypassed = json_boolean_value(bypassedJ); | |||||
if (!bypassJ) | |||||
bypassJ = json_object_get(rootJ, "disabled"); | |||||
if (bypassJ) | |||||
internal->bypass = json_boolean_value(bypassJ); | |||||
// leftModuleId | // leftModuleId | ||||
json_t *leftModuleIdJ = json_object_get(rootJ, "leftModuleId"); | json_t *leftModuleIdJ = json_object_get(rootJ, "leftModuleId"); | ||||
@@ -271,8 +268,8 @@ float& Module::cpuTime() { | |||||
} | } | ||||
bool& Module::bypassed() { | |||||
return internal->bypassed; | |||||
bool& Module::bypass() { | |||||
return internal->bypass; | |||||
} | } | ||||
@@ -91,14 +91,14 @@ void ModuleBypass::undo() { | |||||
engine::Module* module = APP->engine->getModule(moduleId); | engine::Module* module = APP->engine->getModule(moduleId); | ||||
if (!module) | if (!module) | ||||
return; | return; | ||||
APP->engine->bypassModule(module, !bypassed); | |||||
APP->engine->bypassModule(module, !bypass); | |||||
} | } | ||||
void ModuleBypass::redo() { | void ModuleBypass::redo() { | ||||
engine::Module* module = APP->engine->getModule(moduleId); | engine::Module* module = APP->engine->getModule(moduleId); | ||||
if (!module) | if (!module) | ||||
return; | return; | ||||
APP->engine->bypassModule(module, bypassed); | |||||
APP->engine->bypassModule(module, bypass); | |||||
} | } | ||||