kopia lustrzana https://gitlab.com/eliggett/wfview
Test commit of rtaudio
This commit doesn't actually use RTAudio for anything other than enumerating devices and is a proof of concept for each supported platform.merge-requests/5/head
rodzic
fddda526ae
commit
d304b368b6
|
@ -1,22 +1,34 @@
|
||||||
#ifndef AUDIOHANDLER_H
|
#ifndef AUDIOHANDLER_H
|
||||||
#define AUDIOHANDLER_H
|
#define AUDIOHANDLER_H
|
||||||
|
|
||||||
|
#define USE_RTAUDIO
|
||||||
|
#define USE_QTAUDIO
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <QtMultimedia/QAudioOutput>
|
#include <QtMultimedia/QAudioOutput>
|
||||||
#include <QMutexLocker>
|
#include <QMutexLocker>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QtEndian>
|
#include <QtEndian>
|
||||||
|
|
||||||
|
#ifdef USE_QTAUDIO
|
||||||
#include <QAudioFormat>
|
#include <QAudioFormat>
|
||||||
#include <QAudioDeviceInfo>
|
#include <QAudioDeviceInfo>
|
||||||
#include <QAudioOutput>
|
#include <QAudioOutput>
|
||||||
#include <QAudioInput>
|
#include <QAudioInput>
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_RTAUDIO
|
||||||
|
#include "rtaudio/RtAudio.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include "resampler/speex_resampler.h"
|
#include "resampler/speex_resampler.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
//#define BUFFER_SIZE (32*1024)
|
//#define BUFFER_SIZE (32*1024)
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
30.04.2018
|
||||||
|
* Additions and fixes for realtime operation: (Tim E. Real of MusE)
|
||||||
|
- Added realtime operation to Pulse driver.
|
||||||
|
- Fixed ALSA realtime support. Attributes are once again all set
|
||||||
|
in probeDeviceOpen().
|
||||||
|
- Fixed OSS realtime support. Same mods as done to ALSA driver.
|
||||||
|
OSS untested, but should work, it's the same code.
|
||||||
|
- A diagnostic message (streamed to cerr) in each of the callback
|
||||||
|
handlers informs the user if realtime is really running.
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
|
||||||
|
RtAudio: a set of realtime audio i/o C++ classes
|
||||||
|
Copyright (c) 2001-2019 Gary P. Scavone
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation files
|
||||||
|
(the "Software"), to deal in the Software without restriction,
|
||||||
|
including without limitation the rights to use, copy, modify, merge,
|
||||||
|
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
Any person wishing to distribute modifications to the Software is
|
||||||
|
asked to send the modifications to the original developer so that
|
||||||
|
they can be incorporated into the canonical version. This is,
|
||||||
|
however, not a binding provision of this license.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
|
||||||
|
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
||||||
|
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,38 @@
|
||||||
|
# RtAudio
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/thestk/rtaudio.svg?branch=master)](https://travis-ci.org/thestk/rtaudio)
|
||||||
|
|
||||||
|
A set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO and WASAPI) operating systems.
|
||||||
|
|
||||||
|
By Gary P. Scavone, 2001-2019 (and many other developers!)
|
||||||
|
|
||||||
|
This distribution of RtAudio contains the following:
|
||||||
|
|
||||||
|
- doc: RtAudio documentation (see doc/html/index.html)
|
||||||
|
- tests: example RtAudio programs
|
||||||
|
- include: header and source files necessary for ASIO, DS & OSS compilation
|
||||||
|
- tests/Windows: Visual C++ .net test program workspace and projects
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
RtAudio is a set of C++ classes that provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X and Windows (DirectSound, ASIO and WASAPI) operating systems. RtAudio significantly simplifies the process of interacting with computer audio hardware. It was designed with the following objectives:
|
||||||
|
|
||||||
|
- object-oriented C++ design
|
||||||
|
- simple, common API across all supported platforms
|
||||||
|
- only one source and one header file for easy inclusion in programming projects
|
||||||
|
- allow simultaneous multi-api support
|
||||||
|
- support dynamic connection of devices
|
||||||
|
- provide extensive audio device parameter control
|
||||||
|
- allow audio device capability probing
|
||||||
|
- automatic internal conversion for data format, channel number compensation, (de)interleaving, and byte-swapping
|
||||||
|
|
||||||
|
RtAudio incorporates the concept of audio streams, which represent audio output (playback) and/or input (recording). Available audio devices and their capabilities can be enumerated and then specified when opening a stream. Where applicable, multiple API support can be compiled and a particular API specified when creating an RtAudio instance. See the \ref apinotes section for information specific to each of the supported audio APIs.
|
||||||
|
|
||||||
|
## Further Reading
|
||||||
|
|
||||||
|
For complete documentation on RtAudio, see the doc directory of the distribution or surf to http://www.music.mcgill.ca/~gary/rtaudio/.
|
||||||
|
|
||||||
|
|
||||||
|
## Legal and ethical:
|
||||||
|
|
||||||
|
The RtAudio license is similar to the MIT License. Please see [LICENSE](LICENSE).
|
Plik diff jest za duży
Load Diff
Plik diff jest za duży
Load Diff
49
wfmain.cpp
49
wfmain.cpp
|
@ -158,6 +158,49 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
||||||
connect(keyM, SIGNAL(activated()), this, SLOT(shortcutM()));
|
connect(keyM, SIGNAL(activated()), this, SLOT(shortcutM()));
|
||||||
|
|
||||||
// Enumerate audio devices, need to do before settings are loaded.
|
// Enumerate audio devices, need to do before settings are loaded.
|
||||||
|
#ifdef USE_RTAUDIO
|
||||||
|
std::map<int, std::string> apiMap;
|
||||||
|
apiMap[RtAudio::MACOSX_CORE] = "OS-X Core Audio";
|
||||||
|
apiMap[RtAudio::WINDOWS_ASIO] = "Windows ASIO";
|
||||||
|
apiMap[RtAudio::WINDOWS_DS] = "Windows DirectSound";
|
||||||
|
apiMap[RtAudio::WINDOWS_WASAPI] = "Windows WASAPI";
|
||||||
|
apiMap[RtAudio::UNIX_JACK] = "Jack Client";
|
||||||
|
apiMap[RtAudio::LINUX_ALSA] = "Linux ALSA";
|
||||||
|
apiMap[RtAudio::LINUX_PULSE] = "Linux PulseAudio";
|
||||||
|
apiMap[RtAudio::LINUX_OSS] = "Linux OSS";
|
||||||
|
apiMap[RtAudio::RTAUDIO_DUMMY] = "RtAudio Dummy";
|
||||||
|
|
||||||
|
std::vector< RtAudio::Api > apis;
|
||||||
|
RtAudio::getCompiledApi(apis);
|
||||||
|
|
||||||
|
qInfo(logAudio()) << "RtAudio Version " << QString::fromStdString(RtAudio::getVersion());
|
||||||
|
|
||||||
|
qInfo(logAudio()) << "Compiled APIs:";
|
||||||
|
for (unsigned int i = 0; i < apis.size(); i++) {
|
||||||
|
qInfo(logAudio()) << " " << QString::fromStdString(apiMap[apis[i]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RtAudio::DeviceInfo info;
|
||||||
|
qInfo(logAudio()) << "Current API: " << QString::fromStdString(apiMap[audio.getCurrentApi()]);
|
||||||
|
|
||||||
|
unsigned int devices = audio.getDeviceCount();
|
||||||
|
qInfo(logAudio()) << "Found " << devices << " audio device(s) ...";
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < devices; i++) {
|
||||||
|
info = audio.getDeviceInfo(i);
|
||||||
|
if (info.outputChannels > 0) {
|
||||||
|
qInfo(logAudio()) << (info.isDefaultOutput ? "*" : " ") << "Output Device : " << QString::fromStdString(info.name);
|
||||||
|
ui->audioOutputCombo->addItem(QString::fromStdString(info.name),i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (unsigned int i = 0; i < devices; i++) {
|
||||||
|
info = audio.getDeviceInfo(i);
|
||||||
|
if (info.inputChannels > 0) {
|
||||||
|
qInfo(logAudio()) << (info.isDefaultInput ? "*" : " ") << "Input Device : " << QString::fromStdString(info.name);
|
||||||
|
ui->audioInputCombo->addItem(QString::fromStdString(info.name), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else if defined(USE_QTAUDIO)
|
||||||
const auto audioOutputs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
const auto audioOutputs = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
|
||||||
for (const QAudioDeviceInfo& deviceInfo : audioOutputs) {
|
for (const QAudioDeviceInfo& deviceInfo : audioOutputs) {
|
||||||
ui->audioOutputCombo->addItem(deviceInfo.deviceName());
|
ui->audioOutputCombo->addItem(deviceInfo.deviceName());
|
||||||
|
@ -166,6 +209,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, QWidget *parent
|
||||||
for (const QAudioDeviceInfo& deviceInfo : audioInputs) {
|
for (const QAudioDeviceInfo& deviceInfo : audioInputs) {
|
||||||
ui->audioInputCombo->addItem(deviceInfo.deviceName());
|
ui->audioInputCombo->addItem(deviceInfo.deviceName());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ui->serialDeviceListCombo->blockSignals(true);
|
ui->serialDeviceListCombo->blockSignals(true);
|
||||||
ui->serialDeviceListCombo->addItem("Auto", 0);
|
ui->serialDeviceListCombo->addItem("Auto", 0);
|
||||||
|
@ -860,8 +904,13 @@ void wfmain::setDefPrefs()
|
||||||
udpDefPrefs.audioLANPort = 50003;
|
udpDefPrefs.audioLANPort = 50003;
|
||||||
udpDefPrefs.username = QString("");
|
udpDefPrefs.username = QString("");
|
||||||
udpDefPrefs.password = QString("");
|
udpDefPrefs.password = QString("");
|
||||||
|
#if defined(USE_RTAUDIO)
|
||||||
|
udpDefPrefs.audioOutput = QString::fromStdString(audio.getDeviceInfo(audio.getDefaultOutputDevice()).name);
|
||||||
|
udpDefPrefs.audioInput = QString::fromStdString(audio.getDeviceInfo(audio.getDefaultInputDevice()).name);
|
||||||
|
#elif defined(USE_QTAUDIO)
|
||||||
udpDefPrefs.audioOutput = QAudioDeviceInfo::defaultOutputDevice().deviceName();
|
udpDefPrefs.audioOutput = QAudioDeviceInfo::defaultOutputDevice().deviceName();
|
||||||
udpDefPrefs.audioInput = QAudioDeviceInfo::defaultInputDevice().deviceName();
|
udpDefPrefs.audioInput = QAudioDeviceInfo::defaultInputDevice().deviceName();
|
||||||
|
#endif
|
||||||
udpDefPrefs.audioRXLatency = 150;
|
udpDefPrefs.audioRXLatency = 150;
|
||||||
udpDefPrefs.audioTXLatency = 150;
|
udpDefPrefs.audioTXLatency = 150;
|
||||||
udpDefPrefs.audioRXSampleRate = 48000;
|
udpDefPrefs.audioRXSampleRate = 48000;
|
||||||
|
|
2
wfmain.h
2
wfmain.h
|
@ -700,6 +700,8 @@ private:
|
||||||
|
|
||||||
SERVERCONFIG serverConfig;
|
SERVERCONFIG serverConfig;
|
||||||
|
|
||||||
|
RtAudio audio;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(struct rigCapabilities)
|
Q_DECLARE_METATYPE(struct rigCapabilities)
|
||||||
|
|
23
wfview.pro
23
wfview.pro
|
@ -33,6 +33,23 @@ DEFINES += QCUSTOMPLOT_COMPILE_LIBRARY
|
||||||
DEFINES += OUTSIDE_SPEEX
|
DEFINES += OUTSIDE_SPEEX
|
||||||
DEFINES += RANDOM_PREFIX=wf
|
DEFINES += RANDOM_PREFIX=wf
|
||||||
|
|
||||||
|
# RTAudio defines
|
||||||
|
win32:DEFINES += __WINDOWS_WASAPI__
|
||||||
|
#win32:DEFINES += __WINDOWS_DS__ # Requires DirectSound libraries
|
||||||
|
linux:DEFINES += __LINUX_ALSA__
|
||||||
|
#linux:DEFINES += __LINUX_OSS__
|
||||||
|
#linux:DEFINES += __LINUX_PULSE__
|
||||||
|
macx:DEFINES += __MACOSX_CORE__
|
||||||
|
|
||||||
|
option(RTAUDIO_API_DS "Build DirectSound API" OFF)
|
||||||
|
option(RTAUDIO_API_ASIO "Build ASIO API" OFF)
|
||||||
|
option(RTAUDIO_API_WASAPI "Build WASAPI API" ${WIN32})
|
||||||
|
option(RTAUDIO_API_OSS "Build OSS4 API" ${xBSD})
|
||||||
|
option(RTAUDIO_API_ALSA "Build ALSA API" ${LINUX})
|
||||||
|
option(RTAUDIO_API_PULSE "Build PulseAudio API" ${pulse_FOUND})
|
||||||
|
option(RTAUDIO_API_JACK "Build JACK audio server API" ${HAVE_JACK})
|
||||||
|
option(RTAUDIO_API_CORE "Build CoreAudio API" ${APPLE})
|
||||||
|
|
||||||
macx:INCLUDEPATH += /usr/local/include /opt/local/include
|
macx:INCLUDEPATH += /usr/local/include /opt/local/include
|
||||||
macx:LIBS += -L/usr/local/lib -L/opt/local/lib
|
macx:LIBS += -L/usr/local/lib -L/opt/local/lib
|
||||||
|
|
||||||
|
@ -99,7 +116,8 @@ SOURCES += main.cpp\
|
||||||
pttyhandler.cpp \
|
pttyhandler.cpp \
|
||||||
resampler/resample.c \
|
resampler/resample.c \
|
||||||
repeatersetup.cpp \
|
repeatersetup.cpp \
|
||||||
rigctld.cpp
|
rigctld.cpp \
|
||||||
|
rtaudio/RTAudio.cpp
|
||||||
|
|
||||||
HEADERS += wfmain.h \
|
HEADERS += wfmain.h \
|
||||||
commhandler.h \
|
commhandler.h \
|
||||||
|
@ -122,7 +140,8 @@ HEADERS += wfmain.h \
|
||||||
resampler/resample_sse.h \
|
resampler/resample_sse.h \
|
||||||
repeatersetup.h \
|
repeatersetup.h \
|
||||||
repeaterattributes.h \
|
repeaterattributes.h \
|
||||||
rigctld.h
|
rigctld.h \
|
||||||
|
rtaudio/RTAudio.h
|
||||||
|
|
||||||
|
|
||||||
FORMS += wfmain.ui \
|
FORMS += wfmain.ui \
|
||||||
|
|
|
@ -325,7 +325,7 @@
|
||||||
<ExceptionHandling>Sync</ExceptionHandling>
|
<ExceptionHandling>Sync</ExceptionHandling>
|
||||||
<ObjectFileName>debug\</ObjectFileName>
|
<ObjectFileName>debug\</ObjectFileName>
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_USE_OPENGL;HOST=1;UNAME=1;GITSHORT=1;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_WINDOWS;UNICODE;_UNICODE;WIN32;_ENABLE_EXTENDED_ALIGNED_STORAGE;WIN64;QT_DEPRECATED_WARNINGS;QCUSTOMPLOT_USE_OPENGL;HOST=1;UNAME=1;GITSHORT=1;OUTSIDE_SPEEX;RANDOM_PREFIX=wf;__WINDOWS_WASAPI__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<PreprocessToFile>false</PreprocessToFile>
|
<PreprocessToFile>false</PreprocessToFile>
|
||||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||||
|
@ -389,6 +389,7 @@
|
||||||
<ClCompile Include="rigctld.cpp" />
|
<ClCompile Include="rigctld.cpp" />
|
||||||
<ClCompile Include="rigidentities.cpp" />
|
<ClCompile Include="rigidentities.cpp" />
|
||||||
<ClCompile Include="audiohandler.cpp" />
|
<ClCompile Include="audiohandler.cpp" />
|
||||||
|
<ClCompile Include="rtaudio\RtAudio.cpp" />
|
||||||
<ClCompile Include="satellitesetup.cpp" />
|
<ClCompile Include="satellitesetup.cpp" />
|
||||||
<ClCompile Include="udphandler.cpp" />
|
<ClCompile Include="udphandler.cpp" />
|
||||||
<ClCompile Include="udpserver.cpp" />
|
<ClCompile Include="udpserver.cpp" />
|
||||||
|
@ -396,6 +397,7 @@
|
||||||
<ClCompile Include="wfmain.cpp" />
|
<ClCompile Include="wfmain.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="rtaudio\RtAudio.h" />
|
||||||
<QtMoc Include="udpserver.h" />
|
<QtMoc Include="udpserver.h" />
|
||||||
<QtMoc Include="udpserversetup.h" />
|
<QtMoc Include="udpserversetup.h" />
|
||||||
<QtMoc Include="satellitesetup.h" />
|
<QtMoc Include="satellitesetup.h" />
|
||||||
|
|
|
@ -117,6 +117,9 @@
|
||||||
<ClCompile Include="rigctld.cpp">
|
<ClCompile Include="rigctld.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="rtaudio\RtAudio.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="commhandler.h">
|
<QtMoc Include="commhandler.h">
|
||||||
|
@ -350,6 +353,8 @@
|
||||||
<None Include="resources\wfview.png" />
|
<None Include="resources\wfview.png" />
|
||||||
<None Include="resources\wfview.png" />
|
<None Include="resources\wfview.png" />
|
||||||
<None Include="resources\wfview.png" />
|
<None Include="resources\wfview.png" />
|
||||||
|
<None Include="resources\wfview.png" />
|
||||||
|
<None Include="resources\wfview.png" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="resources\install.sh">
|
<None Include="resources\install.sh">
|
||||||
|
@ -369,5 +374,8 @@
|
||||||
<ClInclude Include="resampler\speex_resampler.h">
|
<ClInclude Include="resampler\speex_resampler.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="rtaudio\RtAudio.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Ładowanie…
Reference in New Issue