diff --git a/windows/llcon.dsp b/windows/llcon.dsp index 8ae84a66..4ba0c6d0 100755 --- a/windows/llcon.dsp +++ b/windows/llcon.dsp @@ -70,7 +70,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # 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 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 # ADD BASE 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 # End Source File # 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 SOURCE=..\src\audiocompr.cpp diff --git a/windows/sound.cpp b/windows/sound.cpp index ec3d0f17..4e57d61f 100755 --- a/windows/sound.cpp +++ b/windows/sound.cpp @@ -31,6 +31,11 @@ /* Implementation *************************************************************/ #ifdef USE_ASIO_SND_INTERFACE +// external references +extern AsioDrivers* asioDrivers; +bool loadAsioDriver ( char *name ); + + /******************************************************************************\ * Wave in * \******************************************************************************/ @@ -639,21 +644,59 @@ CSound::CSound() sWaveFormatEx.cbSize = 0; */ -/* - // get the number of digital audio devices in this computer, check range - iNumDevs = waveInGetNumDevs(); -*/ - if ( iNumDevs > MAX_NUMBER_SOUND_CARDS ) - { - 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++ ) + { + cDriverNames[i] = new char[32]; + } + + loadAsioDriver ( "dummy" ); // to initialize external object + 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 ) + { + 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(); + - // at least one device must exist in the system - if ( iNumDevs == 0 ) - { - throw CGenErr ( "No audio device found." ); - } /* // get info about the devices and store the names diff --git a/windows/sound.h b/windows/sound.h index a52c88f1..82245114 100755 --- a/windows/sound.h +++ b/windows/sound.h @@ -35,8 +35,8 @@ /* Definitions ****************************************************************/ // switch here between ASIO (Steinberg) or native Windows(TM) sound interface -//#define 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 @@ -64,6 +64,7 @@ #include "asio.h" #include "asiodrivers.h" + class CSound { public: @@ -97,12 +98,14 @@ protected: void AddOutBuffer ( int iBufNum ); void GetDoneBuffer ( int& iCntPrepBuf, int& iIndexDoneBuf ); + // ASIO stuff + ASIODriverInfo driverInfo; - UINT iNumDevs; + int iNumDevs; std::string pstrDevices[MAX_NUMBER_SOUND_CARDS]; - UINT iCurInDev; - UINT iCurOutDev; + int iCurInDev; + int iCurOutDev; bool bChangParamIn; bool bChangParamOut; int iCurNumSndBufIn;