Audio output device recording: GUI and settings

pull/1512/head
f4exb 2022-11-08 22:55:40 +01:00
rodzic e319267b0f
commit e89331f58f
4 zmienionych plików z 172 dodań i 1 usunięć

Wyświetl plik

@ -62,7 +62,9 @@ public:
udpUseRTP(false), udpUseRTP(false),
udpChannelMode(AudioOutputDevice::UDPChannelLeft), udpChannelMode(AudioOutputDevice::UDPChannelLeft),
udpChannelCodec(AudioOutputDevice::UDPCodecL16), udpChannelCodec(AudioOutputDevice::UDPCodecL16),
udpDecimationFactor(1) udpDecimationFactor(1),
recordToFile(false),
recordSilenceTime(0)
{} {}
void resetToDefaults() { void resetToDefaults() {
sampleRate = m_defaultAudioSampleRate; sampleRate = m_defaultAudioSampleRate;
@ -73,6 +75,9 @@ public:
udpChannelMode = AudioOutputDevice::UDPChannelLeft; udpChannelMode = AudioOutputDevice::UDPChannelLeft;
udpChannelCodec = AudioOutputDevice::UDPCodecL16; udpChannelCodec = AudioOutputDevice::UDPCodecL16;
udpDecimationFactor = 1; udpDecimationFactor = 1;
fileRecordName.clear();
recordToFile = false;
recordSilenceTime = 0;
} }
int sampleRate; int sampleRate;
QString udpAddress; QString udpAddress;
@ -82,6 +87,9 @@ public:
AudioOutputDevice::UDPChannelMode udpChannelMode; AudioOutputDevice::UDPChannelMode udpChannelMode;
AudioOutputDevice::UDPChannelCodec udpChannelCodec; AudioOutputDevice::UDPChannelCodec udpChannelCodec;
uint32_t udpDecimationFactor; uint32_t udpDecimationFactor;
QString fileRecordName;
bool recordToFile;
int recordSilenceTime; //!< 100's ms
friend QDataStream& operator<<(QDataStream& ds, const OutputDeviceInfo& info); friend QDataStream& operator<<(QDataStream& ds, const OutputDeviceInfo& info);
friend QDataStream& operator>>(QDataStream& ds, OutputDeviceInfo& info); friend QDataStream& operator>>(QDataStream& ds, OutputDeviceInfo& info);
}; };

Wyświetl plik

@ -20,6 +20,7 @@
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog>
#include "audio/audiodevicemanager.h" #include "audio/audiodevicemanager.h"
#include "audiodialog.h" #include "audiodialog.h"
@ -259,6 +260,44 @@ void AudioDialogX::on_outputUDPChannelMode_currentIndexChanged(int index)
check(); check();
} }
void AudioDialogX::on_record_toggled(bool checked)
{
ui->showFileDialog->setEnabled(!checked);
m_outputDeviceInfo.recordToFile = checked;
}
void AudioDialogX::on_showFileDialog_clicked(bool checked)
{
(void) checked;
QFileDialog fileDialog(
this,
tr("Save record file"),
m_outputDeviceInfo.fileRecordName,
tr("WAV Files (*.wav)")
);
fileDialog.setOptions(QFileDialog::DontUseNativeDialog);
fileDialog.setFileMode(QFileDialog::AnyFile);
QStringList fileNames;
if (fileDialog.exec())
{
fileNames = fileDialog.selectedFiles();
if (fileNames.size() > 0)
{
m_outputDeviceInfo.fileRecordName = fileNames.at(0);
ui->fileNameText->setText(m_outputDeviceInfo.fileRecordName);
}
}
}
void AudioDialogX::on_recordSilenceTime_valueChanged(int value)
{
m_outputDeviceInfo.recordSilenceTime = value;
ui->recordSilenceText->setText(tr("%1").arg(value / 10.0, 0, 'f', 1));
}
void AudioDialogX::updateOutputDisplay() void AudioDialogX::updateOutputDisplay()
{ {
ui->outputSampleRate->blockSignals(true); ui->outputSampleRate->blockSignals(true);
@ -274,6 +313,11 @@ void AudioDialogX::updateOutputDisplay()
ui->outputUDPChannelMode->setCurrentIndex((int) m_outputDeviceInfo.udpChannelMode); ui->outputUDPChannelMode->setCurrentIndex((int) m_outputDeviceInfo.udpChannelMode);
ui->outputUDPChannelCodec->setCurrentIndex((int) m_outputDeviceInfo.udpChannelCodec); ui->outputUDPChannelCodec->setCurrentIndex((int) m_outputDeviceInfo.udpChannelCodec);
ui->decimationFactor->setCurrentIndex(m_outputDeviceInfo.udpDecimationFactor == 0 ? 0 : m_outputDeviceInfo.udpDecimationFactor - 1); ui->decimationFactor->setCurrentIndex(m_outputDeviceInfo.udpDecimationFactor == 0 ? 0 : m_outputDeviceInfo.udpDecimationFactor - 1);
ui->record->setChecked(m_outputDeviceInfo.recordToFile);
ui->fileNameText->setText(m_outputDeviceInfo.fileRecordName);
ui->showFileDialog->setEnabled(!m_outputDeviceInfo.recordToFile);
ui->recordSilenceTime->setValue(m_outputDeviceInfo.recordSilenceTime);
ui->recordSilenceText->setText(tr("%1").arg(m_outputDeviceInfo.recordSilenceTime / 10.0, 0, 'f', 1));
updateOutputSDPString(); updateOutputSDPString();
@ -293,6 +337,9 @@ void AudioDialogX::updateOutputDeviceInfo()
m_outputDeviceInfo.udpChannelMode = (AudioOutputDevice::UDPChannelMode) ui->outputUDPChannelMode->currentIndex(); m_outputDeviceInfo.udpChannelMode = (AudioOutputDevice::UDPChannelMode) ui->outputUDPChannelMode->currentIndex();
m_outputDeviceInfo.udpChannelCodec = (AudioOutputDevice::UDPChannelCodec) ui->outputUDPChannelCodec->currentIndex(); m_outputDeviceInfo.udpChannelCodec = (AudioOutputDevice::UDPChannelCodec) ui->outputUDPChannelCodec->currentIndex();
m_outputDeviceInfo.udpDecimationFactor = ui->decimationFactor->currentIndex() + 1; m_outputDeviceInfo.udpDecimationFactor = ui->decimationFactor->currentIndex() + 1;
m_outputDeviceInfo.recordToFile = ui->record->isChecked();
m_outputDeviceInfo.fileRecordName = ui->fileNameText->text();
m_outputDeviceInfo.recordSilenceTime = ui->recordSilenceTime->value();
} }
void AudioDialogX::updateOutputSDPString() void AudioDialogX::updateOutputSDPString()

Wyświetl plik

@ -52,6 +52,9 @@ private slots:
void on_decimationFactor_currentIndexChanged(int index); void on_decimationFactor_currentIndexChanged(int index);
void on_outputUDPChannelCodec_currentIndexChanged(int index); void on_outputUDPChannelCodec_currentIndexChanged(int index);
void on_outputUDPChannelMode_currentIndexChanged(int index); void on_outputUDPChannelMode_currentIndexChanged(int index);
void on_record_toggled(bool checked);
void on_showFileDialog_clicked(bool checked);
void on_recordSilenceTime_valueChanged(int value);
}; };
#endif // INCLUDE_AUDIODIALOG_H #endif // INCLUDE_AUDIODIALOG_H

Wyświetl plik

@ -390,6 +390,119 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<layout class="QHBoxLayout" name="fileNameLayout">
<item>
<widget class="ButtonSwitch" name="record">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Start/stop recording</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/record_off.png</normaloff>:/record_off.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="showFileDialog">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Open file</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../resources/res.qrc">
<normaloff>:/preset-load.png</normaloff>:/preset-load.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fileNameText">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Current recording file</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDial" name="recordSilenceTime">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Silence time (s) before recording is stopoed. 0 for continuous recording.</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="recordSilenceText">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Silence time (s) before recording is stopoed</string>
</property>
<property name="text">
<string>10.0</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item> <item>
<layout class="QHBoxLayout" name="outputGeneralLayout"> <layout class="QHBoxLayout" name="outputGeneralLayout">
<item> <item>