RtAudio source integrated, preparing to implement

This commit is contained in:
Charles J. Cliffe 2014-12-04 19:03:02 -05:00
parent e668fa2b5d
commit 7ae1ffc2c9
6 changed files with 11411 additions and 48 deletions

View File

@ -66,13 +66,16 @@ if (DEFINED WIN32)
include_directories ( ${PROJECT_SOURCE_DIR}/external/fftw-3.3.4-dll64 ${PROJECT_SOURCE_DIR}/external/rtl-sdr-release )
link_directories ( ${PROJECT_SOURCE_DIR}/external/fftw-3.3.4-dll64 ${PROJECT_SOURCE_DIR}/external/rtl-sdr-release/x64 )
set(FFTW_LIB fftw3-3)
include_directories ( ${PROJECT_SOURCE_DIR}/external/portaudio/include )
link_directories ( ${PROJECT_SOURCE_DIR}/external/portaudio/libs/64 )
SET (PORTAUDIO_LIBRARY libportaudio_x86.dll winmm)
link_directories ( ${PROJECT_SOURCE_DIR}/external/liquid-dsp/lib/64 )
include_directories ( ${PROJECT_SOURCE_DIR}/external/liquid-dsp/include )
ADD_DEFINITIONS(
-D__WINDOWS_DS__
)
SET(OTHER_LIBRARIES -ldsound)
else (DEFINED WIN32)
set(RTLSDR_INCLUDE "/opt/local/include" CACHE FILEPATH "RTL-SDR Include Path")
set(RTLSDR_LIB "/opt/local/lib" CACHE FILEPATH "RTL-SDR Lib Path")
@ -80,8 +83,6 @@ else (DEFINED WIN32)
link_directories(${RTLSDR_LIB})
set(FFTW_LIB fftw3)
SET (PORTAUDIO_LIBRARY portaudio)
endif (DEFINED WIN32)
@ -105,6 +106,7 @@ SET (cubicsdr_sources
src/visual/SpectrumContext.cpp
src/visual/WaterfallCanvas.cpp
src/visual/WaterfallContext.cpp
external/rtaudio/RtAudio.cpp
)
SET (cubicsdr_headers
@ -128,6 +130,7 @@ SET (cubicsdr_headers
src/visual/SpectrumContext.h
src/visual/WaterfallCanvas.h
src/visual/WaterfallContext.h
external/rtaudio/RtAudio.h
)
include_directories ( ${PROJECT_SOURCE_DIR}/src/sdr
@ -135,7 +138,8 @@ include_directories ( ${PROJECT_SOURCE_DIR}/src/sdr
${PROJECT_SOURCE_DIR}/src/audio
${PROJECT_SOURCE_DIR}/src/util
${PROJECT_SOURCE_DIR}/src/visual
${PROJECT_SOURCE_DIR}/src )
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/external/rtaudio )
ADD_DEFINITIONS(
-std=c++0x # or -std=c++11
@ -147,7 +151,7 @@ ADD_DEFINITIONS(
add_executable(CubicSDR ${cubicsdr_sources} ${cubicsdr_headers})
target_link_libraries(CubicSDR rtlsdr liquid ${FFTW_LIB} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${PORTAUDIO_LIBRARY})
target_link_libraries(CubicSDR rtlsdr liquid ${FFTW_LIB} ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES} ${OTHER_LIBRARIES})
# cubicvr2 glfw ${GLFW_LIBRARIES}

10136
external/rtaudio/RtAudio.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1162
external/rtaudio/RtAudio.h vendored Normal file

File diff suppressed because it is too large Load Diff

61
external/rtaudio/readme vendored Normal file
View File

@ -0,0 +1,61 @@
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-2014.
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, and OSS), Macintosh OS X, SGI, 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.
RtAudio: a set of realtime audio i/o C++ classes
Copyright (c) 2001-2014 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.

View File

@ -3,7 +3,7 @@
#include <vector>
AudioThread::AudioThread(AudioThreadInputQueue *inputQueue) :
inputQueue(inputQueue), stream(NULL), terminated(false) {
inputQueue(inputQueue), terminated(false) { // , stream(NULL)
}
@ -14,51 +14,51 @@ AudioThread::~AudioThread() {
void AudioThread::threadMain() {
std::cout << "Audio thread initializing.." << std::endl;
PaError err;
err = Pa_Initialize();
if (err != paNoError) {
std::cout << "Error starting portaudio :(" << std::endl;
return;
}
// PaError err;
// err = Pa_Initialize();
// if (err != paNoError) {
// std::cout << "Error starting portaudio :(" << std::endl;
// return;
// }
//
// int preferred_device = -1;
//
// outputParameters.device =
// (preferred_device != -1) ?
// preferred_device : Pa_GetDefaultOutputDevice();
// if (outputParameters.device == paNoDevice) {
// std::cout << "Error: No default output device.\n";
// }
//
// outputParameters.channelCount = 2;
// outputParameters.sampleFormat = paFloat32;
// outputParameters.suggestedLatency = Pa_GetDeviceInfo(
// outputParameters.device)->defaultHighOutputLatency;
// outputParameters.hostApiSpecificStreamInfo = NULL;
//
// stream = NULL;
//
// err = Pa_OpenStream(&stream, NULL, &outputParameters, AUDIO_FREQUENCY,
// paFramesPerBufferUnspecified, paClipOff, NULL, NULL);
int preferred_device = -1;
outputParameters.device =
(preferred_device != -1) ?
preferred_device : Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
std::cout << "Error: No default output device.\n";
}
outputParameters.channelCount = 2;
outputParameters.sampleFormat = paFloat32;
outputParameters.suggestedLatency = Pa_GetDeviceInfo(
outputParameters.device)->defaultHighOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
stream = NULL;
err = Pa_OpenStream(&stream, NULL, &outputParameters, AUDIO_FREQUENCY,
paFramesPerBufferUnspecified, paClipOff, NULL, NULL);
err = Pa_StartStream(stream);
if (err != paNoError) {
std::cout << "Error starting stream: " << Pa_GetErrorText(err)
<< std::endl;
std::cout << "\tPortAudio error: " << Pa_GetErrorText(err) << std::endl;
}
// err = Pa_StartStream(stream);
// if (err != paNoError) {
// std::cout << "Error starting stream: " << Pa_GetErrorText(err)
// << std::endl;
// std::cout << "\tPortAudio error: " << Pa_GetErrorText(err) << std::endl;
// }
while (!terminated) {
AudioThreadInput inp;
inputQueue->pop(inp);
if (inp.data.size()) {
Pa_WriteStream(stream, &inp.data[0], inp.data.size()/2);
// Pa_WriteStream(stream, &inp.data[0], inp.data.size()/2);
}
}
err = Pa_StopStream(stream);
err = Pa_CloseStream(stream);
Pa_Terminate();
// err = Pa_StopStream(stream);
// err = Pa_CloseStream(stream);
// Pa_Terminate();
std::cout << "Audio thread done." << std::endl;
}

View File

@ -14,7 +14,7 @@
#include "AudioThread.h"
#include "ThreadQueue.h"
#include "portaudio.h"
#include "RtAudio.h"
class AudioThreadInput {
public:
@ -36,8 +36,8 @@ public:
private:
AudioThreadInputQueue *inputQueue;
PaStreamParameters outputParameters;
PaStream *stream;
// PaStreamParameters outputParameters;
// PaStream *stream;
std::atomic<bool> terminated;
};