mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-06-24 21:15:24 -04:00
Multiple audio support: Select output device in AM demod
This commit is contained in:
parent
095ab14a14
commit
a049e3aaa6
@ -218,9 +218,6 @@ bool AMDemod::handleMessage(const Message& cmd)
|
|||||||
applyAudioSampleRate(sampleRate);
|
applyAudioSampleRate(sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
AMDemodSettings settings = m_settings;
|
|
||||||
applyAudioSampleRate(cfg.getSampleRate());
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -283,6 +280,7 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
|
|||||||
<< " m_copyAudioUseRTP: " << settings.m_copyAudioUseRTP
|
<< " m_copyAudioUseRTP: " << settings.m_copyAudioUseRTP
|
||||||
<< " m_udpAddress: " << settings.m_udpAddress
|
<< " m_udpAddress: " << settings.m_udpAddress
|
||||||
<< " m_udpPort: " << settings.m_udpPort
|
<< " m_udpPort: " << settings.m_udpPort
|
||||||
|
<< " m_audioDeviceName: " << settings.m_audioDeviceName
|
||||||
<< " force: " << force;
|
<< " force: " << force;
|
||||||
|
|
||||||
if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) ||
|
if((m_settings.m_rfBandwidth != settings.m_rfBandwidth) ||
|
||||||
@ -312,21 +310,34 @@ void AMDemod::applySettings(const AMDemodSettings& settings, bool force)
|
|||||||
if (settings.m_copyAudioUseRTP)
|
if (settings.m_copyAudioUseRTP)
|
||||||
{
|
{
|
||||||
if (m_audioNetSink->selectType(AudioNetSink::SinkRTP)) {
|
if (m_audioNetSink->selectType(AudioNetSink::SinkRTP)) {
|
||||||
qDebug("NFMDemod::applySettings: set audio sink to RTP mode");
|
qDebug("AMDemod::applySettings: set audio sink to RTP mode");
|
||||||
} else {
|
} else {
|
||||||
qWarning("NFMDemod::applySettings: RTP support for audio sink not available. Fall back too UDP");
|
qWarning("AMDemod::applySettings: RTP support for audio sink not available. Fall back too UDP");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_audioNetSink->selectType(AudioNetSink::SinkUDP)) {
|
if (m_audioNetSink->selectType(AudioNetSink::SinkUDP)) {
|
||||||
qDebug("NFMDemod::applySettings: set audio sink to UDP mode");
|
qDebug("AMDemod::applySettings: set audio sink to UDP mode");
|
||||||
} else {
|
} else {
|
||||||
qWarning("NFMDemod::applySettings: failed to set audio sink to UDP mode");
|
qWarning("AMDemod::applySettings: failed to set audio sink to UDP mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((settings.m_audioDeviceName != m_settings.m_audioDeviceName) || force)
|
||||||
|
{
|
||||||
|
AudioDeviceManager *audioDeviceManager = DSPEngine::instance()->getAudioDeviceManager();
|
||||||
|
int audioDeviceIndex = audioDeviceManager->getOutputDeviceIndex(settings.m_audioDeviceName);
|
||||||
|
//qDebug("AMDemod::applySettings: audioDeviceName: %s audioDeviceIndex: %d", qPrintable(settings.m_audioDeviceName), audioDeviceIndex);
|
||||||
|
audioDeviceManager->addAudioSink(&m_audioFifo, getInputMessageQueue(), audioDeviceIndex);
|
||||||
|
uint32_t audioSampleRate = audioDeviceManager->getOutputSampleRate(audioDeviceIndex);
|
||||||
|
|
||||||
|
if (m_audioSampleRate != audioSampleRate) {
|
||||||
|
applyAudioSampleRate(audioSampleRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_settings = settings;
|
m_settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include "device/devicesourceapi.h"
|
#include "device/devicesourceapi.h"
|
||||||
#include "device/deviceuiset.h"
|
#include "device/deviceuiset.h"
|
||||||
#include "dsp/downchannelizer.h"
|
#include "dsp/downchannelizer.h"
|
||||||
|
#include "dsp/dspengine.h"
|
||||||
#include "dsp/threadedbasebandsamplesink.h"
|
#include "dsp/threadedbasebandsamplesink.h"
|
||||||
#include "ui_amdemodgui.h"
|
#include "ui_amdemodgui.h"
|
||||||
#include "plugin/pluginapi.h"
|
#include "plugin/pluginapi.h"
|
||||||
@ -31,6 +31,8 @@
|
|||||||
#include "gui/basicchannelsettingsdialog.h"
|
#include "gui/basicchannelsettingsdialog.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "gui/crightclickenabler.h"
|
||||||
|
#include "gui/audioselectdialog.h"
|
||||||
|
|
||||||
#include "amdemod.h"
|
#include "amdemod.h"
|
||||||
|
|
||||||
@ -230,6 +232,9 @@ AMDemodGUI::AMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, BasebandS
|
|||||||
|
|
||||||
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
|
connect(&MainWindow::getInstance()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick())); // 50 ms
|
||||||
|
|
||||||
|
CRightClickEnabler *audioMuteRightClickEnabler = new CRightClickEnabler(ui->audioMute);
|
||||||
|
connect(audioMuteRightClickEnabler, SIGNAL(rightClick()), this, SLOT(audioSelect()));
|
||||||
|
|
||||||
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
ui->deltaFrequencyLabel->setText(QString("%1f").arg(QChar(0x94, 0x03)));
|
||||||
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
|
||||||
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
ui->deltaFrequency->setValueRange(false, 7, -9999999, 9999999);
|
||||||
@ -343,6 +348,19 @@ void AMDemodGUI::enterEvent(QEvent*)
|
|||||||
m_channelMarker.setHighlighted(true);
|
m_channelMarker.setHighlighted(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AMDemodGUI::audioSelect()
|
||||||
|
{
|
||||||
|
qDebug("AMDemodGUI::audioSelect");
|
||||||
|
AudioSelectDialog audioSelect(DSPEngine::instance()->getAudioDeviceManager(), m_settings.m_audioDeviceName);
|
||||||
|
audioSelect.exec();
|
||||||
|
|
||||||
|
if (audioSelect.m_selected)
|
||||||
|
{
|
||||||
|
m_settings.m_audioDeviceName = audioSelect.m_audioDeviceName;
|
||||||
|
applySettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AMDemodGUI::tick()
|
void AMDemodGUI::tick()
|
||||||
{
|
{
|
||||||
double magsqAvg, magsqPeak;
|
double magsqAvg, magsqPeak;
|
||||||
|
@ -76,6 +76,7 @@ private slots:
|
|||||||
void onWidgetRolled(QWidget* widget, bool rollDown);
|
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||||
void onMenuDialogCalled(const QPoint& p);
|
void onMenuDialogCalled(const QPoint& p);
|
||||||
void handleInputMessages();
|
void handleInputMessages();
|
||||||
|
void audioSelect();
|
||||||
void tick();
|
void tick();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,16 +59,7 @@
|
|||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>2</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>2</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
@ -171,7 +162,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="audioMute">
|
<widget class="QToolButton" name="audioMute">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Mute/Unmute audio</string>
|
<string>Left: Mute/Unmute audio Right: view/select audio device</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
|
@ -41,6 +41,7 @@ void AMDemodSettings::resetToDefaults()
|
|||||||
m_udpPort = 9999;
|
m_udpPort = 9999;
|
||||||
m_rgbColor = QColor(255, 255, 0).rgb();
|
m_rgbColor = QColor(255, 255, 0).rgb();
|
||||||
m_title = "AM Demodulator";
|
m_title = "AM Demodulator";
|
||||||
|
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray AMDemodSettings::serialize() const
|
QByteArray AMDemodSettings::serialize() const
|
||||||
@ -59,6 +60,7 @@ QByteArray AMDemodSettings::serialize() const
|
|||||||
s.writeBool(8, m_bandpassEnable);
|
s.writeBool(8, m_bandpassEnable);
|
||||||
s.writeString(9, m_title);
|
s.writeString(9, m_title);
|
||||||
s.writeBool(10, m_copyAudioUseRTP);
|
s.writeBool(10, m_copyAudioUseRTP);
|
||||||
|
s.writeString(11, m_audioDeviceName);
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +97,7 @@ bool AMDemodSettings::deserialize(const QByteArray& data)
|
|||||||
d.readBool(8, &m_bandpassEnable, false);
|
d.readBool(8, &m_bandpassEnable, false);
|
||||||
d.readString(9, &m_title, "AM Demodulator");
|
d.readString(9, &m_title, "AM Demodulator");
|
||||||
d.readBool(10, &m_copyAudioUseRTP, false);
|
d.readBool(10, &m_copyAudioUseRTP, false);
|
||||||
|
d.readString(11, &m_audioDeviceName, AudioDeviceManager::m_defaultDeviceName);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ struct AMDemodSettings
|
|||||||
quint32 m_rgbColor;
|
quint32 m_rgbColor;
|
||||||
QString m_title;
|
QString m_title;
|
||||||
Serializable *m_channelMarker;
|
Serializable *m_channelMarker;
|
||||||
|
QString m_audioDeviceName;
|
||||||
|
|
||||||
AMDemodSettings();
|
AMDemodSettings();
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
@ -109,6 +109,33 @@ bool AudioDeviceManager::getInputDeviceName(int inputDeviceIndex, QString &devic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int AudioDeviceManager::getOutputDeviceIndex(const QString &deviceName) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_outputDevicesInfo.size(); i++)
|
||||||
|
{
|
||||||
|
//qDebug("AudioDeviceManager::getOutputDeviceIndex: %d: %s|%s", i, qPrintable(deviceName), qPrintable(m_outputDevicesInfo[i].deviceName()));
|
||||||
|
if (deviceName == m_outputDevicesInfo[i].deviceName()) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1; // system default
|
||||||
|
}
|
||||||
|
|
||||||
|
int AudioDeviceManager::getInputDeviceIndex(const QString &deviceName) const
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_inputDevicesInfo.size(); i++)
|
||||||
|
{
|
||||||
|
//qDebug("AudioDeviceManager::getInputDeviceIndex: %d: %s|%s", i, qPrintable(deviceName), qPrintable(m_inputDevicesInfo[i].deviceName()));
|
||||||
|
if (deviceName == m_inputDevicesInfo[i].deviceName()) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1; // system default
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AudioDeviceManager::resetToDefaults()
|
void AudioDeviceManager::resetToDefaults()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -203,6 +230,9 @@ void AudioDeviceManager::addAudioSink(AudioFifo* audioFifo, MessageQueue *sample
|
|||||||
if (m_audioSinkFifos.find(audioFifo) == m_audioSinkFifos.end()) // new FIFO
|
if (m_audioSinkFifos.find(audioFifo) == m_audioSinkFifos.end()) // new FIFO
|
||||||
{
|
{
|
||||||
m_audioOutputs[outputDeviceIndex]->addFifo(audioFifo);
|
m_audioOutputs[outputDeviceIndex]->addFifo(audioFifo);
|
||||||
|
m_audioSinkFifos[audioFifo] = outputDeviceIndex; // register audio FIFO
|
||||||
|
m_audioFifoToSinkMessageQueues[audioFifo] = sampleSinkMessageQueue;
|
||||||
|
m_outputDeviceSinkMessageQueues[outputDeviceIndex].append(sampleSinkMessageQueue);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -212,12 +242,11 @@ void AudioDeviceManager::addAudioSink(AudioFifo* audioFifo, MessageQueue *sample
|
|||||||
{
|
{
|
||||||
removeAudioSink(audioFifo); // remove from current
|
removeAudioSink(audioFifo); // remove from current
|
||||||
m_audioOutputs[outputDeviceIndex]->addFifo(audioFifo); // add to new
|
m_audioOutputs[outputDeviceIndex]->addFifo(audioFifo); // add to new
|
||||||
|
m_audioSinkFifos[audioFifo] = outputDeviceIndex; // new index
|
||||||
|
m_outputDeviceSinkMessageQueues[audioOutputDeviceIndex].removeOne(sampleSinkMessageQueue);
|
||||||
|
m_outputDeviceSinkMessageQueues[outputDeviceIndex].append(sampleSinkMessageQueue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_audioSinkFifos[audioFifo] = outputDeviceIndex; // register audio FIFO
|
|
||||||
m_audioFifoToSinkMessageQueues[audioFifo] = sampleSinkMessageQueue;
|
|
||||||
m_outputDeviceSinkMessageQueues[outputDeviceIndex].append(sampleSinkMessageQueue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDeviceManager::removeAudioSink(AudioFifo* audioFifo)
|
void AudioDeviceManager::removeAudioSink(AudioFifo* audioFifo)
|
||||||
|
@ -87,6 +87,8 @@ public:
|
|||||||
|
|
||||||
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const;
|
bool getOutputDeviceName(int outputDeviceIndex, QString &deviceName) const;
|
||||||
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const;
|
bool getInputDeviceName(int inputDeviceIndex, QString &deviceName) const;
|
||||||
|
int getOutputDeviceIndex(const QString &deviceName) const;
|
||||||
|
int getInputDeviceIndex(const QString &deviceName) const;
|
||||||
|
|
||||||
void addAudioSink(AudioFifo* audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex = -1); //!< Add the audio sink
|
void addAudioSink(AudioFifo* audioFifo, MessageQueue *sampleSinkMessageQueue, int outputDeviceIndex = -1); //!< Add the audio sink
|
||||||
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
void removeAudioSink(AudioFifo* audioFifo); //!< Remove the audio sink
|
||||||
|
@ -60,7 +60,7 @@ bool AudioOutput::start(int device, int rate)
|
|||||||
if (device < 0)
|
if (device < 0)
|
||||||
{
|
{
|
||||||
devInfo = QAudioDeviceInfo::defaultOutputDevice();
|
devInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||||
qWarning("AudioOutput::start: using default device %s", qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
qWarning("AudioOutput::start: using system default device %s", qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -69,12 +69,12 @@ bool AudioOutput::start(int device, int rate)
|
|||||||
if (device < devicesInfo.size())
|
if (device < devicesInfo.size())
|
||||||
{
|
{
|
||||||
devInfo = devicesInfo[device];
|
devInfo = devicesInfo[device];
|
||||||
qWarning("AudioOutput::start: using audio device #%d: %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
qWarning("AudioOutput::start: using audio device #%d: %s", device, qPrintable(devInfo.deviceName()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
devInfo = QAudioDeviceInfo::defaultOutputDevice();
|
devInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||||
qWarning("AudioOutput::start: audio device #%d does not exist. Using default device %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
qWarning("AudioOutput::start: audio device #%d does not exist. Using system default device %s", device, qPrintable(devInfo.defaultOutputDevice().deviceName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,14 @@ bool AudioOutput::start(int device, int rate)
|
|||||||
if (!devInfo.isFormatSupported(m_audioFormat))
|
if (!devInfo.isFormatSupported(m_audioFormat))
|
||||||
{
|
{
|
||||||
m_audioFormat = devInfo.nearestFormat(m_audioFormat);
|
m_audioFormat = devInfo.nearestFormat(m_audioFormat);
|
||||||
qWarning("AudioOutput::start: %d Hz S16_LE audio format not supported. New rate: %d", rate, m_audioFormat.sampleRate());
|
std::ostringstream os;
|
||||||
|
os << " sampleRate: " << m_audioFormat.sampleRate()
|
||||||
|
<< " channelCount: " << m_audioFormat.channelCount()
|
||||||
|
<< " sampleSize: " << m_audioFormat.sampleSize()
|
||||||
|
<< " codec: " << m_audioFormat.codec().toStdString()
|
||||||
|
<< " byteOrder: " << (m_audioFormat.byteOrder() == QAudioFormat::BigEndian ? "BE" : "LE")
|
||||||
|
<< " sampleType: " << (int) m_audioFormat.sampleType();
|
||||||
|
qWarning("AudioOutput::start: format %d Hz 2xS16LE audio/pcm not supported. Using: %s", rate, os.str().c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,8 @@ set(sdrgui_SOURCES
|
|||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
gui/aboutdialog.cpp
|
gui/aboutdialog.cpp
|
||||||
gui/addpresetdialog.cpp
|
gui/addpresetdialog.cpp
|
||||||
|
gui/audiodialog.cpp
|
||||||
|
gui/audioselectdialog.cpp
|
||||||
gui/basicchannelsettingsdialog.cpp
|
gui/basicchannelsettingsdialog.cpp
|
||||||
gui/buttonswitch.cpp
|
gui/buttonswitch.cpp
|
||||||
gui/channelwindow.cpp
|
gui/channelwindow.cpp
|
||||||
@ -12,6 +14,7 @@ set(sdrgui_SOURCES
|
|||||||
gui/commanditem.cpp
|
gui/commanditem.cpp
|
||||||
gui/commandkeyreceiver.cpp
|
gui/commandkeyreceiver.cpp
|
||||||
gui/commandoutputdialog.cpp
|
gui/commandoutputdialog.cpp
|
||||||
|
gui/crightclickenabler.cpp
|
||||||
gui/cwkeyergui.cpp
|
gui/cwkeyergui.cpp
|
||||||
gui/editcommanddialog.cpp
|
gui/editcommanddialog.cpp
|
||||||
gui/externalclockbutton.cpp
|
gui/externalclockbutton.cpp
|
||||||
@ -32,7 +35,6 @@ set(sdrgui_SOURCES
|
|||||||
gui/loggingdialog.cpp
|
gui/loggingdialog.cpp
|
||||||
gui/mypositiondialog.cpp
|
gui/mypositiondialog.cpp
|
||||||
gui/pluginsdialog.cpp
|
gui/pluginsdialog.cpp
|
||||||
gui/audiodialog.cpp
|
|
||||||
gui/presetitem.cpp
|
gui/presetitem.cpp
|
||||||
gui/rollupwidget.cpp
|
gui/rollupwidget.cpp
|
||||||
gui/samplingdevicecontrol.cpp
|
gui/samplingdevicecontrol.cpp
|
||||||
@ -62,6 +64,8 @@ set(sdrgui_HEADERS
|
|||||||
mainwindow.h
|
mainwindow.h
|
||||||
gui/aboutdialog.h
|
gui/aboutdialog.h
|
||||||
gui/addpresetdialog.h
|
gui/addpresetdialog.h
|
||||||
|
gui/audiodialog.h
|
||||||
|
gui/audioselectdialog.h
|
||||||
gui/basicchannelsettingsdialog.h
|
gui/basicchannelsettingsdialog.h
|
||||||
gui/buttonswitch.h
|
gui/buttonswitch.h
|
||||||
gui/channelwindow.h
|
gui/channelwindow.h
|
||||||
@ -69,6 +73,7 @@ set(sdrgui_HEADERS
|
|||||||
gui/commanditem.h
|
gui/commanditem.h
|
||||||
gui/commandkeyreceiver.h
|
gui/commandkeyreceiver.h
|
||||||
gui/commandoutputdialog.h
|
gui/commandoutputdialog.h
|
||||||
|
gui/crightclickenabler.h
|
||||||
gui/cwkeyergui.h
|
gui/cwkeyergui.h
|
||||||
gui/editcommanddialog.h
|
gui/editcommanddialog.h
|
||||||
gui/externalclockbutton.h
|
gui/externalclockbutton.h
|
||||||
@ -90,7 +95,6 @@ set(sdrgui_HEADERS
|
|||||||
gui/mypositiondialog.h
|
gui/mypositiondialog.h
|
||||||
gui/physicalunit.h
|
gui/physicalunit.h
|
||||||
gui/pluginsdialog.h
|
gui/pluginsdialog.h
|
||||||
gui/audiodialog.h
|
|
||||||
gui/presetitem.h
|
gui/presetitem.h
|
||||||
gui/rollupwidget.h
|
gui/rollupwidget.h
|
||||||
gui/samplingdevicecontrol.h
|
gui/samplingdevicecontrol.h
|
||||||
@ -136,6 +140,7 @@ set(sdrgui_FORMS
|
|||||||
gui/glspectrumgui.ui
|
gui/glspectrumgui.ui
|
||||||
gui/pluginsdialog.ui
|
gui/pluginsdialog.ui
|
||||||
gui/audiodialog.ui
|
gui/audiodialog.ui
|
||||||
|
gui/audioselectdialog.ui
|
||||||
gui/samplingdevicecontrol.ui
|
gui/samplingdevicecontrol.ui
|
||||||
gui/samplingdevicedialog.ui
|
gui/samplingdevicedialog.ui
|
||||||
gui/myposdialog.ui
|
gui/myposdialog.ui
|
||||||
|
@ -23,9 +23,12 @@ AudioDialogX::AudioDialogX(AudioDeviceManager* audioDeviceManager, QWidget* pare
|
|||||||
|
|
||||||
for(QList<QAudioDeviceInfo>::const_iterator it = outputDevices.begin(); it != outputDevices.end(); ++it)
|
for(QList<QAudioDeviceInfo>::const_iterator it = outputDevices.begin(); it != outputDevices.end(); ++it)
|
||||||
{
|
{
|
||||||
bool isDefaultDevice = it->deviceName() == defaultOutputDeviceInfo.deviceName();
|
|
||||||
treeItem = new QTreeWidgetItem(ui->audioOutTree);
|
treeItem = new QTreeWidgetItem(ui->audioOutTree);
|
||||||
treeItem->setText(0, it->deviceName() + (isDefaultDevice ? "(*)" : ""));
|
treeItem->setText(0, it->deviceName());
|
||||||
|
|
||||||
|
if (it->deviceName() == defaultOutputDeviceInfo.deviceName()) {
|
||||||
|
treeItem->setBackground(0, QBrush(qRgb(96,96,96)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in panel
|
// in panel
|
||||||
@ -39,9 +42,12 @@ AudioDialogX::AudioDialogX(AudioDeviceManager* audioDeviceManager, QWidget* pare
|
|||||||
|
|
||||||
for(QList<QAudioDeviceInfo>::const_iterator it = inputDevices.begin(); it != inputDevices.end(); ++it)
|
for(QList<QAudioDeviceInfo>::const_iterator it = inputDevices.begin(); it != inputDevices.end(); ++it)
|
||||||
{
|
{
|
||||||
bool isDefaultDevice = it->deviceName() == defaultInputDeviceInfo.deviceName();
|
|
||||||
treeItem = new QTreeWidgetItem(ui->audioInTree);
|
treeItem = new QTreeWidgetItem(ui->audioInTree);
|
||||||
treeItem->setText(0, it->deviceName() + (isDefaultDevice ? "(*)" : ""));
|
treeItem->setText(0, it->deviceName());
|
||||||
|
|
||||||
|
if (it->deviceName() == defaultInputDeviceInfo.deviceName()) {
|
||||||
|
treeItem->setBackground(0, QBrush(qRgb(96,96,96)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outputUDPPort = 9998;
|
m_outputUDPPort = 9998;
|
||||||
@ -124,13 +130,12 @@ void AudioDialogX::on_audioOutTree_currentItemChanged(
|
|||||||
ui->outputResetKey->setChecked(false);
|
ui->outputResetKey->setChecked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//qDebug("AudioDialogX::on_audioOutTree_currentItemChanged: %s", qPrintable(outDeviceName));
|
||||||
bool found = m_audioDeviceManager->getOutputDeviceInfo(outDeviceName, outDeviceInfo);
|
bool found = m_audioDeviceManager->getOutputDeviceInfo(outDeviceName, outDeviceInfo);
|
||||||
m_outputDeviceInfo = outDeviceInfo;
|
m_outputDeviceInfo = outDeviceInfo;
|
||||||
ui->outputDefaultText->setText(found ? "" : "D");
|
ui->outputDefaultText->setText(found ? "" : "D");
|
||||||
|
|
||||||
updateOutputDisplay();
|
updateOutputDisplay();
|
||||||
|
|
||||||
//qDebug("AudioDialogX::on_audioOutTree_currentItemChanged: %d:%s", outIndex, qPrintable(outDeviceName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioDialogX::on_inputVolume_valueChanged(int value)
|
void AudioDialogX::on_inputVolume_valueChanged(int value)
|
||||||
|
94
sdrgui/gui/audioselectdialog.cpp
Normal file
94
sdrgui/gui/audioselectdialog.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2018 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "audioselectdialog.h"
|
||||||
|
#include "ui_audioselectdialog.h"
|
||||||
|
|
||||||
|
AudioSelectDialog::AudioSelectDialog(AudioDeviceManager* audioDeviceManager, const QString& deviceName, bool input, QWidget* parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
m_selected(false),
|
||||||
|
ui(new Ui::AudioSelectDialog),
|
||||||
|
m_audioDeviceManager(audioDeviceManager),
|
||||||
|
m_input(input)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
QTreeWidgetItem *treeItem, *defaultItem, *selectedItem = 0;
|
||||||
|
|
||||||
|
// panel
|
||||||
|
|
||||||
|
QAudioDeviceInfo defaultDeviceInfo = input ? QAudioDeviceInfo::defaultInputDevice() : QAudioDeviceInfo::defaultOutputDevice();
|
||||||
|
defaultItem = new QTreeWidgetItem(ui->audioTree);
|
||||||
|
defaultItem->setText(0, AudioDeviceManager::m_defaultDeviceName);
|
||||||
|
|
||||||
|
QList<QAudioDeviceInfo> devices = input ? m_audioDeviceManager->getInputDevices() : m_audioDeviceManager->getOutputDevices();
|
||||||
|
|
||||||
|
for(QList<QAudioDeviceInfo>::const_iterator it = devices.begin(); it != devices.end(); ++it)
|
||||||
|
{
|
||||||
|
treeItem = new QTreeWidgetItem(ui->audioTree);
|
||||||
|
treeItem->setText(0, it->deviceName());
|
||||||
|
|
||||||
|
if (it->deviceName() == defaultDeviceInfo.deviceName()) {
|
||||||
|
treeItem->setBackground(0, QBrush(qRgb(96,96,96)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deviceName == it->deviceName()) {
|
||||||
|
selectedItem = treeItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedItem) {
|
||||||
|
ui->audioTree->setCurrentItem(selectedItem);
|
||||||
|
} else {
|
||||||
|
ui->audioTree->setCurrentItem(defaultItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioSelectDialog::~AudioSelectDialog()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioSelectDialog::accept()
|
||||||
|
{
|
||||||
|
int deviceIndex = ui->audioTree->indexOfTopLevelItem(ui->audioTree->currentItem()) - 1;
|
||||||
|
|
||||||
|
if (m_input)
|
||||||
|
{
|
||||||
|
if (!m_audioDeviceManager->getInputDeviceName(deviceIndex, m_audioDeviceName)) {
|
||||||
|
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!m_audioDeviceManager->getOutputDeviceName(deviceIndex, m_audioDeviceName)) {
|
||||||
|
m_audioDeviceName = AudioDeviceManager::m_defaultDeviceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug("AudioSelectDialog::accept: output: %d (%s)", deviceIndex, qPrintable(m_audioDeviceName));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_selected = true;
|
||||||
|
QDialog::accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioSelectDialog::reject()
|
||||||
|
{
|
||||||
|
QDialog::reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
53
sdrgui/gui/audioselectdialog.h
Normal file
53
sdrgui/gui/audioselectdialog.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2018 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SDRGUI_GUI_AUDIOSELECTDIALOG_H_
|
||||||
|
#define SDRGUI_GUI_AUDIOSELECTDIALOG_H_
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "export.h"
|
||||||
|
#include "audio/audiodevicemanager.h"
|
||||||
|
|
||||||
|
class QTreeWidgetItem;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class AudioSelectDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SDRGUI_API AudioSelectDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit AudioSelectDialog(AudioDeviceManager* audioDeviceManager, const QString& deviceName, bool input = false, QWidget* parent = 0);
|
||||||
|
~AudioSelectDialog();
|
||||||
|
|
||||||
|
QString m_audioDeviceName;
|
||||||
|
bool m_selected;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AudioSelectDialog* ui;
|
||||||
|
AudioDeviceManager* m_audioDeviceManager;
|
||||||
|
bool m_input;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void accept();
|
||||||
|
void reject();
|
||||||
|
//void on_audioInTree_currentItemChanged(QTreeWidgetItem* currentItem, QTreeWidgetItem* previousItem);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SDRGUI_GUI_AUDIOSELECTDIALOG_H_ */
|
84
sdrgui/gui/audioselectdialog.ui
Normal file
84
sdrgui/gui/audioselectdialog.ui
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>AudioSelectDialog</class>
|
||||||
|
<widget class="QDialog" name="AudioSelectDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>349</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>Sans Serif</family>
|
||||||
|
<pointsize>9</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Select audio device</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTreeWidget" name="audioTree">
|
||||||
|
<column>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Device</string>
|
||||||
|
</property>
|
||||||
|
</column>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>buttonBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources>
|
||||||
|
<include location="../resources/res.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>AudioSelectDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>AudioSelectDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
13
sdrgui/gui/crightclickenabler.cpp
Normal file
13
sdrgui/gui/crightclickenabler.cpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* crightclickenabler.cpp
|
||||||
|
*
|
||||||
|
* Created on: Mar 26, 2018
|
||||||
|
* Author: f4exb
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "crightclickenabler.h"
|
||||||
|
|
||||||
|
CRightClickEnabler::CRightClickEnabler(QAbstractButton *button): QObject(button), _button(button) {
|
||||||
|
button->installEventFilter(this);
|
||||||
|
};
|
||||||
|
|
49
sdrgui/gui/crightclickenabler.h
Normal file
49
sdrgui/gui/crightclickenabler.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2018 F4EXB //
|
||||||
|
// written by Edouard Griffiths //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef SDRGUI_GUI_CRIGHTCLICKENABLER_H_
|
||||||
|
#define SDRGUI_GUI_CRIGHTCLICKENABLER_H_
|
||||||
|
|
||||||
|
#include <QAbstractButton>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
class CRightClickEnabler : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CRightClickEnabler(QAbstractButton *button);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void rightClick();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
inline bool eventFilter(QObject *watched __attribute__((unused)), QEvent *event) override {
|
||||||
|
if (event->type() == QEvent::MouseButtonPress)
|
||||||
|
{
|
||||||
|
auto mouseEvent = (QMouseEvent*)event;
|
||||||
|
if (mouseEvent->button() == Qt::RightButton) {
|
||||||
|
//_button->click();
|
||||||
|
emit rightClick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QAbstractButton* _button;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SDRGUI_GUI_CRIGHTCLICKENABLER_H_ */
|
Loading…
x
Reference in New Issue
Block a user