Skip to content

Commit

Permalink
sample rate setting
Browse files Browse the repository at this point in the history
  • Loading branch information
zynskeywolf committed Feb 23, 2024
1 parent 360254f commit 557ebad
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions include/SetupDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private slots:
void updateBufferSizeWarning(int value);
void setBufferSize(int value);
void resetBufferSize();
void updateSampleRates();

// MIDI settings widget.
void midiInterfaceChanged(const QString & driver);
Expand Down Expand Up @@ -180,6 +181,7 @@ private slots:
trMap m_audioIfaceNames;
bool m_NaNHandler;
bool m_hqAudioDev;
QComboBox * m_sampleRate;
int m_bufferSize;
QSlider * m_bufferSizeSlider;
QLabel * m_bufferSizeLbl;
Expand Down
34 changes: 31 additions & 3 deletions src/gui/modals/SetupDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <QGroupBox>
#include <QImageReader>
#include <QLabel>
#include <QLayout>
#include <QFormLayout>
#include <QLineEdit>
#include <QScrollArea>

Expand Down Expand Up @@ -469,10 +469,18 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :

// Audio interface group
QGroupBox * audioInterfaceBox = new QGroupBox(tr("Audio interface"), audio_w);
QVBoxLayout * audioInterfaceLayout = new QVBoxLayout(audioInterfaceBox);
QFormLayout * audioInterfaceLayout = new QFormLayout(audioInterfaceBox);

QLabel * audioBackendLabel = new QLabel(audioInterfaceBox);
audioBackendLabel->setText(tr("Backend"));
m_audioInterfaces = new QComboBox(audioInterfaceBox);
audioInterfaceLayout->addWidget(m_audioInterfaces);
audioInterfaceLayout->addRow(audioBackendLabel,m_audioInterfaces);

QLabel * sampleRateLabel = new QLabel(audioInterfaceBox);
sampleRateLabel->setText(tr("Sample rate"));
m_sampleRate = new QComboBox(audioInterfaceBox);
audioInterfaceLayout->addRow(sampleRateLabel,m_sampleRate);
updateSampleRates();

// Ifaces-settings-widget.
auto as_w = new QWidget(audio_w);
Expand Down Expand Up @@ -960,6 +968,8 @@ void SetupDialog::accept()
QString::number(m_NaNHandler));
ConfigManager::inst()->setValue("audioengine", "hqaudio",
QString::number(m_hqAudioDev));
ConfigManager::inst()->setValue("audioengine", "samplerate",
m_sampleRate->currentText());
ConfigManager::inst()->setValue("audioengine", "framesperaudiobuffer",
QString::number(m_bufferSize));
ConfigManager::inst()->setValue("audioengine", "mididev",
Expand Down Expand Up @@ -1181,6 +1191,8 @@ void SetupDialog::audioInterfaceChanged(const QString & iface)
}

m_audioIfaceSetupWidgets[m_audioIfaceNames[iface]]->show();

updateSampleRates();
}


Expand Down Expand Up @@ -1240,6 +1252,22 @@ void SetupDialog::resetBufferSize()
setBufferSize(DEFAULT_BUFFER_SIZE / BUFFERSIZE_RESOLUTION);
}

void SetupDialog::updateSampleRates()
{
m_sampleRate->clear();
if (m_audioInterfaces->currentText() == "JACK (JACK Audio Connection Kit)")
{
m_sampleRate->setDisabled(true);
}
else
{
// TODO: Dynamically get available sample rates from backend
m_sampleRate->addItems({"44100","48000","88200","96000","176400","192000"});
m_sampleRate->setCurrentText(QString::number(Engine::audioEngine()->outputSampleRate()));
m_sampleRate->setDisabled(false);
}
}


// MIDI settings slots.

Expand Down

0 comments on commit 557ebad

Please sign in to comment.