some more ASIO work

This commit is contained in:
Volker Fischer 2007-12-18 20:52:48 +00:00
parent a9eea99f5a
commit 4889a1d378
3 changed files with 80 additions and 18 deletions

View file

@ -70,7 +70,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0 # PROP Ignore_Export_Lib 0
# PROP Target_Dir "" # PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "$(QTDIR)\include" /I "../src" /I "ASIOSDK2/common" /I "ASIOSDK2/host" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "$(QTDIR)\include" /I "../src" /I "ASIOSDK2/common" /I "ASIOSDK2/host" /I "ASIOSDK2/host/pc" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "QT_DLL" /D "QT_THREAD_SUPPORT" /FD /GZ /c
# SUBTRACT CPP /YX /Yc /Yu # SUBTRACT CPP /YX /Yc /Yu
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -172,6 +172,22 @@ SOURCE=.\moc\moc_socket.cpp
SOURCE=.\moc\moc_util.cpp SOURCE=.\moc\moc_util.cpp
# End Source File # End Source File
# End Group # End Group
# Begin Group "ASIO"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\ASIOSDK2\common\asio.cpp
# End Source File
# Begin Source File
SOURCE=.\ASIOSDK2\host\asiodrivers.cpp
# End Source File
# Begin Source File
SOURCE=.\ASIOSDK2\host\pc\asiolist.cpp
# End Source File
# End Group
# Begin Source File # Begin Source File
SOURCE=..\src\audiocompr.cpp SOURCE=..\src\audiocompr.cpp

View file

@ -31,6 +31,11 @@
/* Implementation *************************************************************/ /* Implementation *************************************************************/
#ifdef USE_ASIO_SND_INTERFACE #ifdef USE_ASIO_SND_INTERFACE
// external references
extern AsioDrivers* asioDrivers;
bool loadAsioDriver ( char *name );
/******************************************************************************\ /******************************************************************************\
* Wave in * * Wave in *
\******************************************************************************/ \******************************************************************************/
@ -639,21 +644,59 @@ CSound::CSound()
sWaveFormatEx.cbSize = 0; sWaveFormatEx.cbSize = 0;
*/ */
/*
// get the number of digital audio devices in this computer, check range
iNumDevs = waveInGetNumDevs();
*/
if ( iNumDevs > MAX_NUMBER_SOUND_CARDS ) // get available ASIO driver names in system
char* cDriverNames[MAX_NUMBER_SOUND_CARDS];
for ( i = 0; i < MAX_NUMBER_SOUND_CARDS; i++ )
{ {
iNumDevs = MAX_NUMBER_SOUND_CARDS; cDriverNames[i] = new char[32];
} }
// at least one device must exist in the system loadAsioDriver ( "dummy" ); // to initialize external object
if ( iNumDevs == 0 ) const long lNumDetDriv = asioDrivers->getDriverNames ( cDriverNames, MAX_NUMBER_SOUND_CARDS );
// load and initialize first valid ASIO driver
bool bValidDriverDetected = false;
int iCurDriverIdx = 0;
while ( !bValidDriverDetected && iCurDriverIdx < lNumDetDriv )
{ {
throw CGenErr ( "No audio device found." ); if ( loadAsioDriver ( cDriverNames[iCurDriverIdx] ) )
{
if ( ASIOInit ( &driverInfo ) == ASE_OK )
{
bValidDriverDetected = true;
} }
else
{
// driver could not be loaded, free memory
asioDrivers->removeCurrentDriver();
}
}
// try next driver
iCurDriverIdx++;
}
// in case we do not have a driver available, throw error
if ( !bValidDriverDetected )
{
throw CGenErr ( "No suitable ASIO audio device found." );
}
// TEST we only use one driver for a first try
iNumDevs = 1;
pstrDevices[0] = driverInfo.name;
// TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ASIOExit();
/* /*
// get info about the devices and store the names // get info about the devices and store the names

View file

@ -35,8 +35,8 @@
/* Definitions ****************************************************************/ /* Definitions ****************************************************************/
// switch here between ASIO (Steinberg) or native Windows(TM) sound interface // switch here between ASIO (Steinberg) or native Windows(TM) sound interface
//#define USE_ASIO_SND_INTERFACE
#undef USE_ASIO_SND_INTERFACE #undef USE_ASIO_SND_INTERFACE
//#define USE_ASIO_SND_INTERFACE
#define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only #define NUM_IN_OUT_CHANNELS 2 /* Stereo recording (but we only
@ -64,6 +64,7 @@
#include "asio.h" #include "asio.h"
#include "asiodrivers.h" #include "asiodrivers.h"
class CSound class CSound
{ {
public: public:
@ -97,12 +98,14 @@ protected:
void AddOutBuffer ( int iBufNum ); void AddOutBuffer ( int iBufNum );
void GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf ); void GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf );
// ASIO stuff
ASIODriverInfo driverInfo;
UINT iNumDevs; int iNumDevs;
std::string pstrDevices[MAX_NUMBER_SOUND_CARDS]; std::string pstrDevices[MAX_NUMBER_SOUND_CARDS];
UINT iCurInDev; int iCurInDev;
UINT iCurOutDev; int iCurOutDev;
bool bChangParamIn; bool bChangParamIn;
bool bChangParamOut; bool bChangParamOut;
int iCurNumSndBufIn; int iCurNumSndBufIn;