Commit fb7e13a0 authored by Jean LeMotan's avatar Jean LeMotan Committed by Jean-Baptiste Mardelle
Browse files

Added audio capture channel & sample rate configuration.

When capturing audio, it's very useful to be able to choose the number of channels and sample rate for the recorded data.
This commit adds that posibility.
parent 67182149
......@@ -88,8 +88,8 @@ void MediaCapture::recordAudio(bool record)
QAudioEncoderSettings audioSettings;
//audioSettings.setCodec("audio/x-flac");
audioSettings.setBitRate(48000); // Bit rate is set to 48,0000
audioSettings.setChannelCount(2);
audioSettings.setSampleRate(KdenliveSettings::audiocapturesamplerate());
audioSettings.setChannelCount(KdenliveSettings::audiocapturechannels());
m_audioRecorder->setEncodingSettings(audioSettings);
m_audioRecorder->setOutputLocation(m_path);
m_audioRecorder->record();
......
......@@ -298,6 +298,28 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(QMap<QString, QString> mappable_a
&KdenliveSettingsDialog::slotUpdateGrabProfile);
connect(m_configCapture.grab_showprofileinfo, &QAbstractButton::clicked, m_configCapture.grab_parameters, &QWidget::setVisible);
// audio capture channels
m_configCapture.audiocapturechannels->clear();
m_configCapture.audiocapturechannels->addItem(i18n("Mono (1 channel)"), 1);
m_configCapture.audiocapturechannels->addItem(i18n("Stereo (2 channels)"), 2);
int channelsIndex = m_configCapture.audiocapturechannels->findData(KdenliveSettings::audiocapturechannels());
m_configCapture.audiocapturechannels->setCurrentIndex(qMax(channelsIndex, 0));
connect(m_configCapture.audiocapturechannels, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&KdenliveSettingsDialog::slotUpdateAudioCaptureChannels);
// audio capture sample rate
m_configCapture.audiocapturesamplerate->clear();
m_configCapture.audiocapturesamplerate->addItem(i18n("44100 Hz"), 44100);
m_configCapture.audiocapturesamplerate->addItem(i18n("48000 Hz"), 48000);
int sampleRateIndex = m_configCapture.audiocapturesamplerate->findData(KdenliveSettings::audiocapturesamplerate());
m_configCapture.audiocapturesamplerate->setCurrentIndex(qMax(sampleRateIndex, 0));
connect(m_configCapture.audiocapturesamplerate, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&KdenliveSettingsDialog::slotUpdateAudioCaptureSampleRate);
m_configCapture.labelNoAudioDevices->setVisible(false);
// Timeline preview
act = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(1);
......@@ -398,6 +420,10 @@ bool KdenliveSettingsDialog::getBlackMagicDeviceList(QComboBox *devicelist, bool
bool KdenliveSettingsDialog::initAudioRecDevice()
{
QStringList audioDevices = pCore->getAudioCaptureDevices();
//show a hint to the user to know what to check for in case the device list are empty (common issue)
m_configCapture.labelNoAudioDevices->setVisible(audioDevices.empty());
m_configCapture.kcfg_defaultaudiocapture->addItems(audioDevices);
connect(m_configCapture.kcfg_defaultaudiocapture, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [&]() {
QString currentDevice = m_configCapture.kcfg_defaultaudiocapture->currentText();
......@@ -1584,3 +1610,13 @@ void KdenliveSettingsDialog::slotReloadShuttleDevices()
QTimer::singleShot(200, this, SLOT(slotUpdateShuttleDevice()));
#endif // USE_JOGSHUTTLE
}
void KdenliveSettingsDialog::slotUpdateAudioCaptureChannels(int index)
{
KdenliveSettings::setAudiocapturechannels(m_configCapture.audiocapturechannels->itemData(index).toInt());
}
void KdenliveSettingsDialog::slotUpdateAudioCaptureSampleRate(int index)
{
KdenliveSettings::setAudiocapturesamplerate(m_configCapture.audiocapturesamplerate->itemData(index).toInt());
}
......@@ -85,6 +85,8 @@ private slots:
void slotReloadBlackMagic();
void slotReloadShuttleDevices();
void loadExternalProxyProfiles();
void slotUpdateAudioCaptureChannels(int index);
void slotUpdateAudioCaptureSampleRate(int index);
private:
KPageWidgetItem *m_page1;
......
......@@ -469,6 +469,16 @@
<default>100</default>
</entry>
<entry name="audiocapturechannels" type="Int">
<label>Audio capture channels</label>
<default>2</default>
</entry>
<entry name="audiocapturesamplerate" type="Int">
<label>Audio capture sample rate</label>
<default>48000</default>
</entry>
<entry name="defaultcapture" type="Int">
<label>Default video capture system.</label>
<default>0</default>
......
......@@ -639,14 +639,44 @@
<string>Audio</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Sample Rate</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Audio Capture Volume </string>
<string>Capture Volume </string>
</property>
</widget>
</item>
<item row="6" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>661</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Channels</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="audiocapturesamplerate"/>
</item>
<item row="3" column="1">
<widget class="QSlider" name="kcfg_audiocapturevolume">
<property name="maximum">
<number>100</number>
......@@ -671,28 +701,30 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="audiocapturechannels"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="kcfg_defaultaudiocapture"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_33">
<property name="text">
<string>Detected devices</string>
<string>Device</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="kcfg_defaultaudiocapture"/>
</item>
<item row="2" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="labelNoAudioDevices">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>661</height>
</size>
<property name="text">
<string>Make sure you have audio plugins installed on your system</string>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment