Commit 4513f0a6 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Update audio mic monitor when record settings changed

parent 695306ae
Pipeline #173819 passed with stage
in 5 minutes and 57 seconds
......@@ -185,6 +185,7 @@ void MediaCapture::switchMonitorState(bool run)
m_levels = level;
emit levelsChanged();
});
m_audioInput->setVolume(KdenliveSettings::audiocapturevolume()/100.0);
m_audioInfo->open(QIODevice::WriteOnly);
m_audioInput->start(m_audioInfo.data());
} else {
......@@ -196,6 +197,11 @@ void MediaCapture::switchMonitorState(bool run)
}
}
bool MediaCapture::isMonitoring() const
{
return m_audioInput != nullptr;
}
MediaCapture::~MediaCapture() = default;
void MediaCapture::displayErrorMessage()
......
......@@ -67,6 +67,8 @@ public:
Q_INVOKABLE QVector<qreal> levels() const;
Q_INVOKABLE int recordState() const;
Q_INVOKABLE void switchMonitorState(bool run);
/** @brief Returns true is audio monitoring is currently in progress **/
bool isMonitoring() const;
public slots:
void displayErrorMessage();
......
......@@ -1029,6 +1029,14 @@ MediaCapture *Core::getAudioDevice()
return m_capture.get();
}
void Core::resetAudioMonitoring()
{
if (m_capture && m_capture->isMonitoring()) {
m_capture->switchMonitorState(false);
m_capture->switchMonitorState(true);
}
}
QString Core::getProjectFolderName()
{
if (currentDoc()) {
......
......@@ -345,6 +345,8 @@ public slots:
void addBin(const QString &id = QString());
/** @brief Transcode a bin clip video. */
void transcodeFriendlyFile(const QString &binId, bool checkProfile);
/** @brief Reset audio monitoring volume and channels. */
void resetAudioMonitoring();
signals:
void coreIsReady();
......
......@@ -399,9 +399,9 @@ void KdenliveSettingsDialog::initCapturePage()
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);
connect(m_configCapture.audiocapturechannels, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [&]() {
updateButtons();
});
// audio capture sample rate
m_configCapture.audiocapturesamplerate->clear();
m_configCapture.audiocapturesamplerate->addItem(i18n("44100 Hz"), 44100);
......@@ -409,8 +409,9 @@ void KdenliveSettingsDialog::initCapturePage()
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);
connect(m_configCapture.audiocapturesamplerate, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [&]() {
updateButtons();
});
m_configCapture.labelNoAudioDevices->setVisible(false);
......@@ -1038,6 +1039,14 @@ void KdenliveSettingsDialog::updateSettings()
emit updateFullScreenGrab();
}
// Check audio capture changes
if (KdenliveSettings::audiocapturechannels() != m_configCapture.audiocapturechannels->currentData().toInt() || KdenliveSettings::audiocapturevolume() != m_configCapture.kcfg_audiocapturevolume->value() || KdenliveSettings::audiocapturesamplerate() != m_configCapture.audiocapturesamplerate->currentData().toInt()) {
KdenliveSettings::setAudiocapturechannels(m_configCapture.audiocapturechannels->currentData().toInt());
KdenliveSettings::setAudiocapturevolume(m_configCapture.kcfg_audiocapturevolume->value());
KdenliveSettings::setAudiocapturesamplerate(m_configCapture.audiocapturesamplerate->currentData().toInt());
emit resetAudioMonitoring();
}
// Check encoding profiles
// FFmpeg
QString string = m_v4lProfiles->currentParams();
......@@ -1431,6 +1440,12 @@ bool KdenliveSettingsDialog::hasChanged()
if (m_modified || m_shuttleModified) {
return true;
}
if (KdenliveSettings::audiocapturechannels() != m_configCapture.audiocapturechannels->currentData().toInt()) {
return true;
}
if (KdenliveSettings::audiocapturesamplerate() != m_configCapture.audiocapturesamplerate->currentData().toInt()) {
return true;
}
return KConfigDialog::hasChanged();
}
......@@ -1635,16 +1650,6 @@ void KdenliveSettingsDialog::slotReloadShuttleDevices()
#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());
}
void KdenliveSettingsDialog::initSpeechPage()
{
m_stt = new SpeechToText();
......
......@@ -88,8 +88,6 @@ private slots:
void slotReloadBlackMagic();
void slotReloadShuttleDevices();
void loadExternalProxyProfiles();
void slotUpdateAudioCaptureChannels(int index);
void slotUpdateAudioCaptureSampleRate(int index);
void slotParseVoskDictionaries();
void getDictionary(const QUrl &sourceUrl = QUrl());
void removeDictionary();
......@@ -178,4 +176,6 @@ signals:
void updateMonitorBg();
/** @brief Trigger parsing of the speech models folder */
void parseDictionaries();
/** @brief audio volume or rec channels changed, update audio monitor view */
void resetAudioMonitoring();
};
......@@ -2448,6 +2448,7 @@ void MainWindow::slotPreferences(int page, int option)
connect(dialog, &KdenliveSettingsDialog::updateMonitorBg, [&]() {
pCore->monitorManager()->updateBgColor();
});
connect(dialog, &KdenliveSettingsDialog::resetAudioMonitoring, pCore.get(), &Core::resetAudioMonitoring);
dialog->show();
if (page != -1) {
......
......@@ -4,6 +4,7 @@
*/
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtGraphicalEffects 1.0
import QtQuick.Layouts 1.11
......@@ -18,11 +19,14 @@ Item {
if (recState == 1) {
// Recording
recbutton.color = 'orange'
recbutton.ToolTip.text = i18n("Stop")
} else if (recState == 2) {
// Paused
recbutton.color = 'white'
recbutton.ToolTip.text = i18n("Paused")
} else {
recbutton.color = 'darkred'
recbutton.ToolTip.text = i18n("Record")
}
}
RowLayout {
......@@ -35,7 +39,12 @@ Item {
radius: root.baseUnit * .75
color: trackHeadRoot.isLocked ? 'grey' : 'darkred'
border.color: 'black'
ToolTip.visible: buttonArea.containsMouse
ToolTip.delay: 1000
ToolTip.timeout: 5000
ToolTip.text: i18n("Record")
MouseArea {
id: buttonArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
......@@ -57,6 +66,10 @@ Item {
id: levelsContainer
width: recContainer.width - recbutton.width - 6
height: recbutton.height
ToolTip.text: i18n("Mic level")
ToolTip.visible: levelArea.containsMouse
ToolTip.delay: 1000
ToolTip.timeout: 5000
color: Qt.lighter(activePalette.base)
Repeater {
model: audiorec.levels.length === 0 ? 2 : audiorec.levels.length
......@@ -67,12 +80,14 @@ Item {
anchors.fill: parent
anchors.margins: 0.5
start: Qt.point(0,0)
end: Qt.point(recContainer.width, 0)
end: Qt.point(levelsContainer.width, 0)
gradient: Gradient {
GradientStop { position: 0.0; color: "green" }
GradientStop { position: 0.6; color: "greenyellow" }
GradientStop { position: 0.7; color: "yellow" }
GradientStop { position: 0.9; color: "gold" }
GradientStop { position: 0.0; color: "darkgreen" }
GradientStop { position: 0.69; color: "darkgreen" }
GradientStop { position: 0.7; color: "green" }
GradientStop { position: 0.84; color: "green" }
GradientStop { position: 0.85; color: "yellow" }
GradientStop { position: 0.99; color: "yellow" }
GradientStop { position: 1.0; color: "red" }
}
}
......@@ -90,7 +105,8 @@ Item {
property double currentLevel: audiorec.levels.length <= 0 ? 0 : audiorec.levels[index]
property double peak: 0
Rectangle {
color: "#cc000000"
color: activePalette.base
opacity: 0.9
width: parent.width * (1.0 - currentLevel)
anchors.right: parent.right
height: parent.height / levelRepeater.count
......@@ -130,6 +146,12 @@ Item {
border.color: "#000000"
border.width: 1
}
MouseArea {
id: levelArea
hoverEnabled: true
anchors.fill: parent
acceptedButtons: Qt.NoButton
}
}
}
}
Supports Markdown
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