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

Add button to reset scala file #660

Merged
merged 2 commits into from
Feb 23, 2021
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
19 changes: 12 additions & 7 deletions plugins/editor/layout/main.fl
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,22 @@ widget_class mainView {open
}
}
}
Fl_Group {subPanels_[kPanelControls]} {open
xywh {5 110 790 285}
Fl_Group {subPanels_[kPanelControls]} {
xywh {5 110 790 285} hide
class LogicalGroup
} {
Fl_Group {} {open
xywh {5 110 790 285} box ROUNDED_BOX
class RoundedGroup
} {
Fl_Group controlsPanel_ {open selected
Fl_Group controlsPanel_ {open
xywh {5 110 790 285} box THIN_DOWN_FRAME
class ControlsPanel
} {}
}
}
Fl_Group {subPanels_[kPanelSettings]} {open
xywh {5 109 790 316} hide
xywh {5 109 790 316}
class LogicalGroup
} {
Fl_Group {} {
Expand Down Expand Up @@ -253,7 +253,7 @@ widget_class mainView {open
}
Fl_Group {} {
label Tuning open
xywh {205 270 390 100} box ROUNDED_BOX labelsize 12 align 17
xywh {175 270 415 100} box ROUNDED_BOX labelsize 12 align 17
class TitleGroup
} {
Fl_Box {} {
Expand Down Expand Up @@ -283,13 +283,13 @@ widget_class mainView {open
}
Fl_Box {} {
label {Scala file}
xywh {225 290 100 25} labelsize 12
xywh {195 290 100 25} labelsize 12
class ValueLabel
}
Fl_Button scalaFileButton_ {
label DefaultScale
comment {tag=kTagLoadScalaFile}
xywh {225 330 100 25} labelsize 12
xywh {195 330 100 25} labelsize 12
class ValueButton
}
Fl_Spinner scalaRootKeySlider_ {
Expand All @@ -302,6 +302,11 @@ widget_class mainView {open
xywh {375 330 30 25} labelsize 12 textsize 12
class ValueMenu
}
Fl_Button scalaResetButton_ {
comment {tag=kTagResetScalaFile} selected
xywh {295 330 25 25} labelsize 12
class ResetSomethingButton
}
}
Fl_Group userFilesGroup_ {
label Files open
Expand Down
15 changes: 15 additions & 0 deletions plugins/editor/src/editor/Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
kTagSetOversampling,
kTagSetPreloadSize,
kTagLoadScalaFile,
kTagResetScalaFile,
kTagSetScalaRootKey,
kTagSetTuningFrequency,
kTagSetStretchedTuning,
Expand All @@ -81,6 +82,7 @@ struct Editor::Impl : EditorController::Receiver, IControlListener {
STextButton* sfzFileLabel_ = nullptr;
CTextLabel* scalaFileLabel_ = nullptr;
STextButton* scalaFileButton_ = nullptr;
STextButton* scalaResetButton_ = nullptr;
CControl *volumeSlider_ = nullptr;
CTextLabel* volumeLabel_ = nullptr;
SValueMenu *numVoicesSlider_ = nullptr;
Expand Down Expand Up @@ -583,6 +585,7 @@ void Editor::Impl::createFrameContents()
typedef STextButton EditFileButton;
typedef STextButton PreviousFileButton;
typedef STextButton NextFileButton;
typedef STextButton ResetSomethingButton;
typedef SPiano Piano;
typedef SActionMenu ChevronDropDown;
typedef SControlsPanel ControlsPanel;
Expand Down Expand Up @@ -738,6 +741,11 @@ void Editor::Impl::createFrameContents()
auto createNextFileButton = [&createGlyphButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
return createGlyphButton(u8"\ue0da", bounds, tag, fontsize);
};
auto createResetSomethingButton = [&createValueButton](const CRect& bounds, int tag, const char*, CHoriTxtAlign, int fontsize) {
STextButton* btn = createValueButton(bounds, tag, u8"\ue13a", kCenterText, fontsize);
btn->setFont(makeOwned<CFontDesc>("Sfizz Fluent System R20", fontsize));
return btn;
};
auto createPiano = [](const CRect& bounds, int, const char*, CHoriTxtAlign, int fontsize) {
SPiano* piano = new SPiano(bounds);
auto font = makeOwned<CFontDesc>("Roboto", fontsize);
Expand Down Expand Up @@ -1471,6 +1479,13 @@ void Editor::Impl::valueChanged(CControl* ctl)
Call::later([this]() { chooseScalaFile(); });
break;

case kTagResetScalaFile:
if (value != 1)
break;

changeScalaFile(std::string());
break;

case kTagSetVolume:
ctrl.uiSendValue(EditId::Volume, value);
updateVolumeLabel(value);
Expand Down
43 changes: 23 additions & 20 deletions plugins/editor/src/editor/layout/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ view__29->addView(view__39);
LogicalGroup* const view__40 = createLogicalGroup(CRect(5, 110, 795, 395), -1, "", kCenterText, 14);
subPanels_[kPanelControls] = view__40;
view__0->addView(view__40);
view__40->setVisible(false);
RoundedGroup* const view__41 = createRoundedGroup(CRect(0, 0, 790, 285), -1, "", kCenterText, 14);
view__40->addView(view__41);
ControlsPanel* const view__42 = createControlsPanel(CRect(0, 0, 790, 285), -1, "", kCenterText, 14);
Expand All @@ -108,7 +109,6 @@ view__41->addView(view__42);
LogicalGroup* const view__43 = createLogicalGroup(CRect(5, 109, 795, 425), -1, "", kCenterText, 14);
subPanels_[kPanelSettings] = view__43;
view__0->addView(view__43);
view__43->setVisible(false);
TitleGroup* const view__44 = createTitleGroup(CRect(255, 26, 535, 126), -1, "Engine", kCenterText, 12);
view__43->addView(view__44);
ValueMenu* const view__45 = createValueMenu(CRect(25, 60, 85, 85), kTagSetNumVoices, "", kCenterText, 12);
Expand All @@ -126,39 +126,42 @@ view__44->addView(view__49);
ValueMenu* const view__50 = createValueMenu(CRect(195, 60, 255, 85), kTagSetPreloadSize, "", kCenterText, 12);
preloadSizeSlider_ = view__50;
view__44->addView(view__50);
TitleGroup* const view__51 = createTitleGroup(CRect(200, 161, 590, 261), -1, "Tuning", kCenterText, 12);
TitleGroup* const view__51 = createTitleGroup(CRect(170, 161, 585, 261), -1, "Tuning", kCenterText, 12);
view__43->addView(view__51);
ValueLabel* const view__52 = createValueLabel(CRect(125, 20, 205, 45), -1, "Root key", kCenterText, 12);
ValueLabel* const view__52 = createValueLabel(CRect(155, 20, 235, 45), -1, "Root key", kCenterText, 12);
view__51->addView(view__52);
ValueMenu* const view__53 = createValueMenu(CRect(220, 60, 280, 85), kTagSetTuningFrequency, "", kCenterText, 12);
ValueMenu* const view__53 = createValueMenu(CRect(250, 60, 310, 85), kTagSetTuningFrequency, "", kCenterText, 12);
tuningFrequencySlider_ = view__53;
view__51->addView(view__53);
ValueLabel* const view__54 = createValueLabel(CRect(210, 20, 290, 45), -1, "Frequency", kCenterText, 12);
ValueLabel* const view__54 = createValueLabel(CRect(240, 20, 320, 45), -1, "Frequency", kCenterText, 12);
view__51->addView(view__54);
StyledKnob* const view__55 = createStyledKnob(CRect(310, 45, 358, 93), kTagSetStretchedTuning, "", kCenterText, 14);
StyledKnob* const view__55 = createStyledKnob(CRect(340, 45, 388, 93), kTagSetStretchedTuning, "", kCenterText, 14);
stretchedTuningSlider_ = view__55;
view__51->addView(view__55);
ValueLabel* const view__56 = createValueLabel(CRect(295, 20, 375, 45), -1, "Stretch", kCenterText, 12);
ValueLabel* const view__56 = createValueLabel(CRect(325, 20, 405, 45), -1, "Stretch", kCenterText, 12);
view__51->addView(view__56);
ValueLabel* const view__57 = createValueLabel(CRect(20, 20, 120, 45), -1, "Scala file", kCenterText, 12);
view__51->addView(view__57);
ValueButton* const view__58 = createValueButton(CRect(20, 60, 120, 85), kTagLoadScalaFile, "DefaultScale", kCenterText, 12);
scalaFileButton_ = view__58;
view__51->addView(view__58);
ValueMenu* const view__59 = createValueMenu(CRect(135, 60, 170, 85), kTagSetScalaRootKey, "", kCenterText, 12);
ValueMenu* const view__59 = createValueMenu(CRect(165, 60, 200, 85), kTagSetScalaRootKey, "", kCenterText, 12);
scalaRootKeySlider_ = view__59;
view__51->addView(view__59);
ValueMenu* const view__60 = createValueMenu(CRect(170, 60, 200, 85), kTagSetScalaRootKey, "", kCenterText, 12);
ValueMenu* const view__60 = createValueMenu(CRect(200, 60, 230, 85), kTagSetScalaRootKey, "", kCenterText, 12);
scalaRootOctaveSlider_ = view__60;
view__51->addView(view__60);
TitleGroup* const view__61 = createTitleGroup(CRect(615, 161, 754, 261), -1, "Files", kCenterText, 12);
userFilesGroup_ = view__61;
view__43->addView(view__61);
ValueLabel* const view__62 = createValueLabel(CRect(20, 20, 120, 45), -1, "User SFZ folder", kCenterText, 12);
view__61->addView(view__62);
ValueButton* const view__63 = createValueButton(CRect(20, 60, 120, 85), kTagChooseUserFilesDir, "DefaultPath", kCenterText, 12);
userFilesDirButton_ = view__63;
view__61->addView(view__63);
Piano* const view__64 = createPiano(CRect(5, 400, 795, 470), -1, "", kCenterText, 12);
piano_ = view__64;
view__0->addView(view__64);
ResetSomethingButton* const view__61 = createResetSomethingButton(CRect(120, 60, 145, 85), kTagResetScalaFile, "", kCenterText, 12);
scalaResetButton_ = view__61;
view__51->addView(view__61);
TitleGroup* const view__62 = createTitleGroup(CRect(615, 161, 754, 261), -1, "Files", kCenterText, 12);
userFilesGroup_ = view__62;
view__43->addView(view__62);
ValueLabel* const view__63 = createValueLabel(CRect(20, 20, 120, 45), -1, "User SFZ folder", kCenterText, 12);
view__62->addView(view__63);
ValueButton* const view__64 = createValueButton(CRect(20, 60, 120, 85), kTagChooseUserFilesDir, "DefaultPath", kCenterText, 12);
userFilesDirButton_ = view__64;
view__62->addView(view__64);
Piano* const view__65 = createPiano(CRect(5, 400, 795, 470), -1, "", kCenterText, 12);
piano_ = view__65;
view__0->addView(view__65);
18 changes: 17 additions & 1 deletion plugins/lv2/sfizz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,14 @@ static bool
sfizz_lv2_load_file(LV2_Handle instance, const char *file_path)
{
sfizz_plugin_t *self = (sfizz_plugin_t *)instance;

char buf[MAX_PATH_SIZE];
if (file_path[0] == '\0')
{
sfizz_lv2_get_default_sfz_path(instance, buf, MAX_PATH_SIZE);
file_path = buf;
}

bool status = sfizz_load_file(self->synth, file_path);
sfizz_lv2_update_file_info(self, file_path);
return status;
Expand All @@ -1187,6 +1195,14 @@ static bool
sfizz_lv2_load_scala_file(LV2_Handle instance, const char *file_path)
{
sfizz_plugin_t *self = (sfizz_plugin_t *)instance;

char buf[MAX_PATH_SIZE];
if (file_path[0] == '\0')
{
sfizz_lv2_get_default_scala_path(instance, buf, MAX_PATH_SIZE);
file_path = buf;
}

bool status = sfizz_load_scala_file(self->synth, file_path);
if (file_path != self->scala_file_path)
strcpy(self->scala_file_path, file_path);
Expand Down Expand Up @@ -1308,7 +1324,7 @@ restore(LV2_Handle instance,
"[sfizz] Error while restoring the file %s\n", self->sfz_file_path);
}

if (sfizz_load_scala_file(self->synth, self->scala_file_path))
if (sfizz_lv2_load_scala_file(self->synth, self->scala_file_path))
{
lv2_log_note(&self->logger,
"[sfizz] Restoring the scale %s\n", self->scala_file_path);
Expand Down