Commit 4c99375c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Audio record: remove rec button from audio mixers. Recording is now enabled by...

Audio record: remove rec button from audio mixers. Recording is now enabled by enabling monitoring (mic icon), then space bar/Esc to record/stop
parent a29263ba
Pipeline #180276 passed with stage
in 9 minutes and 5 seconds
......@@ -70,6 +70,7 @@ void MixerManager::monitorAudio(int tid, bool monitor)
}
m_monitorTrack = -1;
pCore->getAudioDevice()->switchMonitorState(false);
pCore->monitorAudio(tid, false);
return;
}
// We want to monitor audio
......@@ -81,6 +82,7 @@ void MixerManager::monitorAudio(int tid, bool monitor)
}
m_monitorTrack = -1;
} else {
pCore->displayMessage(i18n("Monitoring audio. Press <b>Space</b> to start/pause recording, <b>Esc</b> to end."), InformationMessage, 8000);
pCore->getAudioDevice()->switchMonitorState(true);
}
if (m_mixers.count(tid) > 0) {
......@@ -273,3 +275,8 @@ void MixerManager::pauseMonitoring(bool pause)
m_masterMixer->pauseMonitoring(pause);
}
}
int MixerManager::recordTrack() const
{
return m_monitorTrack;
}
......@@ -42,6 +42,8 @@ public:
void checkAudioLevelVersion();
/** @brief Enable/disable audio monitoring on a track */
void monitorAudio(int tid, bool monitor);
/** @brief Track currently monitored that will be used for recording */
int recordTrack() const;
public slots:
void recordStateChanged(int tid, bool recording);
......@@ -51,7 +53,6 @@ private slots:
signals:
void updateLevels(int);
void recordAudio(int tid);
void purgeCache();
void clearMixers();
void updateRecVolume();
......
......@@ -92,7 +92,6 @@ MixerWidget::MixerWidget(int tid, std::shared_ptr<Mlt::Tractor> service, QString
, m_balanceSlider(nullptr)
, m_maxLevels(qMax(30, int(service->get_fps() * 1.5)))
, m_solo(nullptr)
, m_record(nullptr)
, m_collapse(nullptr)
, m_monitor(nullptr)
, m_lastVolume(0)
......@@ -114,7 +113,6 @@ MixerWidget::MixerWidget(int tid, Mlt::Tractor *service, QString trackTag, const
, m_balanceSlider(nullptr)
, m_maxLevels(qMax(30, int(service->get_fps() * 1.5)))
, m_solo(nullptr)
, m_record(nullptr)
, m_collapse(nullptr)
, m_monitor(nullptr)
, m_lastVolume(0)
......@@ -154,7 +152,7 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackName)
m_volumeSpin->setFrame(false);
connect(m_volumeSpin, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged), this, [&](double val) {
if (m_recording || (m_monitor && m_monitor->isChecked())) {
if (m_monitor && m_monitor->isChecked()) {
m_volumeSlider->setValue(val);
} else {
m_volumeSlider->setValue(fromDB(val));
......@@ -289,11 +287,6 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackName)
emit toggleSolo(m_tid, toggled);
updateLabel();
});
m_record = new QToolButton(this);
m_record->setIcon(QIcon::fromTheme("media-record"));
m_record->setToolTip(i18n("Record"));
m_record->setCheckable(true);
m_record->setAutoRaise(true);
m_monitor = new QToolButton(this);
m_monitor->setIcon(QIcon::fromTheme("audio-input-microphone"));
......@@ -303,13 +296,6 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackName)
connect(m_monitor, &QToolButton::toggled, this, [&](bool toggled) {
m_manager->monitorAudio(m_tid, toggled);
});
connect(m_record, &QToolButton::clicked, this, [&]() {
if (!m_monitor->isChecked()) {
// Start monitoring first
emit m_manager->monitorAudio(m_tid, true);
}
emit m_manager->recordAudio(m_tid);
});
} else {
m_collapse = new QToolButton(this);
m_collapse->setIcon(KdenliveSettings::mixerCollapse() ? QIcon::fromTheme("arrow-left") : QIcon::fromTheme("arrow-right"));
......@@ -322,15 +308,14 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackName)
m_collapse->setIcon(m_collapse->isChecked() ? QIcon::fromTheme("arrow-left") : QIcon::fromTheme("arrow-right"));
m_manager->collapseMixers();
});
showEffects = new QToolButton(this);
showEffects->setIcon(QIcon::fromTheme("autocorrection"));
showEffects->setToolTip(i18n("Open Effect Stack"));
showEffects->setAutoRaise(true);
connect(showEffects, &QToolButton::clicked, this, [&]() {
emit m_manager->showEffectStack(m_tid);
});
}
showEffects = new QToolButton(this);
showEffects->setIcon(QIcon::fromTheme("autocorrection"));
showEffects->setToolTip(i18n("Open Effect Stack"));
showEffects->setAutoRaise(true);
connect(showEffects, &QToolButton::clicked, this, [&]() {
emit m_manager->showEffectStack(m_tid);
});
connect(m_volumeSlider, &QSlider::valueChanged, this, [&](int value) {
QSignalBlocker bk(m_volumeSpin);
......@@ -382,9 +367,6 @@ void MixerWidget::buildUI(Mlt::Tractor *service, const QString &trackName)
if (m_solo) {
buttonslay->addWidget(m_solo);
}
if (m_record) {
buttonslay->addWidget(m_record);
}
if (m_monitor) {
buttonslay->addWidget(m_monitor);
}
......@@ -530,7 +512,7 @@ void MixerWidget::updateMonitorState()
{
QSignalBlocker bk(m_volumeSpin);
QSignalBlocker bk2(m_volumeSlider);
if (m_recording || (m_monitor && m_monitor->isChecked())) {
if (m_monitor && m_monitor->isChecked()) {
connect(pCore->getAudioDevice(), &MediaCapture::audioLevels, this, &MixerWidget::gotRecLevels);
if (m_balanceSlider) {
m_balanceSlider->setEnabled(false);
......@@ -571,7 +553,6 @@ void MixerWidget::monitorAudio(bool monitor)
void MixerWidget::setRecordState(bool recording)
{
m_recording = recording;
m_record->setChecked(m_recording);
updateMonitorState();
}
......
......@@ -89,7 +89,6 @@ private:
std::shared_ptr<AudioLevelWidget> m_audioMeterWidget;
QSlider *m_volumeSlider;
QToolButton *m_solo;
QToolButton *m_record;
QToolButton *m_collapse;
QToolButton *m_monitor;
KSqueezedTextLabel *m_trackLabel;
......
......@@ -236,7 +236,7 @@ const QVector<double> MediaCapture::recLevels() const
bool MediaCapture::isMonitoring() const
{
return m_audioInput != nullptr;
return m_audioInput != nullptr && !isRecording();
}
MediaCapture::~MediaCapture() = default;
......
......@@ -1031,11 +1031,21 @@ int Core::getMediaCaptureState()
return m_capture->getState();
}
bool Core::isMediaCapturing()
bool Core::isMediaMonitoring() const
{
return m_capture->isMonitoring();
}
bool Core::isMediaCapturing() const
{
return m_capture->isRecording();
}
void Core::switchCapture()
{
emit recordAudio(-1);
}
MediaCapture *Core::getAudioDevice()
{
return m_capture.get();
......
......@@ -218,7 +218,8 @@ public:
void stopMediaCapture(int tid, bool, bool);
QStringList getAudioCaptureDevices();
int getMediaCaptureState();
bool isMediaCapturing();
bool isMediaMonitoring() const;
bool isMediaCapturing() const;
MediaCapture *getAudioDevice();
/** @brief Returns Project Folder name for capture output location */
QString getProjectFolderName();
......@@ -280,6 +281,8 @@ public:
/** @brief Returns true if the audio mixer widget is visible */
bool audioMixerVisible{false};
QString packageType() { return m_packageType; };
/** @brief Start / stop audio capture */
void switchCapture();
private:
explicit Core(const QString &packageType);
......@@ -384,4 +387,6 @@ signals:
void updateMixerLevels(int pos);
/** @brief Audio recording was started or stopped*/
void switchTimelineRecord(bool on);
/** @brief Launch audio recording on track tid*/
void recordAudio(int tid);
};
......@@ -2735,8 +2735,11 @@ void MainWindow::slotSwitchTrackAudioStream()
void MainWindow::slotShowTrackRec(bool checked)
{
pCore->mixer()->monitorAudio(getCurrentTimeline()->controller()->activeTrack(), checked);
getCurrentTimeline()->controller()->switchTrackRecord(-1, checked);
if (checked) {
pCore->mixer()->monitorAudio(getCurrentTimeline()->controller()->activeTrack(), checked);
} else {
pCore->mixer()->monitorAudio(pCore->mixer()->recordTrack(), false);
}
}
void MainWindow::slotSelectTrack()
......@@ -4395,6 +4398,14 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
switch (event->type()) {
case QEvent::ShortcutOverride:
if (static_cast<QKeyEvent *>(event)->key() == Qt::Key_Escape) {
if (pCore->isMediaMonitoring()) {
slotShowTrackRec(false);
return true;
}
if (pCore->isMediaCapturing()) {
pCore->switchCapture();
return true;
}
if (m_activeTool != ToolType::SelectTool) {
m_buttonSelectTool->trigger();
return true;
......
......@@ -1547,6 +1547,8 @@ void Monitor::slotSwitchPlay()
} else if (recState == QMediaRecorder::PausedState && play) {
pCore->getAudioDevice()->resumeRecording();
}
} else if (pCore->getAudioDevice()->isMonitoring()) {
pCore->recordAudio(-1);
}
m_glMonitor->switchPlay(play, m_offset);
bool showDropped = false;
......
......@@ -167,7 +167,7 @@ void StatusBarMessageLabel::setMessage(const QString &text, MessageType type, in
qCDebug(KDENLIVE_LOG) << item.text;
// Put the new error message at first place and immediately show it
item.timeoutMillis = qMax(item.timeoutMillis, 3000);
item.timeoutMillis = qMax(item.timeoutMillis, 4000);
if (item.type == ProcessingJobMessage) {
// This is a job progress info, discard previous ones
......@@ -190,7 +190,7 @@ void StatusBarMessageLabel::setMessage(const QString &text, MessageType type, in
m_queueTimer.start(delay);
} else {
// Message with normal priority
item.timeoutMillis = qMax(item.timeoutMillis, 2000);
item.timeoutMillis = qMax(item.timeoutMillis, 4000);
m_messageQueue.push_back(item);
if (!m_queueTimer.isValid() || m_queueTimer.elapsed() >= m_currentMessage.timeoutMillis) {
m_queueTimer.start(0);
......
......@@ -531,9 +531,6 @@ Rectangle {
visible: showAudioRecord && (trackHeadRoot.height >= 2 * root.collapsedHeight + resizer.height)
source: isAudio && showAudioRecord ? "AudioLevels.qml" : ""
onLoaded: item.trackId = trackId
onVisibleChanged: {
audiorec.switchMonitorState(trackId, audioVuMeter.visible)
}
}
}
Item {
......
......@@ -70,7 +70,7 @@ TimelineController::TimelineController(QObject *parent)
m_disablePreview->setEnabled(false);
connect(pCore.get(), &Core::finalizeRecording, this, &TimelineController::finishRecording);
connect(pCore.get(), &Core::autoScrollChanged, this, &TimelineController::autoScrollChanged);
connect(pCore->mixer(), &MixerManager::recordAudio, this, &TimelineController::switchRecording);
connect(pCore.get(), &Core::recordAudio, this, &TimelineController::switchRecording);
}
TimelineController::~TimelineController()
......@@ -4497,6 +4497,9 @@ QColor TimelineController::selectionColor() const
void TimelineController::switchRecording(int trackId)
{
if (trackId == -1) {
trackId = pCore->mixer()->recordTrack();
}
if (!pCore->isMediaCapturing()) {
qDebug() << "start recording" << trackId;
if (!m_model->isTrack(trackId)) {
......
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