From 4c661b5109a1829524f6b90f7debe9fc4093eecd Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Thu, 20 Feb 2020 11:24:39 -0500 Subject: [PATCH] Add 1/2 and 1/4x sample rate to menu bar. --- src/app/MenuBar.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 1e577b52..cf0d21db 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -501,17 +501,21 @@ struct SampleRateItem : ui::MenuItem { enginePauseItem->rightText = CHECKMARK(APP->engine->isPaused()); menu->addChild(enginePauseItem); - for (int i = 0; i <= 4; i++) { + for (int i = -2; i <= 4; i++) { for (int j = 0; j < 2; j++) { - int oversample = 1 << i; + float oversample = std::pow(2.f, i); float sampleRate = (j == 0) ? 44100.f : 48000.f; sampleRate *= oversample; SampleRateValueItem* item = new SampleRateValueItem; item->sampleRate = sampleRate; item->text = string::f("%g kHz", sampleRate / 1000.0); - if (oversample > 1) - item->rightText += string::f("(%dx)", oversample); + if (oversample > 1.f) { + item->rightText += string::f("(%.0fx)", oversample); + } + else if (oversample < 1.f) { + item->rightText += string::f("(1/%.0fx)", 1.f / oversample); + } item->rightText += " "; item->rightText += CHECKMARK(settings::sampleRate == sampleRate); menu->addChild(item);