MCPcopy Create free account
hub / github.com/VCVRack/Rack / createChildMenu

Method createChildMenu

src/app/MenuBar.cpp:644–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642
643struct SampleRateItem : ui::MenuItem {
644 ui::Menu* createChildMenu() override {
645 ui::Menu* menu = new ui::Menu;
646
647 // Auto sample rate
648 std::string rightText;
649 if (settings::sampleRate == 0) {
650 float sampleRate = APP->engine->getSampleRate();
651 rightText += string::f("(%g kHz) ", sampleRate / 1000.f);
652 }
653 menu->addChild(createCheckMenuItem(string::translate("MenuBar.engine.sampleRate.auto"), rightText,
654 [=]() {return settings::sampleRate == 0;},
655 [=]() {settings::sampleRate = 0;}
656 ));
657
658 // Power-of-2 oversample times 44.1kHz or 48kHz
659 for (int i = -2; i <= 4; i++) {
660 for (int j = 0; j < 2; j++) {
661 float oversample = std::pow(2.f, i);
662 float sampleRate = (j == 0) ? 44100.f : 48000.f;
663 sampleRate *= oversample;
664
665 std::string text = string::f("%g kHz", sampleRate / 1000.f);
666 std::string rightText;
667 if (oversample > 1.f) {
668 rightText += string::f("(%.0fx)", oversample);
669 }
670 else if (oversample < 1.f) {
671 rightText += string::f("(1/%.0fx)", 1.f / oversample);
672 }
673 menu->addChild(createCheckMenuItem(text, rightText,
674 [=]() {return settings::sampleRate == sampleRate;},
675 [=]() {settings::sampleRate = sampleRate;}
676 ));
677 }
678 }
679 return menu;
680 }
681};
682
683

Callers

nothing calls this directly

Calls 6

createCheckMenuItemFunction · 0.85
translateFunction · 0.85
powFunction · 0.85
addChildMethod · 0.80
fFunction · 0.50
getSampleRateMethod · 0.45

Tested by

no test coverage detected