Commit 2ad5ed65 authored by Jonas Stienen's avatar Jonas Stienen
Browse files
parents e734ab5a d2facd72
......@@ -100,6 +100,11 @@ vista_create_default_info_file( ITADataSources )
set_property( TARGET ITADataSources PROPERTY FOLDER "ITACoreLibs" )
# apps
set( ITADATASOURCES_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/apps/ita_whad" )
# tests
set( ITADATASOURCES_COMMON_BUILD TRUE )
add_subdirectory( "${CMAKE_CURRENT_SOURCE_DIR}/tests" )
cmake_minimum_required( VERSION 2.8 )
if( NOT ITADATASOURCES_COMMON_BUILD )
project( ita_whad )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
endif()
vista_use_package( ITADataSources REQUIRED FIND_DEPENDENCIES )
if( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
add_definitions( "-DITA_WHAD_WITH_ASIO" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_ASIO )
if( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
add_definitions( "-DITA_WHAD_WITH_PORTAUDIO" )
endif( ITA_DATA_SOURCE_WITH_INTEGRATED_PORTAUDIO )
add_definitions( -DITA_DATA_SOURCES_DLL )
add_executable( ita_whad main.cpp )
target_link_libraries( ita_whad ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( ita_whad )
vista_install( ita_whad )
vista_create_default_info_file( ita_whad )
set_property( TARGET ita_whad PROPERTY FOLDER "ITAApps/ITADataSources" )
//#include <conio.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <ITAAsioInterface.h>
using namespace std;
int main( int, char** )
{
cout << "ita_whad - ITA's which audio devices application" << endl;
cout << " ... lists all available audio devices and available properties." << endl << endl;
#ifdef ITA_WHAD_WITH_ASIO
cout << "ASIO support: yes" << endl;
#else
cout << "ASIO support: no" << endl;
#endif // ITA_WHAD_WITH_ASIO
#ifdef ITA_WHAD_WITH_PORTAUDIO
cout << "Portaudio support: yes" << endl;
#else
cout << "Portaudio support: no" << endl;
#endif // ITA_WHAD_WITH_PORTAUDIO
cout << endl;
#ifdef ITA_WHAD_WITH_ASIO
string sFileName = "ita_whad_asio.txt";
FILE* file = fopen( sFileName.c_str(), "w" );
ITAsioInitializeLibrary();
long lDrivers = ITAsioGetNumDrivers();
if( lDrivers == 0 )
cerr << "Warning: no ASIO drivers found." << endl;
for( long i = 0; i < lDrivers; i++ )
{
cout << "[" << i+1 << "] \"" << ITAsioGetDriverName(i) << "\"" << endl;
}
ITAsioFinalizeLibrary();
fclose( file );
#endif // ITA_WHAD_WITH_ASIO
return 0;
}
......@@ -40,7 +40,8 @@ class ITA_DATA_SOURCES_API ITAPortaudioInterface
{
public:
//! ITAPortaudio error code table
typedef enum ITA_PA_ERRORCODE {
typedef enum ITA_PA_ERRORCODE
{
//! Portaudio/ITAPortaudio no error
ITA_PA_NO_ERROR=0,
......@@ -160,19 +161,20 @@ public:
};
//! Portaudio available host APIs
typedef enum ITA_PA_HOST_APIS {
ITA_PA_DIRECT_SOUND=1, //!< Windows DirectSound
ITA_PA_MME=2, //!< Windows MME
ITA_PA_ASIO=3, //!< Windows Steinberg ASIO (recommended: use ITAsioInterface instead)
ITA_PA_SOUND_MANAGER=4, //!< Macintosh Sound Manager
ITA_PA_CORE_AUDIO=5, //!< MacOS CoreAudio
ITA_PA_OSS=7, //!< Linux/Unix OSS
ITA_PA_ALSA=8, //!< Linux/Unix ALSA
ITA_PA_AL=9, //!< Silicon Graphics Irix using AL
ITA_PA_BE_OS=10, //!< BeOS
ITA_PA_WDMKS=11, //!< Windows Driver Model Kernel Streaming driver
ITA_PA_JACK=12, //!< MacOS/Linux/Unix Jack Audio
ITA_PA_WASAPI=13, //!< Windows Audio Session API
typedef enum ITA_PA_HOST_APIS
{
ITA_PA_DIRECT_SOUND = 1, //!< Windows DirectSound
ITA_PA_MME = 2, //!< Windows MME
ITA_PA_ASIO = 3, //!< Windows Steinberg ASIO (recommended: use ITAsioInterface instead)
ITA_PA_SOUND_MANAGER = 4, //!< Macintosh Sound Manager
ITA_PA_CORE_AUDIO = 5, //!< MacOS CoreAudio
ITA_PA_OSS = 7, //!< Linux/Unix OSS
ITA_PA_ALSA = 8, //!< Linux/Unix ALSA
ITA_PA_AL = 9, //!< Silicon Graphics Irix using AL
ITA_PA_BE_OS = 10, //!< BeOS
ITA_PA_WDMKS = 11, //!< Windows Driver Model Kernel Streaming driver
ITA_PA_JACK = 12, //!< MacOS/Linux/Unix Jack Audio
ITA_PA_WASAPI = 13, //!< Windows Audio Session API
ITA_PA_AUDIO_SCIENCE_HPI=14 //!< AudioScience Hardware Programming Interface
};
......@@ -185,7 +187,7 @@ public:
*
* \see #Initialize #Initialize(const int iDriver)
*/
ITAPortaudioInterface(const double dSampleRate, const int iBufferSize);
ITAPortaudioInterface( double dSampleRate, int iBufferSize );
//! Destructor
~ITAPortaudioInterface();
......@@ -201,25 +203,25 @@ public:
ITA_PA_ERRORCODE Initialize();
//! Initialize Portaudio using specified host/driver by id
ITA_PA_ERRORCODE Initialize(const int iDriverID);
ITA_PA_ERRORCODE Initialize( int iDriverID);
//! Initialize Portaudio using specified driver by name
ITA_PA_ERRORCODE Initialize(const std::string& sDriverName);
ITA_PA_ERRORCODE Initialize( const std::string& sDriverName );
//! Use Portaudio with specific input device
ITA_PA_ERRORCODE SetOutputDevice(const int iOutputDevice);
ITA_PA_ERRORCODE SetOutputDevice( int iOutputDevice);
//! Returns true if playback is enabled, false otherwise
bool IsPlaybackEnabled() const;
//! Set playback enabled/disabled
void SetPlaybackEnabled(const bool bEnabled);
void SetPlaybackEnabled( bool bEnabled);
//! Returns true if record is enabled, false otherwise
bool IsRecordEnabled() const;
//! Set record enabled/disabled
void SetRecordEnabled(const bool bEnabled);
void SetRecordEnabled( bool bEnabled);
//! Finalize Portaudio
/**
......@@ -243,7 +245,7 @@ public:
int GetNumDevices() const;
//! Returns the name of the driver avaiable in Portaudio
std::string GetDeviceName(const int iDriverID) const;
std::string GetDeviceName( int iDriverID ) const;
static int GetPreferredBufferSize();
......@@ -252,9 +254,9 @@ public:
* \param iDriverID Identifier of driver
* \return Latency in seconds, -1 if any error with the driver occurs
*/
float GetDeviceLatency(const int iDriverID) const;
float GetDeviceLatency( int iDriverID ) const;
ITA_PA_ERRORCODE GetDriverSampleRate(const int iDeviceID, double& dSampleRate) const;
ITA_PA_ERRORCODE GetDriverSampleRate( int iDeviceID, double& dSampleRate ) const;
//! Returns the name of the current devices in Portaudio
std::string GetInputDeviceName() const;
......@@ -275,31 +277,31 @@ public:
int GetOutputDevice() const;
//! Returns the number of input and output channels
void GetNumChannels(const int iDeviceID, int& iNumInputChannels, int& iNumOutputChannels) const;
void GetNumChannels( const int iDeviceID, int& iNumInputChannels, int& iNumOutputChannels ) const;
//! Returns the number of input channels
/**
* \return Number of input channels (>=0) or #ITA_PA_ERRORCODE (<0)
*/
int GetNumInputChannels(const int iDeviceID) const;
int GetNumInputChannels( const int iDeviceID ) const;
//! Returns the number of output channels
/**
* \return Number of output channels (>=0) or #ITA_PA_ERRORCODE (<0)
*/
int GetNumOutputChannels(const int iDeviceID) const;
int GetNumOutputChannels( int iDeviceID ) const;
//! Returns the sample rate
double GetSampleRate() const;
//! Sets the sample rate
ITA_PA_ERRORCODE SetSampleRate(const double dSampleRate);
ITA_PA_ERRORCODE SetSampleRate( double dSampleRate );
//! Set the playback data source
/**
* \note Enables playback, see IsPlaybackEnabled() and SetPlaybackEnabled()
*/
ITA_PA_ERRORCODE SetPlaybackDatasource(ITADatasource* pidsDatasource);
ITA_PA_ERRORCODE SetPlaybackDatasource( ITADatasource* pidsDatasource );
//! Get the recording data source
/**
......@@ -312,21 +314,23 @@ public:
ITADatasource* GetRecordDatasource();
//! Uses the Portaudio sleep function
void Sleep(const float fSeconds) const;
void Sleep( float fSeconds ) const;
//! Returns a human readable error code string
static std::string GetErrorCodeString(const ITA_PA_ERRORCODE err);
static std::string GetErrorCodeString( ITA_PA_ERRORCODE err );
//! Internal user data class for information exchange with callback function
class ITAPortaudioUserData {
class ITAPortaudioUserData
{
public:
ITADatasource* pdsPlaybackDatasource; //!< ITADatasource playback datasource
ITADatasource* pdsRecordDatasource; //!< ITADatasource record datasource
bool bPlayback; //!< Playback enabled
bool bRecord; //!< Record enabled
ITAPortaudioUserData() {
inline ITAPortaudioUserData()
{
pdsPlaybackDatasource = NULL;
pdsRecordDatasource = NULL;
bPlayback = false;
......@@ -335,7 +339,7 @@ public:
};
private:
//! Standard constructor
//! Standard constructor deactivated
ITAPortaudioInterface();
std::string m_sConfigFile; //!< Configuration file path
......@@ -364,7 +368,6 @@ private:
ITA_PA_ERRORCODE m_iError; //!< Last ITAPortaudio error
};
#endif // INCLUDE_WATCHER_ITA_PORTAUDIO_INTERFACE
......@@ -9,17 +9,18 @@
#include <ITAStreamInfo.h>
// Portaudio Callback Function
static int PortaudioCallbackFunction(const void*, void*, unsigned long, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void*);
static int PortaudioCallbackFunction( const void*, void*, unsigned long, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void* );
class ITAPortaudioSource : public ITADatasourceRealization {
class ITAPortaudioSource : public ITADatasourceRealization
{
public:
ITAPortaudioSource(int iChannels, double dSamplerate, int iBufferSize)
: ITADatasourceRealization((unsigned int) iChannels, dSamplerate, (unsigned int) iBufferSize, 16) {}
ITAPortaudioSource( int iChannels, double dSampleRate, int iBufferSize )
: ITADatasourceRealization( ( unsigned int ) iChannels, dSampleRate, ( unsigned int ) iBufferSize, 16 ) {};
};
ITAPortaudioInterface::ITAPortaudioInterface(const double dSampleRate, const int iBufferSize) :
m_vpPaStream(NULL)
ITAPortaudioInterface::ITAPortaudioInterface( double dSampleRate, int iBufferSize )
: m_vpPaStream( NULL )
{
m_dSampleRate = dSampleRate;
m_iBufferSize = iBufferSize; // Darf 0 sein
......@@ -41,13 +42,17 @@ ITAPortaudioInterface::ITAPortaudioInterface(const double dSampleRate, const int
m_iError = ITA_PA_NO_ERROR;
}
ITAPortaudioInterface::~ITAPortaudioInterface() {
ITAPortaudioInterface::~ITAPortaudioInterface()
{
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize(const std::string& sDriverName) {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize( const std::string& sDriverName )
{
return ITA_PA_INVALID_DEVICE;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize(const int iDriverID) {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize( int iDriverID )
{
if (m_bInitialized)
return ITA_PA_IS_INITIALIZED;
......@@ -79,7 +84,8 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize(const
return ITA_PA_NO_ERROR;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize() {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize()
{
if (m_bInitialized)
return ITA_PA_IS_INITIALIZED;
......@@ -108,11 +114,13 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Initialize() {
return ITA_PA_NO_ERROR;
}
bool ITAPortaudioInterface::IsPlaybackEnabled() const {
bool ITAPortaudioInterface::IsPlaybackEnabled() const
{
return m_bPlayback;
}
void ITAPortaudioInterface::SetPlaybackEnabled(const bool bEnabled) {
void ITAPortaudioInterface::SetPlaybackEnabled( bool bEnabled )
{
m_bPlayback = bEnabled;
}
......@@ -120,11 +128,13 @@ bool ITAPortaudioInterface::IsRecordEnabled() const {
return m_bRecord;
}
void ITAPortaudioInterface::SetRecordEnabled(const bool bEnabled) {
void ITAPortaudioInterface::SetRecordEnabled( bool bEnabled )
{
m_bRecord = bEnabled;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Finalize() {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Finalize()
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -147,7 +157,8 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Finalize() {
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Open() {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Open()
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -201,17 +212,21 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Open() {
m_iError = (ITA_PA_ERRORCODE) Pa_OpenStream(&stream, pInParams, pOutParams, m_dSampleRate, m_iBufferSize, paNoFlag, PortaudioCallbackFunction, &m_oUserData);
if (m_iError == ITA_PA_NO_ERROR) {
if( m_iError == ITA_PA_NO_ERROR )
{
m_vpPaStream = (void*) stream;
m_bOpen = true;
} else {
}
else
{
m_vpPaStream = NULL;
}
return m_iError;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Close() {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Close()
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -229,7 +244,8 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Close() {
return m_iError;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Start() {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Start()
{
if (m_bStreaming)
return ITA_PA_IS_STARTED;
......@@ -253,7 +269,8 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Start() {
return m_iError;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Stop() {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::Stop()
{
if (!m_bStreaming)
return ITA_PA_STREAM_IS_STOPPED;
......@@ -277,7 +294,8 @@ int ITAPortaudioInterface::GetNumDevices() const {
}
int ITAPortaudioInterface::GetNumInputChannels(const int iDeviceID) const {
int ITAPortaudioInterface::GetNumInputChannels( int iDeviceID ) const
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -287,7 +305,8 @@ int ITAPortaudioInterface::GetNumInputChannels(const int iDeviceID) const {
return info->maxInputChannels;
}
int ITAPortaudioInterface::GetNumOutputChannels(const int iDeviceID) const {
int ITAPortaudioInterface::GetNumOutputChannels( int iDeviceID ) const
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -297,16 +316,19 @@ int ITAPortaudioInterface::GetNumOutputChannels(const int iDeviceID) const {
return info->maxOutputChannels;
}
double ITAPortaudioInterface::GetSampleRate() const {
double ITAPortaudioInterface::GetSampleRate() const
{
return m_dSampleRate;
}
void ITAPortaudioInterface::GetNumChannels(const int iDeviceID, int& iNumInputChannels, int& iNumOutputChannels) const {
void ITAPortaudioInterface::GetNumChannels( int iDeviceID, int& iNumInputChannels, int& iNumOutputChannels ) const
{
iNumInputChannels = GetNumInputChannels(iDeviceID);
iNumOutputChannels = GetNumOutputChannels(iDeviceID);
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::GetDriverSampleRate(const int iDeviceID, double& dSampleRate) const {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::GetDriverSampleRate( int iDeviceID, double& dSampleRate ) const
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -318,7 +340,8 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::GetDriverSampleRa
return ITA_PA_NO_ERROR;
}
std::string ITAPortaudioInterface::GetDeviceName(const int iDriverID) const {
std::string ITAPortaudioInterface::GetDeviceName( int iDriverID ) const
{
if (!m_bInitialized)
return "Portaudio not initialized";
......@@ -331,7 +354,8 @@ std::string ITAPortaudioInterface::GetDeviceName(const int iDriverID) const {
return info->name;
}
float ITAPortaudioInterface::GetDeviceLatency(const int iDriverID) const {
float ITAPortaudioInterface::GetDeviceLatency( int iDriverID ) const
{
if (!m_bInitialized)
return -1;
......@@ -344,7 +368,8 @@ float ITAPortaudioInterface::GetDeviceLatency(const int iDriverID) const {
return (float) info->defaultLowOutputLatency;
}
int ITAPortaudioInterface::GetDefaultInputDevice() const {
int ITAPortaudioInterface::GetDefaultInputDevice() const
{
int iDefaultInputDevice;
if (!m_bInitialized) {
Pa_Initialize();
......@@ -357,7 +382,8 @@ int ITAPortaudioInterface::GetDefaultInputDevice() const {
return iDefaultInputDevice;
}
int ITAPortaudioInterface::GetDefaultOutputDevice() const {
int ITAPortaudioInterface::GetDefaultOutputDevice() const
{
int iDefaultOutputDevice;
if (!m_bInitialized) {
Pa_Initialize();
......@@ -370,7 +396,8 @@ int ITAPortaudioInterface::GetDefaultOutputDevice() const {
return iDefaultOutputDevice;
}
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::SetPlaybackDatasource(ITADatasource* pidsDatasource) {
ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::SetPlaybackDatasource( ITADatasource* pidsDatasource )
{
if (!m_bInitialized)
return ITA_PA_NOT_INITIALIZED;
......@@ -390,7 +417,8 @@ ITAPortaudioInterface::ITA_PA_ERRORCODE ITAPortaudioInterface::SetPlaybackDataso
return ITA_PA_NO_ERROR;
}
ITADatasource* ITAPortaudioInterface::GetRecordDatasource() {
ITADatasource* ITAPortaudioInterface::GetRecordDatasource()
{
if (!m_bInitialized)
return NULL;
......@@ -405,13 +433,15 @@ ITADatasource* ITAPortaudioInterface::GetRecordDatasource() {
return m_oUserData.pdsRecordDatasource;
}
void ITAPortaudioInterface::Sleep(const float fSeconds) const {
void ITAPortaudioInterface::Sleep( float fSeconds ) const
{
Pa_Sleep((long) fSeconds*1000);
return;
}
std::string ITAPortaudioInterface::GetErrorCodeString(const ITA_PA_ERRORCODE err) {
std::string ITAPortaudioInterface::GetErrorCodeString( ITA_PA_ERRORCODE err )
{
if (err == ITA_PA_NOT_INITIALIZED)
return "Portaudio not initialized";
if (err == ITA_PA_INVALID_CHANNEL_COUNT)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment