From: wittend99 Date: Thu, 17 May 2012 15:03:24 +0000 (+0000) Subject: More work with portaudiocpp X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=8fee8b5ffe6ada74505a2895b76b4decd2de4115;p=freetel-svn-tracking.git More work with portaudiocpp git-svn-id: https://svn.code.sf.net/p/freetel/code@471 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/fdmdv2/extern/include/portaudiocpp/AsioDeviceAdapter.hxx b/fdmdv2/extern/include/portaudiocpp/AsioDeviceAdapter.hxx new file mode 100644 index 00000000..1964b6a2 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/AsioDeviceAdapter.hxx @@ -0,0 +1,44 @@ +#ifndef INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX +#define INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX + +namespace portaudio +{ + + // Forward declaration(s): + class Device; + + // Declaration(s): + ////// + /// @brief Adapts the given Device to an ASIO specific extension. + /// + /// Deleting the AsioDeviceAdapter does not affect the underlaying + /// Device. + ////// + class AsioDeviceAdapter + { + public: + AsioDeviceAdapter(Device &device); + + Device &device(); + + long minBufferSize() const; + long maxBufferSize() const; + long preferredBufferSize() const; + long granularity() const; + + void showControlPanel(void *systemSpecific); + + const char *inputChannelName(int channelIndex) const; + const char *outputChannelName(int channelIndex) const; + + private: + Device *device_; + + long minBufferSize_; + long maxBufferSize_; + long preferredBufferSize_; + long granularity_; + }; +} + +#endif // INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/AutoSystem.hxx b/fdmdv2/extern/include/portaudiocpp/AutoSystem.hxx new file mode 100644 index 00000000..16cac5ed --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/AutoSystem.hxx @@ -0,0 +1,62 @@ +#ifndef INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX +#define INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudiocpp/System.hxx" + +// --------------------------------------------------------------------------------------- + +namespace portaudio +{ + + + ////// + /// @brief A RAII idiom class to ensure automatic clean-up when an exception is + /// raised. + /// + /// A simple helper class which uses the 'Resource Acquisition is Initialization' + /// idiom (RAII). Use this class to initialize/terminate the System rather than + /// using System directly. AutoSystem must be created on stack and must be valid + /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be + /// a good place for it. + /// + /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually + /// a good idea to make a reference to the System which can be accessed directly. + /// @verbatim + /// portaudio::AutoSys autoSys; + /// portaudio::System &sys = portaudio::System::instance(); + /// @endverbatim + ////// + class AutoSystem + { + public: + AutoSystem(bool initialize = true) + { + if (initialize) + System::initialize(); + } + + ~AutoSystem() + { + if (System::exists()) + System::terminate(); + } + + void initialize() + { + System::initialize(); + } + + void terminate() + { + System::terminate(); + } + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/BlockingStream.hxx b/fdmdv2/extern/include/portaudiocpp/BlockingStream.hxx new file mode 100644 index 00000000..37fa7665 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/BlockingStream.hxx @@ -0,0 +1,45 @@ +#ifndef INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX +#define INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudiocpp/Stream.hxx" + +// --------------------------------------------------------------------------------------- + +namespace portaudio +{ + + + + ////// + /// @brief Stream class for blocking read/write-style input and output. + ////// + class BlockingStream : public Stream + { + public: + BlockingStream(); + BlockingStream(const StreamParameters ¶meters); + ~BlockingStream(); + + void open(const StreamParameters ¶meters); + + void read(void *buffer, unsigned long numFrames); + void write(const void *buffer, unsigned long numFrames); + + signed long availableReadSize() const; + signed long availableWriteSize() const; + + private: + BlockingStream(const BlockingStream &); // non-copyable + BlockingStream &operator=(const BlockingStream &); // non-copyable + }; + + + +} // portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/CFunCallbackStream.hxx b/fdmdv2/extern/include/portaudiocpp/CFunCallbackStream.hxx new file mode 100644 index 00000000..b3e3b5c1 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/CFunCallbackStream.hxx @@ -0,0 +1,49 @@ +#ifndef INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX +#define INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/CallbackStream.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s) +namespace portaudio +{ + class StreamParameters; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Callback stream using a free function with C linkage. It's important that the function + /// the passed function pointer points to is declared ``extern "C"''. + ////// + class CFunCallbackStream : public CallbackStream + { + public: + CFunCallbackStream(); + CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); + ~CFunCallbackStream(); + + void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); + + private: + CFunCallbackStream(const CFunCallbackStream &); // non-copyable + CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable + }; + + // ----------------------------------------------------------------------------------- +} // portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/CallbackInterface.hxx b/fdmdv2/extern/include/portaudiocpp/CallbackInterface.hxx new file mode 100644 index 00000000..d498ec5b --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/CallbackInterface.hxx @@ -0,0 +1,45 @@ +#ifndef INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX +#define INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +// --------------------------------------------------------------------------------------- + +namespace portaudio +{ + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the + /// paCallbackFun method). + ////// + class CallbackInterface + { + public: + virtual ~CallbackInterface() {} + + virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0; + }; + + // ----------------------------------------------------------------------------------- + + namespace impl + { + extern "C" + { + int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, + void *userData); + } // extern "C" + } + + // ----------------------------------------------------------------------------------- + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/CallbackStream.hxx b/fdmdv2/extern/include/portaudiocpp/CallbackStream.hxx new file mode 100644 index 00000000..0382275e --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/CallbackStream.hxx @@ -0,0 +1,40 @@ +#ifndef INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX +#define INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/Stream.hxx" + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief Base class for all Streams which use a callback-based mechanism. + ////// + class CallbackStream : public Stream + { + protected: + CallbackStream(); + virtual ~CallbackStream(); + + public: + // stream info (time-varying) + double cpuLoad() const; + + private: + CallbackStream(const CallbackStream &); // non-copyable + CallbackStream &operator=(const CallbackStream &); // non-copyable + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/CppFunCallbackStream.hxx b/fdmdv2/extern/include/portaudiocpp/CppFunCallbackStream.hxx new file mode 100644 index 00000000..e0c00127 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/CppFunCallbackStream.hxx @@ -0,0 +1,86 @@ +#ifndef INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX +#define INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/CallbackStream.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class StreamParameters; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + namespace impl + { + extern "C" + { + int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, + void *userData); + } // extern "C" + } + + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Callback stream using a C++ function (either a free function or a static function) + /// callback. + ////// + class FunCallbackStream : public CallbackStream + { + public: + typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, + void *userData); + + // ------------------------------------------------------------------------------- + + ////// + /// @brief Simple structure containing a function pointer to the C++ callback function and a + /// (void) pointer to the user supplied data. + ////// + struct CppToCCallbackData + { + CppToCCallbackData(); + CppToCCallbackData(CallbackFunPtr funPtr, void *userData); + void init(CallbackFunPtr funPtr, void *userData); + + CallbackFunPtr funPtr; + void *userData; + }; + + // ------------------------------------------------------------------------------- + + FunCallbackStream(); + FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); + ~FunCallbackStream(); + + void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); + + private: + FunCallbackStream(const FunCallbackStream &); // non-copyable + FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable + + CppToCCallbackData adapterData_; + + void open(const StreamParameters ¶meters); + }; + + +} // portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/Device.hxx b/fdmdv2/extern/include/portaudiocpp/Device.hxx new file mode 100644 index 00000000..ffde7aa8 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/Device.hxx @@ -0,0 +1,91 @@ +#ifndef INCLUDED_PORTAUDIO_DEVICE_HXX +#define INCLUDED_PORTAUDIO_DEVICE_HXX + +// --------------------------------------------------------------------------------------- + +#include + +#include "portaudio.h" + +#include "portaudiocpp/SampleDataFormat.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class System; + class HostApi; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + ////// + /// @brief Class which represents a PortAudio device in the System. + /// + /// A single physical device in the system may have multiple PortAudio + /// Device representations using different HostApi 's though. A Device + /// can be half-duplex or full-duplex. A half-duplex Device can be used + /// to create a half-duplex Stream. A full-duplex Device can be used to + /// create a full-duplex Stream. If supported by the HostApi, two + /// half-duplex Devices can even be used to create a full-duplex Stream. + /// + /// Note that Device objects are very light-weight and can be passed around + /// by-value. + ////// + class Device + { + public: + // query info: name, max in channels, max out channels, + // default low/hight input/output latency, default sample rate + PaDeviceIndex index() const; + const char *name() const; + int maxInputChannels() const; + int maxOutputChannels() const; + PaTime defaultLowInputLatency() const; + PaTime defaultHighInputLatency() const; + PaTime defaultLowOutputLatency() const; + PaTime defaultHighOutputLatency() const; + double defaultSampleRate() const; + + bool isInputOnlyDevice() const; // extended + bool isOutputOnlyDevice() const; // extended + bool isFullDuplexDevice() const; // extended + bool isSystemDefaultInputDevice() const; // extended + bool isSystemDefaultOutputDevice() const; // extended + bool isHostApiDefaultInputDevice() const; // extended + bool isHostApiDefaultOutputDevice() const; // extended + + bool operator==(const Device &rhs); + bool operator!=(const Device &rhs); + + // host api reference + HostApi &hostApi(); + const HostApi &hostApi() const; + + private: + PaDeviceIndex index_; + const PaDeviceInfo *info_; + + private: + friend class System; + + explicit Device(PaDeviceIndex index); + ~Device(); + + Device(const Device &); // non-copyable + Device &operator=(const Device &); // non-copyable + }; + + // ----------------------------------------------------------------------------------- + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_DEVICE_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/DirectionSpecificStreamParameters.hxx b/fdmdv2/extern/include/portaudiocpp/DirectionSpecificStreamParameters.hxx new file mode 100644 index 00000000..dd5ae0b9 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/DirectionSpecificStreamParameters.hxx @@ -0,0 +1,77 @@ +#ifndef INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX +#define INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX + +// --------------------------------------------------------------------------------------- + +#include + +#include "portaudio.h" + +#include "portaudiocpp/System.hxx" +#include "portaudiocpp/SampleDataFormat.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class Device; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + ////// + /// @brief All parameters for one direction (either in or out) of a Stream. Together with + /// parameters common to both directions, two DirectionSpecificStreamParameters can make up + /// a StreamParameters object which contains all parameters for a Stream. + ////// + class DirectionSpecificStreamParameters + { + public: + static DirectionSpecificStreamParameters null(); + + DirectionSpecificStreamParameters(); + DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, + bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo); + + // Set up methods: + void setDevice(const Device &device); + void setNumChannels(int numChannels); + + void setSampleFormat(SampleDataFormat format, bool interleaved = true); + void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true); + + void setSuggestedLatency(PaTime latency); + + void setHostApiSpecificStreamInfo(void *streamInfo); + + // Accessor methods: + PaStreamParameters *paStreamParameters(); + const PaStreamParameters *paStreamParameters() const; + + Device &device() const; + int numChannels() const; + + SampleDataFormat sampleFormat() const; + bool isSampleFormatInterleaved() const; + bool isSampleFormatHostApiSpecific() const; + PaSampleFormat hostApiSpecificSampleFormat() const; + + PaTime suggestedLatency() const; + + void *hostApiSpecificStreamInfo() const; + + private: + PaStreamParameters paStreamParameters_; + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/Exception.hxx b/fdmdv2/extern/include/portaudiocpp/Exception.hxx new file mode 100644 index 00000000..a70c2f1d --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/Exception.hxx @@ -0,0 +1,108 @@ +#ifndef INCLUDED_PORTAUDIO_EXCEPTION_HXX +#define INCLUDED_PORTAUDIO_EXCEPTION_HXX + +// --------------------------------------------------------------------------------------- + +#include + +#include "portaudio.h" + +// --------------------------------------------------------------------------------------- + +namespace portaudio +{ + + ////// + /// @brief Base class for all exceptions PortAudioCpp can throw. + /// + /// Class is derived from std::exception. + ////// + class Exception : public std::exception + { + public: + virtual ~Exception() throw() {} + + virtual const char *what() const throw() = 0; + }; + + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Wrapper for PortAudio error codes to C++ exceptions. + /// + /// It wraps up PortAudio's error handling mechanism using + /// C++ exceptions and is derived from std::exception for + /// easy exception handling and to ease integration with + /// other code. + /// + /// To know what exceptions each function may throw, look up + /// the errors that can occure in the PortAudio documentation + /// for the equivalent functions. + /// + /// Some functions are likely to throw an exception (such as + /// Stream::open(), etc) and these should always be called in + /// try{} catch{} blocks and the thrown exceptions should be + /// handled properly (ie. the application shouldn't just abort, + /// but merely display a warning dialog to the user or something). + /// However nearly all functions in PortAudioCpp are capable + /// of throwing exceptions. When a function like Stream::isStopped() + /// throws an exception, it's such an exceptional state that it's + /// not likely that it can be recovered. PaExceptions such as these + /// can ``safely'' be left to be handled by some outer catch-all-like + /// mechanism for unrecoverable errors. + ////// + class PaException : public Exception + { + public: + explicit PaException(PaError error); + + const char *what() const throw(); + + PaError paError() const; + const char *paErrorText() const; + + bool isHostApiError() const; // extended + long lastHostApiError() const; + const char *lastHostApiErrorText() const; + + bool operator==(const PaException &rhs) const; + bool operator!=(const PaException &rhs) const; + + private: + PaError error_; + }; + + // ----------------------------------------------------------------------------------- + + ////// + /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an + /// equivalent PortAudio error code). + ////// + class PaCppException : public Exception + { + public: + enum ExceptionSpecifier + { + UNABLE_TO_ADAPT_DEVICE + }; + + PaCppException(ExceptionSpecifier specifier); + + const char *what() const throw(); + + ExceptionSpecifier specifier() const; + + bool operator==(const PaCppException &rhs) const; + bool operator!=(const PaCppException &rhs) const; + + private: + ExceptionSpecifier specifier_; + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/HostApi.hxx b/fdmdv2/extern/include/portaudiocpp/HostApi.hxx new file mode 100644 index 00000000..899fc42d --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/HostApi.hxx @@ -0,0 +1,76 @@ +#ifndef INCLUDED_PORTAUDIO_HOSTAPI_HXX +#define INCLUDED_PORTAUDIO_HOSTAPI_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/System.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class Device; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief HostApi represents a host API (usually type of driver) in the System. + /// + /// A single System can support multiple HostApi's each one typically having + /// a set of Devices using that HostApi (usually driver type). All Devices in + /// the HostApi can be enumerated and the default input/output Device for this + /// HostApi can be retreived. + ////// + class HostApi + { + public: + typedef System::DeviceIterator DeviceIterator; + + // query info: id, name, numDevices + PaHostApiTypeId typeId() const; + PaHostApiIndex index() const; + const char *name() const; + int deviceCount() const; + + // iterate devices + DeviceIterator devicesBegin(); + DeviceIterator devicesEnd(); + + // default devices + Device &defaultInputDevice() const; + Device &defaultOutputDevice() const; + + // comparison operators + bool operator==(const HostApi &rhs) const; + bool operator!=(const HostApi &rhs) const; + + private: + const PaHostApiInfo *info_; + Device **devices_; + + private: + friend class System; + + explicit HostApi(PaHostApiIndex index); + ~HostApi(); + + HostApi(const HostApi &); // non-copyable + HostApi &operator=(const HostApi &); // non-copyable + }; + + +} + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_HOSTAPI_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/InterfaceCallbackStream.hxx b/fdmdv2/extern/include/portaudiocpp/InterfaceCallbackStream.hxx new file mode 100644 index 00000000..e496dd27 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/InterfaceCallbackStream.hxx @@ -0,0 +1,49 @@ +#ifndef INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX +#define INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/CallbackStream.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s) +namespace portaudio +{ + class StreamParameters; + class CallbackInterface; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface + /// interface. + ////// + class InterfaceCallbackStream : public CallbackStream + { + public: + InterfaceCallbackStream(); + InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance); + ~InterfaceCallbackStream(); + + void open(const StreamParameters ¶meters, CallbackInterface &instance); + + private: + InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable + InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable + }; + + +} // portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/MemFunCallbackStream.hxx b/fdmdv2/extern/include/portaudiocpp/MemFunCallbackStream.hxx new file mode 100644 index 00000000..a9e50ca6 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/MemFunCallbackStream.hxx @@ -0,0 +1,107 @@ +#ifndef INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX +#define INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/CallbackStream.hxx" +#include "portaudiocpp/CallbackInterface.hxx" +#include "portaudiocpp/StreamParameters.hxx" +#include "portaudiocpp/Exception.hxx" +#include "portaudiocpp/InterfaceCallbackStream.hxx" + +// --------------------------------------------------------------------------------------- + +namespace portaudio +{ + + + ////// + /// @brief Callback stream using a class's member function as a callback. Template argument T is the type of the + /// class of which a member function is going to be used. + /// + /// Example usage: + /// @verbatim MemFunCallback stream = MemFunCallbackStream(parameters, *this, &MyClass::myCallbackFunction); @endverbatim + ////// + template + class MemFunCallbackStream : public CallbackStream + { + public: + typedef int (T::*CallbackFunPtr)(const void *, void *, unsigned long, const PaStreamCallbackTimeInfo *, + PaStreamCallbackFlags); + + // ------------------------------------------------------------------------------- + + MemFunCallbackStream() + { + } + + MemFunCallbackStream(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) : adapter_(instance, memFun) + { + open(parameters); + } + + ~MemFunCallbackStream() + { + close(); + } + + void open(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) + { + // XXX: need to check if already open? + + adapter_.init(instance, memFun); + open(parameters); + } + + private: + MemFunCallbackStream(const MemFunCallbackStream &); // non-copyable + MemFunCallbackStream &operator=(const MemFunCallbackStream &); // non-copyable + + ////// + /// @brief Inner class which adapts a member function callback to a CallbackInterface compliant + /// class (so it can be adapted using the paCallbackAdapter function). + ////// + class MemFunToCallbackInterfaceAdapter : public CallbackInterface + { + public: + MemFunToCallbackInterfaceAdapter() {} + MemFunToCallbackInterfaceAdapter(T &instance, CallbackFunPtr memFun) : instance_(&instance), memFun_(memFun) {} + + void init(T &instance, CallbackFunPtr memFun) + { + instance_ = &instance; + memFun_ = memFun; + } + + int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, + const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) + { + return (instance_->*memFun_)(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); + } + + private: + T *instance_; + CallbackFunPtr memFun_; + }; + + MemFunToCallbackInterfaceAdapter adapter_; + + void open(const StreamParameters ¶meters) + { + PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), + parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, + static_cast(&adapter_)); + + if (err != paNoError) + throw PaException(err); + } + }; + + +} // portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/PortAudioCpp.hxx b/fdmdv2/extern/include/portaudiocpp/PortAudioCpp.hxx new file mode 100644 index 00000000..f11e7fb9 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/PortAudioCpp.hxx @@ -0,0 +1,109 @@ +#ifndef INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX +#define INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX + +// --------------------------------------------------------------------------------------- + +////// +/// @mainpage PortAudioCpp +/// +///

PortAudioCpp - A Native C++ Binding of PortAudio V19

+///

PortAudio

+///

+/// PortAudio is a portable and mature C API for accessing audio hardware. It offers both callback-based and blocking +/// style input and output, deals with sample data format conversions, dithering and much more. There are a large number +/// of implementations available for various platforms including Windows MME, Windows DirectX, Windows and MacOS (Classic) +/// ASIO, MacOS Classic SoundManager, MacOS X CoreAudio, OSS (Linux), Linux ALSA, JACK (MacOS X and Linux) and SGI Irix +/// AL. Note that, currently not all of these implementations are equally complete or up-to-date (as PortAudio V19 is +/// still in development). Because PortAudio has a C API, it can easily be called from a variety of other programming +/// languages. +///

+///

PortAudioCpp

+///

+/// Although, it is possible to use PortAudio's C API from within a C++ program, this is usually a little awkward +/// as procedural and object-oriented paradigms need to be mixed. PortAudioCpp aims to resolve this by encapsulating +/// PortAudio's C API to form an equivalent object-oriented C++ API. It provides a more natural integration of PortAudio +/// into C++ programs as well as a more structured interface. PortAudio's concepts were preserved as much as possible and +/// no additional features were added except for some `convenience methods'. +///

+///

+/// PortAudioCpp's main features are: +///

    +///
  • Structured object model.
  • +///
  • C++ exception handling instead of C-style error return codes.
  • +///
  • Handling of callbacks using free functions (C and C++), static functions, member functions or instances of classes +/// derived from a given interface.
  • +///
  • STL compliant iterators to host APIs and devices.
  • +///
  • Some additional convenience functions to more easily set up and use PortAudio.
  • +///
+///

+///

+/// PortAudioCpp requires a recent version of the PortAudio V19 source code. This can be obtained from CVS or as a snapshot +/// from the website. The examples also require the ASIO 2 SDK which can be obtained from the Steinberg website. Alternatively, the +/// examples can easily be modified to compile without needing ASIO. +///

+///

+/// Supported platforms: +///

    +///
  • Microsoft Visual C++ 6.0, 7.0 (.NET 2002) and 7.1 (.NET 2003).
  • +///
  • GNU G++ 2.95 and G++ 3.3.
  • +///
+/// Other platforms should be easily supported as PortAudioCpp is platform-independent and (reasonably) C++ standard compliant. +///

+///

+/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explaination of all of the +/// concepts used, please consult the PortAudio documentation. +///

+///

+/// PortAudioCpp was developed by Merlijn Blaauw with many great suggestions and help from Ross Bencina. Ludwig Schwardt provided +/// GNU/Linux build files and checked G++ compatibility. PortAudioCpp may be used under the same licensing, conditions and +/// warranty as PortAudio. See the PortAudio license for more details. +///

+///

Links

+///

+/// Official PortAudio site.
+///

+////// + +// --------------------------------------------------------------------------------------- + +////// +/// @namespace portaudio +/// +/// To avoid name collision, everything in PortAudioCpp is in the portaudio +/// namespace. If this name is too long it's usually pretty safe to use an +/// alias like ``namespace pa = portaudio;''. +////// + +// --------------------------------------------------------------------------------------- + +////// +/// @file PortAudioCpp.hxx +/// An include-all header file (for lazy programmers and using pre-compiled headers). +////// + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/AutoSystem.hxx" +#include "portaudiocpp/BlockingStream.hxx" +#include "portaudiocpp/CallbackInterface.hxx" +#include "portaudiocpp/CallbackStream.hxx" +#include "portaudiocpp/CFunCallbackStream.hxx" +#include "portaudiocpp/CppFunCallbackStream.hxx" +#include "portaudiocpp/Device.hxx" +#include "portaudiocpp/Exception.hxx" +#include "portaudiocpp/HostApi.hxx" +#include "portaudiocpp/InterfaceCallbackStream.hxx" +#include "portaudiocpp/MemFunCallbackStream.hxx" +#include "portaudiocpp/SampleDataFormat.hxx" +#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" +#include "portaudiocpp/Stream.hxx" +#include "portaudiocpp/StreamParameters.hxx" +#include "portaudiocpp/System.hxx" +#include "portaudiocpp/SystemDeviceIterator.hxx" +#include "portaudiocpp/SystemHostApiIterator.hxx" + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/SampleDataFormat.hxx b/fdmdv2/extern/include/portaudiocpp/SampleDataFormat.hxx new file mode 100644 index 00000000..a7e25b24 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/SampleDataFormat.hxx @@ -0,0 +1,35 @@ +#ifndef INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX +#define INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +// --------------------------------------------------------------------------------------- + +namespace portaudio +{ + + + ////// + /// @brief PortAudio sample data formats. + /// + /// Small helper enum to wrap the PortAudio defines. + ////// + enum SampleDataFormat + { + INVALID_FORMAT = 0, + FLOAT32 = paFloat32, + INT32 = paInt32, + INT24 = paInt24, + INT16 = paInt16, + INT8 = paInt8, + UINT8 = paUInt8 + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/Stream.hxx b/fdmdv2/extern/include/portaudiocpp/Stream.hxx new file mode 100644 index 00000000..8a255ec7 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/Stream.hxx @@ -0,0 +1,82 @@ +#ifndef INCLUDED_PORTAUDIO_STREAM_HXX +#define INCLUDED_PORTAUDIO_STREAM_HXX + +#include "portaudio.h" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class StreamParameters; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief A Stream represents an active or inactive input and/or output data + /// stream in the System. + /// + /// Concrete Stream classes should ensure themselves being in a closed state at + /// destruction (i.e. by calling their own close() method in their deconstructor). + /// Following good C++ programming practices, care must be taken to ensure no + /// exceptions are thrown by the deconstructor of these classes. As a consequence, + /// clients need to explicitly call close() to ensure the stream closed successfully. + /// + /// The Stream object can be used to manipulate the Stream's state. Also, time-constant + /// and time-varying information about the Stream can be retreived. + ////// + class Stream + { + public: + // Opening/closing: + virtual ~Stream(); + + virtual void close(); + bool isOpen() const; + + // Additional set up: + void setStreamFinishedCallback(PaStreamFinishedCallback *callback); + + // State management: + void start(); + void stop(); + void abort(); + + bool isStopped() const; + bool isActive() const; + + // Stream info (time-constant, but might become time-variant soon): + PaTime inputLatency() const; + PaTime outputLatency() const; + double sampleRate() const; + + // Stream info (time-varying): + PaTime time() const; + + // Accessors for PortAudio PaStream, useful for interfacing + // with PortAudio add-ons (such as PortMixer) for instance: + const PaStream *paStream() const; + PaStream *paStream(); + + protected: + Stream(); // abstract class + + PaStream *stream_; + + private: + Stream(const Stream &); // non-copyable + Stream &operator=(const Stream &); // non-copyable + }; + + +} // namespace portaudio + + +#endif // INCLUDED_PORTAUDIO_STREAM_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/StreamParameters.hxx b/fdmdv2/extern/include/portaudiocpp/StreamParameters.hxx new file mode 100644 index 00000000..2b6aa2ef --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/StreamParameters.hxx @@ -0,0 +1,77 @@ +#ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX +#define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + ////// + /// @brief The entire set of parameters needed to configure and open + /// a Stream. + /// + /// It contains parameters of input, output and shared parameters. + /// Using the isSupported() method, the StreamParameters can be + /// checked if opening a Stream using this StreamParameters would + /// succeed or not. Accessors are provided to higher-level parameters + /// aswell as the lower-level parameters which are mainly intended for + /// internal use. + ////// + class StreamParameters + { + public: + StreamParameters(); + StreamParameters(const DirectionSpecificStreamParameters &inputParameters, + const DirectionSpecificStreamParameters &outputParameters, double sampleRate, + unsigned long framesPerBuffer, PaStreamFlags flags); + + // Set up for direction-specific: + void setInputParameters(const DirectionSpecificStreamParameters ¶meters); + void setOutputParameters(const DirectionSpecificStreamParameters ¶meters); + + // Set up for common parameters: + void setSampleRate(double sampleRate); + void setFramesPerBuffer(unsigned long framesPerBuffer); + void setFlag(PaStreamFlags flag); + void unsetFlag(PaStreamFlags flag); + void clearFlags(); + + // Validation: + bool isSupported() const; + + // Accessors (direction-specific): + DirectionSpecificStreamParameters &inputParameters(); + const DirectionSpecificStreamParameters &inputParameters() const; + DirectionSpecificStreamParameters &outputParameters(); + const DirectionSpecificStreamParameters &outputParameters() const; + + // Accessors (common): + double sampleRate() const; + unsigned long framesPerBuffer() const; + PaStreamFlags flags() const; + bool isFlagSet(PaStreamFlags flag) const; + + private: + // Half-duplex specific parameters: + DirectionSpecificStreamParameters inputParameters_; + DirectionSpecificStreamParameters outputParameters_; + + // Common parameters: + double sampleRate_; + unsigned long framesPerBuffer_; + PaStreamFlags flags_; + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX diff --git a/fdmdv2/extern/include/portaudiocpp/System.hxx b/fdmdv2/extern/include/portaudiocpp/System.hxx new file mode 100644 index 00000000..f5fb7132 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/System.hxx @@ -0,0 +1,107 @@ +#ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX +#define INCLUDED_PORTAUDIO_SYSTEM_HXX + +// --------------------------------------------------------------------------------------- + +#include "portaudio.h" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class Device; + class Stream; + class HostApi; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief System singleton which represents the PortAudio system. + /// + /// The System is used to initialize/terminate PortAudio and provide + /// a single acccess point to the PortAudio System (instance()). + /// It can be used to iterate through all HostApi 's in the System as + /// well as all devices in the System. It also provides some utility + /// functionality of PortAudio. + /// + /// Terminating the System will also abort and close the open streams. + /// The Stream objects will need to be deallocated by the client though + /// (it's usually a good idea to have them cleaned up automatically). + ////// + class System + { + public: + class HostApiIterator; // forward declaration + class DeviceIterator; // forward declaration + + // ------------------------------------------------------------------------------- + + static int version(); + static const char *versionText(); + + static void initialize(); + static void terminate(); + + static System &instance(); + static bool exists(); + + // ------------------------------------------------------------------------------- + + // host apis: + HostApiIterator hostApisBegin(); + HostApiIterator hostApisEnd(); + + HostApi &defaultHostApi(); + + HostApi &hostApiByTypeId(PaHostApiTypeId type); + HostApi &hostApiByIndex(PaHostApiIndex index); + + int hostApiCount(); + + // ------------------------------------------------------------------------------- + + // devices: + DeviceIterator devicesBegin(); + DeviceIterator devicesEnd(); + + Device &defaultInputDevice(); + Device &defaultOutputDevice(); + + Device &deviceByIndex(PaDeviceIndex index); + + int deviceCount(); + + static Device &nullDevice(); + + // ------------------------------------------------------------------------------- + + // misc: + void sleep(long msec); + int sizeOfSample(PaSampleFormat format); + + private: + System(); + ~System(); + + static System *instance_; + static int initCount_; + + static HostApi **hostApis_; + static Device **devices_; + + static Device *nullDevice_; + }; + + +} // namespace portaudio + + +#endif // INCLUDED_PORTAUDIO_SYSTEM_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/SystemDeviceIterator.hxx b/fdmdv2/extern/include/portaudiocpp/SystemDeviceIterator.hxx new file mode 100644 index 00000000..613fc3db --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/SystemDeviceIterator.hxx @@ -0,0 +1,66 @@ +#ifndef INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX +#define INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX + +// --------------------------------------------------------------------------------------- + +#include +#include + +#include "portaudiocpp/System.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class Device; + class HostApi; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief Iterator class for iterating through all Devices in a System. + /// + /// Devices will be iterated by iterating all Devices in each + /// HostApi in the System. Compliant with the STL bidirectional + /// iterator concept. + ////// + class System::DeviceIterator + { + public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef Device value_type; + typedef ptrdiff_t difference_type; + typedef Device * pointer; + typedef Device & reference; + + Device &operator*() const; + Device *operator->() const; + + DeviceIterator &operator++(); + DeviceIterator operator++(int); + DeviceIterator &operator--(); + DeviceIterator operator--(int); + + bool operator==(const DeviceIterator &rhs); + bool operator!=(const DeviceIterator &rhs); + + private: + friend class System; + friend class HostApi; + Device **ptr_; + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX + diff --git a/fdmdv2/extern/include/portaudiocpp/SystemHostApiIterator.hxx b/fdmdv2/extern/include/portaudiocpp/SystemHostApiIterator.hxx new file mode 100644 index 00000000..b9b13b85 --- /dev/null +++ b/fdmdv2/extern/include/portaudiocpp/SystemHostApiIterator.hxx @@ -0,0 +1,61 @@ +#ifndef INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX +#define INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX + +// --------------------------------------------------------------------------------------- + +#include +#include + +#include "portaudiocpp/System.hxx" + +// --------------------------------------------------------------------------------------- + +// Forward declaration(s): +namespace portaudio +{ + class HostApi; +} + +// --------------------------------------------------------------------------------------- + +// Declaration(s): +namespace portaudio +{ + + + ////// + /// @brief Iterator class for iterating through all HostApis in a System. + /// + /// Compliant with the STL bidirectional iterator concept. + ////// + class System::HostApiIterator + { + public: + typedef std::bidirectional_iterator_tag iterator_category; + typedef Device value_type; + typedef ptrdiff_t difference_type; + typedef HostApi * pointer; + typedef HostApi & reference; + + HostApi &operator*() const; + HostApi *operator->() const; + + HostApiIterator &operator++(); + HostApiIterator operator++(int); + HostApiIterator &operator--(); + HostApiIterator operator--(int); + + bool operator==(const HostApiIterator &rhs); + bool operator!=(const HostApiIterator &rhs); + + private: + friend class System; + HostApi **ptr_; + }; + + +} // namespace portaudio + +// --------------------------------------------------------------------------------------- + +#endif // INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX diff --git a/fdmdv2/fdmdv2.mk b/fdmdv2/fdmdv2.mk index 85b3e0eb..8dc37dad 100644 --- a/fdmdv2/fdmdv2.mk +++ b/fdmdv2/fdmdv2.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=wittend -Date :=5/13/2012 +Date :=5/17/2012 CodeLitePath :="C:\Program Files\CodeLite" LinkerName :=g++ ArchiveTool :=ar rcus @@ -56,7 +56,7 @@ WXWIN:=C:\bin\wxWidgets-2.9.2 PATH:=$(WXWIN)\lib\gcc_dll;$(PATH) WXCFG:=gcc_dll\mswu UNIT_TEST_PP_SRC_DIR:=C:\bin\UnitTest++-1.3 -Objects=$(IntermediateDirectory)/topFrame$(ObjectSuffix) $(IntermediateDirectory)/dlg_about$(ObjectSuffix) $(IntermediateDirectory)/dlg_audio$(ObjectSuffix) $(IntermediateDirectory)/dlg_options$(ObjectSuffix) $(IntermediateDirectory)/dlg_comports$(ObjectSuffix) $(IntermediateDirectory)/fdmdv2_plot$(ObjectSuffix) $(IntermediateDirectory)/fdmdv2_main$(ObjectSuffix) +Objects=$(IntermediateDirectory)/topFrame$(ObjectSuffix) $(IntermediateDirectory)/dlg_about$(ObjectSuffix) $(IntermediateDirectory)/dlg_audio$(ObjectSuffix) $(IntermediateDirectory)/dlg_options$(ObjectSuffix) $(IntermediateDirectory)/dlg_comports$(ObjectSuffix) $(IntermediateDirectory)/fdmdv2_plot$(ObjectSuffix) $(IntermediateDirectory)/fdmdv2_main$(ObjectSuffix) $(IntermediateDirectory)/thread_audio$(ObjectSuffix) $(IntermediateDirectory)/fdmdv2_thread_audio$(ObjectSuffix) ## ## Main Build Targets @@ -135,6 +135,22 @@ $(IntermediateDirectory)/fdmdv2_main$(DependSuffix): fdmdv2_main.cpp $(IntermediateDirectory)/fdmdv2_main$(PreprocessSuffix): fdmdv2_main.cpp @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/fdmdv2_main$(PreprocessSuffix) "C:/Users/wittend/Projects/Radio/fdmdv2/fdmdv2_main.cpp" +$(IntermediateDirectory)/thread_audio$(ObjectSuffix): thread_audio.cpp $(IntermediateDirectory)/thread_audio$(DependSuffix) + $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/Users/wittend/Projects/Radio/fdmdv2/thread_audio.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/thread_audio$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/thread_audio$(DependSuffix): thread_audio.cpp + @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/thread_audio$(ObjectSuffix) -MF$(IntermediateDirectory)/thread_audio$(DependSuffix) -MM "C:/Users/wittend/Projects/Radio/fdmdv2/thread_audio.cpp" + +$(IntermediateDirectory)/thread_audio$(PreprocessSuffix): thread_audio.cpp + @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/thread_audio$(PreprocessSuffix) "C:/Users/wittend/Projects/Radio/fdmdv2/thread_audio.cpp" + +$(IntermediateDirectory)/fdmdv2_thread_audio$(ObjectSuffix): fdmdv2_thread_audio.cpp $(IntermediateDirectory)/fdmdv2_thread_audio$(DependSuffix) + $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/Users/wittend/Projects/Radio/fdmdv2/fdmdv2_thread_audio.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/fdmdv2_thread_audio$(ObjectSuffix) $(IncludePath) +$(IntermediateDirectory)/fdmdv2_thread_audio$(DependSuffix): fdmdv2_thread_audio.cpp + @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/fdmdv2_thread_audio$(ObjectSuffix) -MF$(IntermediateDirectory)/fdmdv2_thread_audio$(DependSuffix) -MM "C:/Users/wittend/Projects/Radio/fdmdv2/fdmdv2_thread_audio.cpp" + +$(IntermediateDirectory)/fdmdv2_thread_audio$(PreprocessSuffix): fdmdv2_thread_audio.cpp + @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/fdmdv2_thread_audio$(PreprocessSuffix) "C:/Users/wittend/Projects/Radio/fdmdv2/fdmdv2_thread_audio.cpp" + -include $(IntermediateDirectory)/*$(DependSuffix) ## @@ -162,6 +178,12 @@ clean: $(RM) $(IntermediateDirectory)/fdmdv2_main$(ObjectSuffix) $(RM) $(IntermediateDirectory)/fdmdv2_main$(DependSuffix) $(RM) $(IntermediateDirectory)/fdmdv2_main$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/thread_audio$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/thread_audio$(DependSuffix) + $(RM) $(IntermediateDirectory)/thread_audio$(PreprocessSuffix) + $(RM) $(IntermediateDirectory)/fdmdv2_thread_audio$(ObjectSuffix) + $(RM) $(IntermediateDirectory)/fdmdv2_thread_audio$(DependSuffix) + $(RM) $(IntermediateDirectory)/fdmdv2_thread_audio$(PreprocessSuffix) $(RM) $(OutputFile) $(RM) $(OutputFile).exe $(RM) "C:\Users\wittend\Projects\Radio\fdmdv2\.build-release\fdmdv2" diff --git a/fdmdv2/fdmdv2.project b/fdmdv2/fdmdv2.project index 1a55b90b..883aea66 100644 --- a/fdmdv2/fdmdv2.project +++ b/fdmdv2/fdmdv2.project @@ -15,6 +15,8 @@ + + @@ -24,6 +26,8 @@ + + diff --git a/fdmdv2/fdmdv2.workspace b/fdmdv2/fdmdv2.workspace index 748741c3..9254a85e 100644 --- a/fdmdv2/fdmdv2.workspace +++ b/fdmdv2/fdmdv2.workspace @@ -2,7 +2,9 @@ - + + + @@ -11,6 +13,8 @@ + + @@ -19,6 +23,8 @@ + + diff --git a/fdmdv2/fdmdv2_main.h b/fdmdv2/fdmdv2_main.h index b13f6e7d..08f03fda 100644 --- a/fdmdv2/fdmdv2_main.h +++ b/fdmdv2/fdmdv2_main.h @@ -30,6 +30,7 @@ #include "dlg_options.h" #include "dlg_comports.h" #include "fdmdv2_plot.h" +#include "fdmdv2_thread_audio.h" #define WAV_FILE wxT("doggrowl.wav") @@ -85,7 +86,7 @@ class MainFrame : public TopFrame void OnThreadCompletion(wxThreadEvent&); protected: - MyThread *m_pThread; + Fdmdv2ThreadAudio *m_pThread; wxCriticalSection m_pThreadCS; // protects the m_pThread pointer // protected event handlers virtual void OnCloseFrame(wxCloseEvent& event); diff --git a/fdmdv2/fdmdv2_thread_audio.cpp b/fdmdv2/fdmdv2_thread_audio.cpp new file mode 100644 index 00000000..4d17ea41 --- /dev/null +++ b/fdmdv2/fdmdv2_thread_audio.cpp @@ -0,0 +1,30 @@ +#include "fdmdv2_thread_audio.h" + +//namespace NSfdmdv2Audio +//{ + + Fdmdv2ThreadAudio::Fdmdv2ThreadAudio() + { + } + + Fdmdv2ThreadAudio::~Fdmdv2ThreadAudio() + { + } + + void* Fdmdv2ThreadAudio::Entry() + { + return NULL; + } + void Fdmdv2ThreadAudio::OnDelete() + { + } + void Fdmdv2ThreadAudio::OnExit() + { + } + void Fdmdv2ThreadAudio::OnKill() + { + } +// bool Fdmdv2ThreadAudio::TestDestroy() +// { +// } +//} diff --git a/fdmdv2/fdmdv2_thread_audio.h b/fdmdv2/fdmdv2_thread_audio.h new file mode 100644 index 00000000..d96221f0 --- /dev/null +++ b/fdmdv2/fdmdv2_thread_audio.h @@ -0,0 +1,20 @@ +#ifndef __THREAD_AUDIO__ +#define __THREAD_AUDIO__ +#include "wx/thread.h" // Base class: wxThread + +//namespace NSfdmdv2Audio +//{ + class Fdmdv2ThreadAudio : public wxThread + { + public: + Fdmdv2ThreadAudio(); + ~Fdmdv2ThreadAudio(); + public: + virtual void* Entry(); + virtual void OnDelete(); + virtual void OnExit(); + virtual void OnKill(); + virtual bool TestDestroy(); + }; +//} +#endif // __THREAD_AUDIO__ diff --git a/fdmdv2/fdmdv2_wsp.mk b/fdmdv2/fdmdv2_wsp.mk index 661439a3..13bc5fdc 100644 --- a/fdmdv2/fdmdv2_wsp.mk +++ b/fdmdv2/fdmdv2_wsp.mk @@ -1,8 +1,8 @@ .PHONY: clean All All: - @echo ----------Building project:[ test_hamlib - Release ]---------- - @cd "hamlib-3.0\test_hamlib" && "mingw32-make.exe" -j 2 -f "test_hamlib.mk" + @echo ----------Building project:[ pa_cppbinding_test - Release ]---------- + @cd "pa_cppbinding_test" && "mingw32-make.exe" -j 2 -f "pa_cppbinding_test.mk" clean: - @echo ----------Cleaning project:[ test_hamlib - Release ]---------- - @cd "hamlib-3.0\test_hamlib" && "mingw32-make.exe" -j 2 -f "test_hamlib.mk" clean + @echo ----------Cleaning project:[ pa_cppbinding_test - Release ]---------- + @cd "pa_cppbinding_test" && "mingw32-make.exe" -j 2 -f "pa_cppbinding_test.mk" clean diff --git a/fdmdv2/pa_cpp_binding/AsioDeviceAdapter.hxx b/fdmdv2/pa_cpp_binding/AsioDeviceAdapter.hxx deleted file mode 100644 index 1964b6a2..00000000 --- a/fdmdv2/pa_cpp_binding/AsioDeviceAdapter.hxx +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX -#define INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX - -namespace portaudio -{ - - // Forward declaration(s): - class Device; - - // Declaration(s): - ////// - /// @brief Adapts the given Device to an ASIO specific extension. - /// - /// Deleting the AsioDeviceAdapter does not affect the underlaying - /// Device. - ////// - class AsioDeviceAdapter - { - public: - AsioDeviceAdapter(Device &device); - - Device &device(); - - long minBufferSize() const; - long maxBufferSize() const; - long preferredBufferSize() const; - long granularity() const; - - void showControlPanel(void *systemSpecific); - - const char *inputChannelName(int channelIndex) const; - const char *outputChannelName(int channelIndex) const; - - private: - Device *device_; - - long minBufferSize_; - long maxBufferSize_; - long preferredBufferSize_; - long granularity_; - }; -} - -#endif // INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX diff --git a/fdmdv2/pa_cpp_binding/AutoSystem.hxx b/fdmdv2/pa_cpp_binding/AutoSystem.hxx deleted file mode 100644 index 16cac5ed..00000000 --- a/fdmdv2/pa_cpp_binding/AutoSystem.hxx +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX -#define INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - ////// - /// @brief A RAII idiom class to ensure automatic clean-up when an exception is - /// raised. - /// - /// A simple helper class which uses the 'Resource Acquisition is Initialization' - /// idiom (RAII). Use this class to initialize/terminate the System rather than - /// using System directly. AutoSystem must be created on stack and must be valid - /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be - /// a good place for it. - /// - /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually - /// a good idea to make a reference to the System which can be accessed directly. - /// @verbatim - /// portaudio::AutoSys autoSys; - /// portaudio::System &sys = portaudio::System::instance(); - /// @endverbatim - ////// - class AutoSystem - { - public: - AutoSystem(bool initialize = true) - { - if (initialize) - System::initialize(); - } - - ~AutoSystem() - { - if (System::exists()) - System::terminate(); - } - - void initialize() - { - System::initialize(); - } - - void terminate() - { - System::terminate(); - } - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX diff --git a/fdmdv2/pa_cpp_binding/BlockingStream.hxx b/fdmdv2/pa_cpp_binding/BlockingStream.hxx deleted file mode 100644 index 37fa7665..00000000 --- a/fdmdv2/pa_cpp_binding/BlockingStream.hxx +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX -#define INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudiocpp/Stream.hxx" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - - ////// - /// @brief Stream class for blocking read/write-style input and output. - ////// - class BlockingStream : public Stream - { - public: - BlockingStream(); - BlockingStream(const StreamParameters ¶meters); - ~BlockingStream(); - - void open(const StreamParameters ¶meters); - - void read(void *buffer, unsigned long numFrames); - void write(const void *buffer, unsigned long numFrames); - - signed long availableReadSize() const; - signed long availableWriteSize() const; - - private: - BlockingStream(const BlockingStream &); // non-copyable - BlockingStream &operator=(const BlockingStream &); // non-copyable - }; - - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX - diff --git a/fdmdv2/pa_cpp_binding/CFunCallbackStream.hxx b/fdmdv2/pa_cpp_binding/CFunCallbackStream.hxx deleted file mode 100644 index b3e3b5c1..00000000 --- a/fdmdv2/pa_cpp_binding/CFunCallbackStream.hxx +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s) -namespace portaudio -{ - class StreamParameters; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Callback stream using a free function with C linkage. It's important that the function - /// the passed function pointer points to is declared ``extern "C"''. - ////// - class CFunCallbackStream : public CallbackStream - { - public: - CFunCallbackStream(); - CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); - ~CFunCallbackStream(); - - void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); - - private: - CFunCallbackStream(const CFunCallbackStream &); // non-copyable - CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable - }; - - // ----------------------------------------------------------------------------------- -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX - diff --git a/fdmdv2/pa_cpp_binding/CallbackInterface.hxx b/fdmdv2/pa_cpp_binding/CallbackInterface.hxx deleted file mode 100644 index d498ec5b..00000000 --- a/fdmdv2/pa_cpp_binding/CallbackInterface.hxx +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX -#define INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the - /// paCallbackFun method). - ////// - class CallbackInterface - { - public: - virtual ~CallbackInterface() {} - - virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0; - }; - - // ----------------------------------------------------------------------------------- - - namespace impl - { - extern "C" - { - int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - } // extern "C" - } - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX diff --git a/fdmdv2/pa_cpp_binding/CallbackStream.hxx b/fdmdv2/pa_cpp_binding/CallbackStream.hxx deleted file mode 100644 index 0382275e..00000000 --- a/fdmdv2/pa_cpp_binding/CallbackStream.hxx +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/Stream.hxx" - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Base class for all Streams which use a callback-based mechanism. - ////// - class CallbackStream : public Stream - { - protected: - CallbackStream(); - virtual ~CallbackStream(); - - public: - // stream info (time-varying) - double cpuLoad() const; - - private: - CallbackStream(const CallbackStream &); // non-copyable - CallbackStream &operator=(const CallbackStream &); // non-copyable - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX diff --git a/fdmdv2/pa_cpp_binding/CppFunCallbackStream.hxx b/fdmdv2/pa_cpp_binding/CppFunCallbackStream.hxx deleted file mode 100644 index e0c00127..00000000 --- a/fdmdv2/pa_cpp_binding/CppFunCallbackStream.hxx +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class StreamParameters; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - namespace impl - { - extern "C" - { - int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - } // extern "C" - } - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Callback stream using a C++ function (either a free function or a static function) - /// callback. - ////// - class FunCallbackStream : public CallbackStream - { - public: - typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, - void *userData); - - // ------------------------------------------------------------------------------- - - ////// - /// @brief Simple structure containing a function pointer to the C++ callback function and a - /// (void) pointer to the user supplied data. - ////// - struct CppToCCallbackData - { - CppToCCallbackData(); - CppToCCallbackData(CallbackFunPtr funPtr, void *userData); - void init(CallbackFunPtr funPtr, void *userData); - - CallbackFunPtr funPtr; - void *userData; - }; - - // ------------------------------------------------------------------------------- - - FunCallbackStream(); - FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); - ~FunCallbackStream(); - - void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); - - private: - FunCallbackStream(const FunCallbackStream &); // non-copyable - FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable - - CppToCCallbackData adapterData_; - - void open(const StreamParameters ¶meters); - }; - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX diff --git a/fdmdv2/pa_cpp_binding/Device.hxx b/fdmdv2/pa_cpp_binding/Device.hxx deleted file mode 100644 index ffde7aa8..00000000 --- a/fdmdv2/pa_cpp_binding/Device.hxx +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_DEVICE_HXX -#define INCLUDED_PORTAUDIO_DEVICE_HXX - -// --------------------------------------------------------------------------------------- - -#include - -#include "portaudio.h" - -#include "portaudiocpp/SampleDataFormat.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class System; - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - ////// - /// @brief Class which represents a PortAudio device in the System. - /// - /// A single physical device in the system may have multiple PortAudio - /// Device representations using different HostApi 's though. A Device - /// can be half-duplex or full-duplex. A half-duplex Device can be used - /// to create a half-duplex Stream. A full-duplex Device can be used to - /// create a full-duplex Stream. If supported by the HostApi, two - /// half-duplex Devices can even be used to create a full-duplex Stream. - /// - /// Note that Device objects are very light-weight and can be passed around - /// by-value. - ////// - class Device - { - public: - // query info: name, max in channels, max out channels, - // default low/hight input/output latency, default sample rate - PaDeviceIndex index() const; - const char *name() const; - int maxInputChannels() const; - int maxOutputChannels() const; - PaTime defaultLowInputLatency() const; - PaTime defaultHighInputLatency() const; - PaTime defaultLowOutputLatency() const; - PaTime defaultHighOutputLatency() const; - double defaultSampleRate() const; - - bool isInputOnlyDevice() const; // extended - bool isOutputOnlyDevice() const; // extended - bool isFullDuplexDevice() const; // extended - bool isSystemDefaultInputDevice() const; // extended - bool isSystemDefaultOutputDevice() const; // extended - bool isHostApiDefaultInputDevice() const; // extended - bool isHostApiDefaultOutputDevice() const; // extended - - bool operator==(const Device &rhs); - bool operator!=(const Device &rhs); - - // host api reference - HostApi &hostApi(); - const HostApi &hostApi() const; - - private: - PaDeviceIndex index_; - const PaDeviceInfo *info_; - - private: - friend class System; - - explicit Device(PaDeviceIndex index); - ~Device(); - - Device(const Device &); // non-copyable - Device &operator=(const Device &); // non-copyable - }; - - // ----------------------------------------------------------------------------------- - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_DEVICE_HXX - diff --git a/fdmdv2/pa_cpp_binding/DirectionSpecificStreamParameters.hxx b/fdmdv2/pa_cpp_binding/DirectionSpecificStreamParameters.hxx deleted file mode 100644 index dd5ae0b9..00000000 --- a/fdmdv2/pa_cpp_binding/DirectionSpecificStreamParameters.hxx +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX -#define INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX - -// --------------------------------------------------------------------------------------- - -#include - -#include "portaudio.h" - -#include "portaudiocpp/System.hxx" -#include "portaudiocpp/SampleDataFormat.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - ////// - /// @brief All parameters for one direction (either in or out) of a Stream. Together with - /// parameters common to both directions, two DirectionSpecificStreamParameters can make up - /// a StreamParameters object which contains all parameters for a Stream. - ////// - class DirectionSpecificStreamParameters - { - public: - static DirectionSpecificStreamParameters null(); - - DirectionSpecificStreamParameters(); - DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, - bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo); - - // Set up methods: - void setDevice(const Device &device); - void setNumChannels(int numChannels); - - void setSampleFormat(SampleDataFormat format, bool interleaved = true); - void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true); - - void setSuggestedLatency(PaTime latency); - - void setHostApiSpecificStreamInfo(void *streamInfo); - - // Accessor methods: - PaStreamParameters *paStreamParameters(); - const PaStreamParameters *paStreamParameters() const; - - Device &device() const; - int numChannels() const; - - SampleDataFormat sampleFormat() const; - bool isSampleFormatInterleaved() const; - bool isSampleFormatHostApiSpecific() const; - PaSampleFormat hostApiSpecificSampleFormat() const; - - PaTime suggestedLatency() const; - - void *hostApiSpecificStreamInfo() const; - - private: - PaStreamParameters paStreamParameters_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX diff --git a/fdmdv2/pa_cpp_binding/Exception.hxx b/fdmdv2/pa_cpp_binding/Exception.hxx deleted file mode 100644 index a70c2f1d..00000000 --- a/fdmdv2/pa_cpp_binding/Exception.hxx +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_EXCEPTION_HXX -#define INCLUDED_PORTAUDIO_EXCEPTION_HXX - -// --------------------------------------------------------------------------------------- - -#include - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - ////// - /// @brief Base class for all exceptions PortAudioCpp can throw. - /// - /// Class is derived from std::exception. - ////// - class Exception : public std::exception - { - public: - virtual ~Exception() throw() {} - - virtual const char *what() const throw() = 0; - }; - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Wrapper for PortAudio error codes to C++ exceptions. - /// - /// It wraps up PortAudio's error handling mechanism using - /// C++ exceptions and is derived from std::exception for - /// easy exception handling and to ease integration with - /// other code. - /// - /// To know what exceptions each function may throw, look up - /// the errors that can occure in the PortAudio documentation - /// for the equivalent functions. - /// - /// Some functions are likely to throw an exception (such as - /// Stream::open(), etc) and these should always be called in - /// try{} catch{} blocks and the thrown exceptions should be - /// handled properly (ie. the application shouldn't just abort, - /// but merely display a warning dialog to the user or something). - /// However nearly all functions in PortAudioCpp are capable - /// of throwing exceptions. When a function like Stream::isStopped() - /// throws an exception, it's such an exceptional state that it's - /// not likely that it can be recovered. PaExceptions such as these - /// can ``safely'' be left to be handled by some outer catch-all-like - /// mechanism for unrecoverable errors. - ////// - class PaException : public Exception - { - public: - explicit PaException(PaError error); - - const char *what() const throw(); - - PaError paError() const; - const char *paErrorText() const; - - bool isHostApiError() const; // extended - long lastHostApiError() const; - const char *lastHostApiErrorText() const; - - bool operator==(const PaException &rhs) const; - bool operator!=(const PaException &rhs) const; - - private: - PaError error_; - }; - - // ----------------------------------------------------------------------------------- - - ////// - /// @brief Exceptions specific to PortAudioCpp (ie. exceptions which do not have an - /// equivalent PortAudio error code). - ////// - class PaCppException : public Exception - { - public: - enum ExceptionSpecifier - { - UNABLE_TO_ADAPT_DEVICE - }; - - PaCppException(ExceptionSpecifier specifier); - - const char *what() const throw(); - - ExceptionSpecifier specifier() const; - - bool operator==(const PaCppException &rhs) const; - bool operator!=(const PaCppException &rhs) const; - - private: - ExceptionSpecifier specifier_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_EXCEPTION_HXX - diff --git a/fdmdv2/pa_cpp_binding/HostApi.hxx b/fdmdv2/pa_cpp_binding/HostApi.hxx deleted file mode 100644 index 899fc42d..00000000 --- a/fdmdv2/pa_cpp_binding/HostApi.hxx +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_HOSTAPI_HXX -#define INCLUDED_PORTAUDIO_HOSTAPI_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief HostApi represents a host API (usually type of driver) in the System. - /// - /// A single System can support multiple HostApi's each one typically having - /// a set of Devices using that HostApi (usually driver type). All Devices in - /// the HostApi can be enumerated and the default input/output Device for this - /// HostApi can be retreived. - ////// - class HostApi - { - public: - typedef System::DeviceIterator DeviceIterator; - - // query info: id, name, numDevices - PaHostApiTypeId typeId() const; - PaHostApiIndex index() const; - const char *name() const; - int deviceCount() const; - - // iterate devices - DeviceIterator devicesBegin(); - DeviceIterator devicesEnd(); - - // default devices - Device &defaultInputDevice() const; - Device &defaultOutputDevice() const; - - // comparison operators - bool operator==(const HostApi &rhs) const; - bool operator!=(const HostApi &rhs) const; - - private: - const PaHostApiInfo *info_; - Device **devices_; - - private: - friend class System; - - explicit HostApi(PaHostApiIndex index); - ~HostApi(); - - HostApi(const HostApi &); // non-copyable - HostApi &operator=(const HostApi &); // non-copyable - }; - - -} - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_HOSTAPI_HXX - diff --git a/fdmdv2/pa_cpp_binding/InterfaceCallbackStream.hxx b/fdmdv2/pa_cpp_binding/InterfaceCallbackStream.hxx deleted file mode 100644 index e496dd27..00000000 --- a/fdmdv2/pa_cpp_binding/InterfaceCallbackStream.hxx +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s) -namespace portaudio -{ - class StreamParameters; - class CallbackInterface; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface - /// interface. - ////// - class InterfaceCallbackStream : public CallbackStream - { - public: - InterfaceCallbackStream(); - InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance); - ~InterfaceCallbackStream(); - - void open(const StreamParameters ¶meters, CallbackInterface &instance); - - private: - InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable - InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable - }; - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX diff --git a/fdmdv2/pa_cpp_binding/MemFunCallbackStream.hxx b/fdmdv2/pa_cpp_binding/MemFunCallbackStream.hxx deleted file mode 100644 index a9e50ca6..00000000 --- a/fdmdv2/pa_cpp_binding/MemFunCallbackStream.hxx +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX -#define INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/CallbackStream.hxx" -#include "portaudiocpp/CallbackInterface.hxx" -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/InterfaceCallbackStream.hxx" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - ////// - /// @brief Callback stream using a class's member function as a callback. Template argument T is the type of the - /// class of which a member function is going to be used. - /// - /// Example usage: - /// @verbatim MemFunCallback stream = MemFunCallbackStream(parameters, *this, &MyClass::myCallbackFunction); @endverbatim - ////// - template - class MemFunCallbackStream : public CallbackStream - { - public: - typedef int (T::*CallbackFunPtr)(const void *, void *, unsigned long, const PaStreamCallbackTimeInfo *, - PaStreamCallbackFlags); - - // ------------------------------------------------------------------------------- - - MemFunCallbackStream() - { - } - - MemFunCallbackStream(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) : adapter_(instance, memFun) - { - open(parameters); - } - - ~MemFunCallbackStream() - { - close(); - } - - void open(const StreamParameters ¶meters, T &instance, CallbackFunPtr memFun) - { - // XXX: need to check if already open? - - adapter_.init(instance, memFun); - open(parameters); - } - - private: - MemFunCallbackStream(const MemFunCallbackStream &); // non-copyable - MemFunCallbackStream &operator=(const MemFunCallbackStream &); // non-copyable - - ////// - /// @brief Inner class which adapts a member function callback to a CallbackInterface compliant - /// class (so it can be adapted using the paCallbackAdapter function). - ////// - class MemFunToCallbackInterfaceAdapter : public CallbackInterface - { - public: - MemFunToCallbackInterfaceAdapter() {} - MemFunToCallbackInterfaceAdapter(T &instance, CallbackFunPtr memFun) : instance_(&instance), memFun_(memFun) {} - - void init(T &instance, CallbackFunPtr memFun) - { - instance_ = &instance; - memFun_ = memFun; - } - - int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, - const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) - { - return (instance_->*memFun_)(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); - } - - private: - T *instance_; - CallbackFunPtr memFun_; - }; - - MemFunToCallbackInterfaceAdapter adapter_; - - void open(const StreamParameters ¶meters) - { - PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), - parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, - static_cast(&adapter_)); - - if (err != paNoError) - throw PaException(err); - } - }; - - -} // portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX diff --git a/fdmdv2/pa_cpp_binding/PortAudioCpp.hxx b/fdmdv2/pa_cpp_binding/PortAudioCpp.hxx deleted file mode 100644 index f11e7fb9..00000000 --- a/fdmdv2/pa_cpp_binding/PortAudioCpp.hxx +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX -#define INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX - -// --------------------------------------------------------------------------------------- - -////// -/// @mainpage PortAudioCpp -/// -///

PortAudioCpp - A Native C++ Binding of PortAudio V19

-///

PortAudio

-///

-/// PortAudio is a portable and mature C API for accessing audio hardware. It offers both callback-based and blocking -/// style input and output, deals with sample data format conversions, dithering and much more. There are a large number -/// of implementations available for various platforms including Windows MME, Windows DirectX, Windows and MacOS (Classic) -/// ASIO, MacOS Classic SoundManager, MacOS X CoreAudio, OSS (Linux), Linux ALSA, JACK (MacOS X and Linux) and SGI Irix -/// AL. Note that, currently not all of these implementations are equally complete or up-to-date (as PortAudio V19 is -/// still in development). Because PortAudio has a C API, it can easily be called from a variety of other programming -/// languages. -///

-///

PortAudioCpp

-///

-/// Although, it is possible to use PortAudio's C API from within a C++ program, this is usually a little awkward -/// as procedural and object-oriented paradigms need to be mixed. PortAudioCpp aims to resolve this by encapsulating -/// PortAudio's C API to form an equivalent object-oriented C++ API. It provides a more natural integration of PortAudio -/// into C++ programs as well as a more structured interface. PortAudio's concepts were preserved as much as possible and -/// no additional features were added except for some `convenience methods'. -///

-///

-/// PortAudioCpp's main features are: -///

    -///
  • Structured object model.
  • -///
  • C++ exception handling instead of C-style error return codes.
  • -///
  • Handling of callbacks using free functions (C and C++), static functions, member functions or instances of classes -/// derived from a given interface.
  • -///
  • STL compliant iterators to host APIs and devices.
  • -///
  • Some additional convenience functions to more easily set up and use PortAudio.
  • -///
-///

-///

-/// PortAudioCpp requires a recent version of the PortAudio V19 source code. This can be obtained from CVS or as a snapshot -/// from the website. The examples also require the ASIO 2 SDK which can be obtained from the Steinberg website. Alternatively, the -/// examples can easily be modified to compile without needing ASIO. -///

-///

-/// Supported platforms: -///

    -///
  • Microsoft Visual C++ 6.0, 7.0 (.NET 2002) and 7.1 (.NET 2003).
  • -///
  • GNU G++ 2.95 and G++ 3.3.
  • -///
-/// Other platforms should be easily supported as PortAudioCpp is platform-independent and (reasonably) C++ standard compliant. -///

-///

-/// This documentation mainly provides information specific to PortAudioCpp. For a more complete explaination of all of the -/// concepts used, please consult the PortAudio documentation. -///

-///

-/// PortAudioCpp was developed by Merlijn Blaauw with many great suggestions and help from Ross Bencina. Ludwig Schwardt provided -/// GNU/Linux build files and checked G++ compatibility. PortAudioCpp may be used under the same licensing, conditions and -/// warranty as PortAudio. See the PortAudio license for more details. -///

-///

Links

-///

-/// Official PortAudio site.
-///

-////// - -// --------------------------------------------------------------------------------------- - -////// -/// @namespace portaudio -/// -/// To avoid name collision, everything in PortAudioCpp is in the portaudio -/// namespace. If this name is too long it's usually pretty safe to use an -/// alias like ``namespace pa = portaudio;''. -////// - -// --------------------------------------------------------------------------------------- - -////// -/// @file PortAudioCpp.hxx -/// An include-all header file (for lazy programmers and using pre-compiled headers). -////// - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/AutoSystem.hxx" -#include "portaudiocpp/BlockingStream.hxx" -#include "portaudiocpp/CallbackInterface.hxx" -#include "portaudiocpp/CallbackStream.hxx" -#include "portaudiocpp/CFunCallbackStream.hxx" -#include "portaudiocpp/CppFunCallbackStream.hxx" -#include "portaudiocpp/Device.hxx" -#include "portaudiocpp/Exception.hxx" -#include "portaudiocpp/HostApi.hxx" -#include "portaudiocpp/InterfaceCallbackStream.hxx" -#include "portaudiocpp/MemFunCallbackStream.hxx" -#include "portaudiocpp/SampleDataFormat.hxx" -#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" -#include "portaudiocpp/Stream.hxx" -#include "portaudiocpp/StreamParameters.hxx" -#include "portaudiocpp/System.hxx" -#include "portaudiocpp/SystemDeviceIterator.hxx" -#include "portaudiocpp/SystemHostApiIterator.hxx" - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_PORTAUDIOCPP_HXX diff --git a/fdmdv2/pa_cpp_binding/SampleDataFormat.hxx b/fdmdv2/pa_cpp_binding/SampleDataFormat.hxx deleted file mode 100644 index a7e25b24..00000000 --- a/fdmdv2/pa_cpp_binding/SampleDataFormat.hxx +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX -#define INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -namespace portaudio -{ - - - ////// - /// @brief PortAudio sample data formats. - /// - /// Small helper enum to wrap the PortAudio defines. - ////// - enum SampleDataFormat - { - INVALID_FORMAT = 0, - FLOAT32 = paFloat32, - INT32 = paInt32, - INT24 = paInt24, - INT16 = paInt16, - INT8 = paInt8, - UINT8 = paUInt8 - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX diff --git a/fdmdv2/pa_cpp_binding/Stream.hxx b/fdmdv2/pa_cpp_binding/Stream.hxx deleted file mode 100644 index 8a255ec7..00000000 --- a/fdmdv2/pa_cpp_binding/Stream.hxx +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_STREAM_HXX -#define INCLUDED_PORTAUDIO_STREAM_HXX - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class StreamParameters; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief A Stream represents an active or inactive input and/or output data - /// stream in the System. - /// - /// Concrete Stream classes should ensure themselves being in a closed state at - /// destruction (i.e. by calling their own close() method in their deconstructor). - /// Following good C++ programming practices, care must be taken to ensure no - /// exceptions are thrown by the deconstructor of these classes. As a consequence, - /// clients need to explicitly call close() to ensure the stream closed successfully. - /// - /// The Stream object can be used to manipulate the Stream's state. Also, time-constant - /// and time-varying information about the Stream can be retreived. - ////// - class Stream - { - public: - // Opening/closing: - virtual ~Stream(); - - virtual void close(); - bool isOpen() const; - - // Additional set up: - void setStreamFinishedCallback(PaStreamFinishedCallback *callback); - - // State management: - void start(); - void stop(); - void abort(); - - bool isStopped() const; - bool isActive() const; - - // Stream info (time-constant, but might become time-variant soon): - PaTime inputLatency() const; - PaTime outputLatency() const; - double sampleRate() const; - - // Stream info (time-varying): - PaTime time() const; - - // Accessors for PortAudio PaStream, useful for interfacing - // with PortAudio add-ons (such as PortMixer) for instance: - const PaStream *paStream() const; - PaStream *paStream(); - - protected: - Stream(); // abstract class - - PaStream *stream_; - - private: - Stream(const Stream &); // non-copyable - Stream &operator=(const Stream &); // non-copyable - }; - - -} // namespace portaudio - - -#endif // INCLUDED_PORTAUDIO_STREAM_HXX - diff --git a/fdmdv2/pa_cpp_binding/StreamParameters.hxx b/fdmdv2/pa_cpp_binding/StreamParameters.hxx deleted file mode 100644 index 2b6aa2ef..00000000 --- a/fdmdv2/pa_cpp_binding/StreamParameters.hxx +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX -#define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -#include "portaudiocpp/DirectionSpecificStreamParameters.hxx" - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - ////// - /// @brief The entire set of parameters needed to configure and open - /// a Stream. - /// - /// It contains parameters of input, output and shared parameters. - /// Using the isSupported() method, the StreamParameters can be - /// checked if opening a Stream using this StreamParameters would - /// succeed or not. Accessors are provided to higher-level parameters - /// aswell as the lower-level parameters which are mainly intended for - /// internal use. - ////// - class StreamParameters - { - public: - StreamParameters(); - StreamParameters(const DirectionSpecificStreamParameters &inputParameters, - const DirectionSpecificStreamParameters &outputParameters, double sampleRate, - unsigned long framesPerBuffer, PaStreamFlags flags); - - // Set up for direction-specific: - void setInputParameters(const DirectionSpecificStreamParameters ¶meters); - void setOutputParameters(const DirectionSpecificStreamParameters ¶meters); - - // Set up for common parameters: - void setSampleRate(double sampleRate); - void setFramesPerBuffer(unsigned long framesPerBuffer); - void setFlag(PaStreamFlags flag); - void unsetFlag(PaStreamFlags flag); - void clearFlags(); - - // Validation: - bool isSupported() const; - - // Accessors (direction-specific): - DirectionSpecificStreamParameters &inputParameters(); - const DirectionSpecificStreamParameters &inputParameters() const; - DirectionSpecificStreamParameters &outputParameters(); - const DirectionSpecificStreamParameters &outputParameters() const; - - // Accessors (common): - double sampleRate() const; - unsigned long framesPerBuffer() const; - PaStreamFlags flags() const; - bool isFlagSet(PaStreamFlags flag) const; - - private: - // Half-duplex specific parameters: - DirectionSpecificStreamParameters inputParameters_; - DirectionSpecificStreamParameters outputParameters_; - - // Common parameters: - double sampleRate_; - unsigned long framesPerBuffer_; - PaStreamFlags flags_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX diff --git a/fdmdv2/pa_cpp_binding/System.hxx b/fdmdv2/pa_cpp_binding/System.hxx deleted file mode 100644 index f5fb7132..00000000 --- a/fdmdv2/pa_cpp_binding/System.hxx +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX -#define INCLUDED_PORTAUDIO_SYSTEM_HXX - -// --------------------------------------------------------------------------------------- - -#include "portaudio.h" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; - class Stream; - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief System singleton which represents the PortAudio system. - /// - /// The System is used to initialize/terminate PortAudio and provide - /// a single acccess point to the PortAudio System (instance()). - /// It can be used to iterate through all HostApi 's in the System as - /// well as all devices in the System. It also provides some utility - /// functionality of PortAudio. - /// - /// Terminating the System will also abort and close the open streams. - /// The Stream objects will need to be deallocated by the client though - /// (it's usually a good idea to have them cleaned up automatically). - ////// - class System - { - public: - class HostApiIterator; // forward declaration - class DeviceIterator; // forward declaration - - // ------------------------------------------------------------------------------- - - static int version(); - static const char *versionText(); - - static void initialize(); - static void terminate(); - - static System &instance(); - static bool exists(); - - // ------------------------------------------------------------------------------- - - // host apis: - HostApiIterator hostApisBegin(); - HostApiIterator hostApisEnd(); - - HostApi &defaultHostApi(); - - HostApi &hostApiByTypeId(PaHostApiTypeId type); - HostApi &hostApiByIndex(PaHostApiIndex index); - - int hostApiCount(); - - // ------------------------------------------------------------------------------- - - // devices: - DeviceIterator devicesBegin(); - DeviceIterator devicesEnd(); - - Device &defaultInputDevice(); - Device &defaultOutputDevice(); - - Device &deviceByIndex(PaDeviceIndex index); - - int deviceCount(); - - static Device &nullDevice(); - - // ------------------------------------------------------------------------------- - - // misc: - void sleep(long msec); - int sizeOfSample(PaSampleFormat format); - - private: - System(); - ~System(); - - static System *instance_; - static int initCount_; - - static HostApi **hostApis_; - static Device **devices_; - - static Device *nullDevice_; - }; - - -} // namespace portaudio - - -#endif // INCLUDED_PORTAUDIO_SYSTEM_HXX - diff --git a/fdmdv2/pa_cpp_binding/SystemDeviceIterator.hxx b/fdmdv2/pa_cpp_binding/SystemDeviceIterator.hxx deleted file mode 100644 index 613fc3db..00000000 --- a/fdmdv2/pa_cpp_binding/SystemDeviceIterator.hxx +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX -#define INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX - -// --------------------------------------------------------------------------------------- - -#include -#include - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class Device; - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Iterator class for iterating through all Devices in a System. - /// - /// Devices will be iterated by iterating all Devices in each - /// HostApi in the System. Compliant with the STL bidirectional - /// iterator concept. - ////// - class System::DeviceIterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Device value_type; - typedef ptrdiff_t difference_type; - typedef Device * pointer; - typedef Device & reference; - - Device &operator*() const; - Device *operator->() const; - - DeviceIterator &operator++(); - DeviceIterator operator++(int); - DeviceIterator &operator--(); - DeviceIterator operator--(int); - - bool operator==(const DeviceIterator &rhs); - bool operator!=(const DeviceIterator &rhs); - - private: - friend class System; - friend class HostApi; - Device **ptr_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX - diff --git a/fdmdv2/pa_cpp_binding/SystemHostApiIterator.hxx b/fdmdv2/pa_cpp_binding/SystemHostApiIterator.hxx deleted file mode 100644 index b9b13b85..00000000 --- a/fdmdv2/pa_cpp_binding/SystemHostApiIterator.hxx +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX -#define INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX - -// --------------------------------------------------------------------------------------- - -#include -#include - -#include "portaudiocpp/System.hxx" - -// --------------------------------------------------------------------------------------- - -// Forward declaration(s): -namespace portaudio -{ - class HostApi; -} - -// --------------------------------------------------------------------------------------- - -// Declaration(s): -namespace portaudio -{ - - - ////// - /// @brief Iterator class for iterating through all HostApis in a System. - /// - /// Compliant with the STL bidirectional iterator concept. - ////// - class System::HostApiIterator - { - public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Device value_type; - typedef ptrdiff_t difference_type; - typedef HostApi * pointer; - typedef HostApi & reference; - - HostApi &operator*() const; - HostApi *operator->() const; - - HostApiIterator &operator++(); - HostApiIterator operator++(int); - HostApiIterator &operator--(); - HostApiIterator operator--(int); - - bool operator==(const HostApiIterator &rhs); - bool operator!=(const HostApiIterator &rhs); - - private: - friend class System; - HostApi **ptr_; - }; - - -} // namespace portaudio - -// --------------------------------------------------------------------------------------- - -#endif // INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX diff --git a/fdmdv2/pa_test/pa_test.project b/fdmdv2/pa_test/pa_test.project index 28ec3f44..86d39e3b 100644 --- a/fdmdv2/pa_test/pa_test.project +++ b/fdmdv2/pa_test/pa_test.project @@ -10,6 +10,9 @@ + + + @@ -23,6 +26,8 @@ + + @@ -62,7 +67,7 @@ - + @@ -99,7 +104,4 @@ - - - diff --git a/fdmdv2/thread_audio.cpp b/fdmdv2/thread_audio.cpp index 889bf732..72793fdc 100644 --- a/fdmdv2/thread_audio.cpp +++ b/fdmdv2/thread_audio.cpp @@ -14,12 +14,10 @@ wxDECLARE_EVENT(wxEVT_COMMAND_AUDIOTHREAD_COMPLETED, wxThreadEvent); wxDECLARE_EVENT(wxEVT_COMMAND_AUDIOTHREAD_UPDATE, wxThreadEvent); #include "stdio.h" -#include "portaudio.h" +#include "extern/include/portaudio.h" /* This will be called asynchronously by the PortAudio engine. */ -static int audioCallback( void *inputBuffer, void *outputBuffer, - -unsigned long framesPerBuffer, PaTimestamp outTime, void *userData ) +static int audioCallback( void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTime outTime, void *userData ) { float *out = (float *) outputBuffer; float *in = (float *) inputBuffer; @@ -40,10 +38,11 @@ unsigned long framesPerBuffer, PaTimestamp outTime, void *userData ) } return 0; } + /* Use a PortAudioStream to process audio data. */ int main(void) { - PortAudioStream *stream; + PortAudioWrap *stream; Pa_Initialize(); //Pa_OpenDefaultStream(&stream, 2, 2, /* stereo input and output */ paFloat32, 44100.0, 64, 0, /* 64 frames per buffer, let PA determine numBuffers */audioCallback, NULL ); Pa_OpenDefaultStream(&stream, 2, 2, paFloat32, 44100.0, 64, 0, audioCallback, NULL ); diff --git a/fdmdv2/thread_audio.h b/fdmdv2/thread_audio.h index 5c2e9a4e..fa2cc4f4 100644 --- a/fdmdv2/thread_audio.h +++ b/fdmdv2/thread_audio.h @@ -16,7 +16,7 @@ class AudioThread: public wxThread { public: - AudioThread(MainFrame *handler) : wxThread(wxTHREAD_DETACHED) { m_pHandler = handler } + AudioThread(MainFrame *handler) : wxThread(wxTHREAD_DETACHED){ m_pHandler = handler; } ~AudioThread(); protected: