2006-12-18 15:39:33 +01:00
|
|
|
/******************************************************************************\
|
2011-02-22 19:56:52 +01:00
|
|
|
* Copyright (c) 2004-2011
|
2006-12-18 15:39:33 +01:00
|
|
|
*
|
|
|
|
* Author(s):
|
|
|
|
* Volker Fischer
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License as published by the Free Software
|
|
|
|
* Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
* version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2009-05-01 12:28:52 +02:00
|
|
|
#if !defined ( _SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_ )
|
|
|
|
#define _SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
#include <windows.h>
|
2009-03-01 12:17:35 +01:00
|
|
|
#include <qmutex.h>
|
2008-11-01 12:48:17 +01:00
|
|
|
#include <qmessagebox.h>
|
2006-12-18 15:39:33 +01:00
|
|
|
#include "../src/util.h"
|
|
|
|
#include "../src/global.h"
|
2009-02-23 00:13:59 +01:00
|
|
|
#include "../src/soundbase.h"
|
2006-12-18 15:39:33 +01:00
|
|
|
|
2009-02-21 18:48:58 +01:00
|
|
|
// copy the ASIO SDK in the llcon/windows directory: "llcon/windows/ASIOSDK2" to
|
|
|
|
// get it work
|
|
|
|
#include "asiosys.h"
|
|
|
|
#include "asio.h"
|
|
|
|
#include "asiodrivers.h"
|
2007-12-17 22:28:40 +01:00
|
|
|
|
|
|
|
|
2009-02-21 18:48:58 +01:00
|
|
|
/* Definitions ****************************************************************/
|
2010-03-19 21:23:31 +01:00
|
|
|
// stereo for input and output
|
|
|
|
#define NUM_IN_OUT_CHANNELS 2
|
2006-12-18 15:39:33 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
2009-02-23 00:13:59 +01:00
|
|
|
class CSound : public CSoundBase
|
2007-12-17 22:28:40 +01:00
|
|
|
{
|
|
|
|
public:
|
2009-07-24 16:31:25 +02:00
|
|
|
CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ), void* arg );
|
2007-12-17 22:28:40 +01:00
|
|
|
virtual ~CSound();
|
|
|
|
|
2009-03-01 23:08:06 +01:00
|
|
|
virtual int Init ( const int iNewPrefMonoBufferSize );
|
2009-03-05 21:07:41 +01:00
|
|
|
virtual void Start();
|
|
|
|
virtual void Stop();
|
2007-12-17 22:28:40 +01:00
|
|
|
|
2009-03-05 10:30:58 +01:00
|
|
|
virtual void OpenDriverSetup() { ASIOControlPanel(); }
|
|
|
|
|
2010-03-20 09:55:42 +01:00
|
|
|
// device selection
|
2010-03-20 13:11:11 +01:00
|
|
|
virtual int GetNumDev() { return lNumDevs; }
|
|
|
|
virtual QString GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; }
|
|
|
|
virtual QString SetDev ( const int iNewDev );
|
|
|
|
virtual int GetDev() { return lCurDev; }
|
2007-12-17 22:28:40 +01:00
|
|
|
|
2010-03-20 09:55:42 +01:00
|
|
|
// channel selection
|
2010-03-20 13:57:16 +01:00
|
|
|
virtual int GetNumInputChannels() { return static_cast<int> ( lNumInChan ); }
|
|
|
|
virtual QString GetInputChannelName ( const int iDiD ) { return channelInfosInput[iDiD].name; }
|
|
|
|
virtual void SetLeftInputChannel ( const int iNewChan );
|
|
|
|
virtual void SetRightInputChannel ( const int iNewChan );
|
|
|
|
virtual int GetLeftInputChannel() { return vSelectedInputChannels[0]; }
|
|
|
|
virtual int GetRightInputChannel() { return vSelectedInputChannels[1]; }
|
2010-03-20 09:55:42 +01:00
|
|
|
|
2010-03-20 13:57:16 +01:00
|
|
|
virtual int GetNumOutputChannels() { return static_cast<int> ( lNumOutChan ); }
|
|
|
|
virtual QString GetOutputChannelName ( const int iDiD ) { return channelInfosOutput[iDiD].name; }
|
|
|
|
virtual void SetLeftOutputChannel ( const int iNewChan );
|
|
|
|
virtual void SetRightOutputChannel ( const int iNewChan );
|
|
|
|
virtual int GetLeftOutputChannel() { return vSelectedOutputChannels[0]; }
|
|
|
|
virtual int GetRightOutputChannel() { return vSelectedOutputChannels[1]; }
|
2010-03-20 09:55:42 +01:00
|
|
|
|
2007-12-17 22:28:40 +01:00
|
|
|
protected:
|
2009-12-01 21:08:21 +01:00
|
|
|
QVector<QString> LoadAndInitializeFirstValidDriver();
|
|
|
|
QString LoadAndInitializeDriver ( int iIdx );
|
|
|
|
int GetActualBufferSize ( const int iDesiredBufferSizeMono );
|
|
|
|
QString CheckDeviceCapabilities();
|
2010-03-19 21:23:31 +01:00
|
|
|
bool CheckSampleTypeSupported ( const ASIOSampleType SamType );
|
2010-03-20 09:55:42 +01:00
|
|
|
void ResetChannelMapping();
|
2010-03-19 21:23:31 +01:00
|
|
|
|
|
|
|
int iASIOBufferSizeMono;
|
|
|
|
int iASIOBufferSizeStereo;
|
|
|
|
|
2010-03-20 09:55:42 +01:00
|
|
|
long lNumInChan;
|
|
|
|
long lNumOutChan;
|
2010-03-19 21:23:31 +01:00
|
|
|
CVector<int> vSelectedInputChannels;
|
|
|
|
CVector<int> vSelectedOutputChannels;
|
|
|
|
|
|
|
|
CVector<int16_t> vecsTmpAudioSndCrdStereo;
|
|
|
|
|
|
|
|
QMutex ASIOMutex;
|
2007-12-17 22:28:40 +01:00
|
|
|
|
2010-02-03 20:27:48 +01:00
|
|
|
// utility functions
|
|
|
|
static int16_t Flip16Bits ( const int16_t iIn );
|
|
|
|
static int32_t Flip32Bits ( const int32_t iIn );
|
|
|
|
static int64_t Flip64Bits ( const int64_t iIn );
|
|
|
|
|
2008-04-13 18:43:21 +02:00
|
|
|
// audio hardware buffer info
|
|
|
|
struct sHWBufferInfo
|
|
|
|
{
|
2009-02-22 12:07:18 +01:00
|
|
|
long lMinSize;
|
|
|
|
long lMaxSize;
|
|
|
|
long lPreferredSize;
|
|
|
|
long lGranularity;
|
2008-04-13 18:43:21 +02:00
|
|
|
} HWBufferInfo;
|
|
|
|
|
2010-03-19 21:23:31 +01:00
|
|
|
// ASIO stuff
|
|
|
|
ASIODriverInfo driverInfo;
|
|
|
|
ASIOBufferInfo bufferInfos[2 * NUM_IN_OUT_CHANNELS]; // for input and output buffers -> "2 *"
|
|
|
|
ASIOChannelInfo channelInfosInput[MAX_NUM_IN_OUT_CHANNELS];
|
|
|
|
ASIOChannelInfo channelInfosOutput[MAX_NUM_IN_OUT_CHANNELS];
|
|
|
|
bool bASIOPostOutput;
|
|
|
|
ASIOCallbacks asioCallbacks;
|
|
|
|
|
2007-12-19 21:16:50 +01:00
|
|
|
// callbacks
|
2008-03-16 14:10:46 +01:00
|
|
|
static void bufferSwitch ( long index, ASIOBool processNow );
|
2009-07-24 16:31:25 +02:00
|
|
|
static ASIOTime* bufferSwitchTimeInfo ( ASIOTime* timeInfo, long index, ASIOBool processNow );
|
2008-03-16 14:10:46 +01:00
|
|
|
static void sampleRateChanged ( ASIOSampleRate sRate ) {}
|
|
|
|
static long asioMessages ( long selector, long value, void* message, double* opt );
|
2007-12-17 22:28:40 +01:00
|
|
|
|
2008-10-31 00:23:26 +01:00
|
|
|
long lNumDevs;
|
|
|
|
long lCurDev;
|
|
|
|
char* cDriverNames[MAX_NUMBER_SOUND_CARDS];
|
2007-12-17 22:28:40 +01:00
|
|
|
};
|
|
|
|
|
2009-05-01 12:28:52 +02:00
|
|
|
#endif // !defined ( _SOUNDIN_H__9518A621_7F78_11D3_8C0D_EEBF182CF549__INCLUDED_ )
|