Skip to content

Commit de1e184

Browse files
committed
Fix build.
1 parent b6208e1 commit de1e184

File tree

1 file changed

+57
-50
lines changed

1 file changed

+57
-50
lines changed

src/Recorder.cpp

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,18 @@ struct Encoder {
222222
}
223223

224224
// Check sample rate
225-
bool validSampleRate = false;
226-
for (const int *p = audioCodec->supported_samplerates; p && *p != 0; p++) {
227-
if (sampleRate == *p) {
228-
validSampleRate = true;
229-
break;
230-
}
231-
}
232-
if (!validSampleRate) {
233-
WARN("Sample rate %d not supported by codec", sampleRate);
234-
return;
235-
}
225+
// bool validSampleRate = false;
226+
// for (const int *p = audioCodec->supported_samplerates; p && *p != 0; p++) {
227+
// DEBUG("sr %d", *p);
228+
// if (sampleRate == *p) {
229+
// validSampleRate = true;
230+
// break;
231+
// }
232+
// }
233+
// if (!validSampleRate) {
234+
// WARN("Sample rate %d not supported by codec", sampleRate);
235+
// return;
236+
// }
236237

237238
// Set sample rate
238239
audioCtx->sample_rate = sampleRate;
@@ -615,7 +616,6 @@ struct Encoder {
615616
struct Recorder : Module {
616617
enum ParamIds {
617618
GAIN_PARAM,
618-
REC_PARAM,
619619
NUM_PARAMS
620620
};
621621
enum InputIds {
@@ -635,13 +635,13 @@ struct Recorder : Module {
635635
};
636636

637637
dsp::ClockDivider gateDivider;
638-
dsp::BooleanTrigger recTrigger;
639638
dsp::SchmittTrigger trigTrigger;
640639
dsp::VuMeter2 vuMeter[2];
641640
dsp::ClockDivider lightDivider;
642641
Encoder *encoder = NULL;
643642
std::mutex encoderMutex;
644-
std::thread primaryThread;
643+
// std::thread primaryThread;
644+
bool recClicked = false;
645645

646646
// Settings. Copied to Encoder when created.
647647
std::string format;
@@ -658,7 +658,6 @@ struct Recorder : Module {
658658
Recorder() {
659659
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
660660
configParam(GAIN_PARAM, 0.f, 2.f, 1.f, "Level", " dB", -10, 40);
661-
configParam(REC_PARAM, 0.f, 1.f, 0.f, "Record");
662661

663662
gateDivider.setDivision(32);
664663
lightDivider.setDivision(512);
@@ -669,10 +668,10 @@ struct Recorder : Module {
669668
stop();
670669

671670
// Stop primary thread
672-
if (APP->engine->getPrimaryModule() == this) {
673-
if (primaryThread.joinable())
674-
primaryThread.join();
675-
}
671+
// if (APP->engine->getPrimaryModule() == this) {
672+
// if (primaryThread.joinable())
673+
// primaryThread.join();
674+
// }
676675
}
677676

678677
void onReset() override {
@@ -735,8 +734,9 @@ struct Recorder : Module {
735734
// Recording state
736735
bool gate = isRecording();
737736
bool oldGate = gate;
738-
if (recTrigger.process(params[REC_PARAM].getValue())) {
737+
if (recClicked) {
739738
gate ^= true;
739+
recClicked = false;
740740
}
741741
if (trigTrigger.process(rescale(inputs[TRIG_INPUT].getVoltage(), 0.1, 2.0, 0.0, 1.0))) {
742742
gate ^= true;
@@ -983,13 +983,13 @@ struct Recorder : Module {
983983
// }
984984
// }
985985

986-
void setPrimary() {
987-
APP->engine->setPrimaryModule(this);
988-
}
986+
// void setPrimary() {
987+
// APP->engine->setPrimaryModule(this);
988+
// }
989989

990-
bool isPrimary() {
991-
return APP->engine->getPrimaryModule() == this;
992-
}
990+
// bool isPrimary() {
991+
// return APP->engine->getPrimaryModule() == this;
992+
// }
993993
};
994994

995995

@@ -1019,18 +1019,23 @@ static void selectPath(Recorder *module) {
10191019
}
10201020

10211021

1022-
struct RecButton : SvgSwitch {
1022+
struct RecButton : SvgButton {
1023+
Recorder* module;
1024+
10231025
RecButton() {
1024-
momentary = true;
10251026
addFrame(Svg::load(asset::plugin(pluginInstance, "res/RecButton.svg")));
10261027
}
10271028

1029+
// Instead of using onAction() which is called on mouse up, handle on mouse down
10281030
void onDragStart(const event::DragStart &e) override {
1029-
Recorder *module = dynamic_cast<Recorder*>(this->module);
1030-
if (module && module->path == "")
1031-
selectPath(module);
1031+
if (e.button == GLFW_MOUSE_BUTTON_LEFT) {
1032+
if (module && module->path == "") {
1033+
selectPath(module);
1034+
}
1035+
module->recClicked = true;
1036+
}
10321037

1033-
SvgSwitch::onDragStart(e);
1038+
SvgButton::onDragStart(e);
10341039
}
10351040
};
10361041

@@ -1062,7 +1067,10 @@ struct RecorderWidget : ModuleWidget {
10621067
addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
10631068

10641069
addParam(createParamCentered<RoundBigBlackKnob>(mm2px(Vec(12.7, 21.417)), module, Recorder::GAIN_PARAM));
1065-
addParam(createParamCentered<RecButton>(mm2px(Vec(12.7, 73.624)), module, Recorder::REC_PARAM));
1070+
1071+
RecButton* recButton = createWidgetCentered<RecButton>(mm2px(Vec(12.7, 73.624)));
1072+
recButton->module = module;
1073+
addChild(recButton);
10661074

10671075
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(6.697, 97.253)), module, Recorder::GATE_INPUT));
10681076
addInput(createInputCentered<PJ301MPort>(mm2px(Vec(18.703, 97.253)), module, Recorder::TRIG_INPUT));
@@ -1109,19 +1117,18 @@ struct RecorderWidget : ModuleWidget {
11091117
menu->addChild(createMenuLabel("Output file"));
11101118

11111119
std::string path = string::ellipsizePrefix(module->path, 30);
1112-
menu->addChild(createCheckMenuItem((path != "") ? path : "Select...",
1113-
[=]() {return module->isPrimary();},
1120+
menu->addChild(createMenuItem((path != "") ? path : "Select...", "",
11141121
[=]() {selectPath(module);}
11151122
));
11161123

1117-
menu->addChild(createBoolPtrMenuItem("Append -001, -002, etc.", &module->incrementPath));
1124+
menu->addChild(createBoolPtrMenuItem("Append -001, -002, etc.", "", &module->incrementPath));
11181125

11191126
menu->addChild(new MenuSeparator);
11201127
menu->addChild(createMenuLabel("Audio formats"));
11211128

11221129
for (const std::string &format : AUDIO_FORMATS) {
11231130
const FormatInfo &fi = FORMAT_INFO.at(format);
1124-
menu->addChild(createCheckMenuItem(fi.name + " (." + fi.extension + ")",
1131+
menu->addChild(createCheckMenuItem(fi.name + " (." + fi.extension + ")", "",
11251132
[=]() {return format == module->format;},
11261133
[=]() {module->setFormat(format);}
11271134
));
@@ -1132,7 +1139,7 @@ struct RecorderWidget : ModuleWidget {
11321139

11331140
for (const std::string &format : VIDEO_FORMATS) {
11341141
const FormatInfo &fi = FORMAT_INFO.at(format);
1135-
menu->addChild(createCheckMenuItem(fi.name + " (." + fi.extension + ")",
1142+
menu->addChild(createCheckMenuItem(fi.name + " (." + fi.extension + ")", "",
11361143
[=]() {return format == module->format;},
11371144
[=]() {module->setFormat(format);}
11381145
));
@@ -1141,22 +1148,22 @@ struct RecorderWidget : ModuleWidget {
11411148
menu->addChild(new MenuSeparator);
11421149
menu->addChild(createMenuLabel("Encoder settings"));
11431150

1144-
menu->addChild(createSubmenuItem("Sample rate",
1151+
menu->addChild(createSubmenuItem("Sample rate", string::f("%g kHz", module->sampleRate / 1000.0),
11451152
[=](Menu* menu) {
11461153
for (int sampleRate : module->getSampleRates()) {
1147-
menu->addChild(createCheckMenuItem(string::f("%g kHz", sampleRate / 1000.0),
1154+
menu->addChild(createCheckMenuItem(string::f("%g kHz", sampleRate / 1000.0), "",
11481155
[=]() {return module->sampleRate == sampleRate;},
1149-
[=]() {module->setSampleRate(sampleRate); DEBUG("%d", sampleRate);}
1156+
[=]() {module->setSampleRate(sampleRate);}
11501157
));
11511158
}
11521159
}
11531160
));
11541161

11551162
if (module->showDepth()) {
1156-
menu->addChild(createSubmenuItem("Bit depth",
1163+
menu->addChild(createSubmenuItem("Bit depth", string::f("%d bit", module->depth),
11571164
[=](Menu* menu) {
11581165
for (int depth : module->getDepths()) {
1159-
menu->addChild(createCheckMenuItem(string::f("%d bit", depth),
1166+
menu->addChild(createCheckMenuItem(string::f("%d bit", depth), "",
11601167
[=]() {return module->depth == depth;},
11611168
[=]() {module->setDepth(depth);}
11621169
));
@@ -1166,10 +1173,10 @@ struct RecorderWidget : ModuleWidget {
11661173
}
11671174

11681175
if (module->showBitRate()) {
1169-
menu->addChild(createSubmenuItem("Bit rate",
1176+
menu->addChild(createSubmenuItem("Bit rate", string::f("%d kbps", module->bitRate / 1000),
11701177
[=](Menu* menu) {
11711178
for (int bitRate : module->getBitRates()) {
1172-
menu->addChild(createCheckMenuItem(string::f("%d kbps", bitRate / 1000),
1179+
menu->addChild(createCheckMenuItem(string::f("%d kbps", bitRate / 1000), "",
11731180
[=]() {return module->bitRate == bitRate;},
11741181
[=]() {module->setBitRate(bitRate);}
11751182
));
@@ -1178,11 +1185,11 @@ struct RecorderWidget : ModuleWidget {
11781185
));
11791186
}
11801187

1181-
menu->addChild(new MenuSeparator);
1182-
menu->addChild(createCheckMenuItem("Primary audio module",
1183-
[=]() {return module->isPrimary();},
1184-
[=]() {module->setPrimary();}
1185-
));
1188+
// menu->addChild(new MenuSeparator);
1189+
// menu->addChild(createCheckMenuItem("Primary audio module", "",
1190+
// [=]() {return module->isPrimary();},
1191+
// [=]() {module->setPrimary();}
1192+
// ));
11861193
}
11871194

11881195
void step() override {

0 commit comments

Comments
 (0)