2011-04-23 17:57:54 +02:00
|
|
|
/******************************************************************************\
|
2020-01-01 15:41:43 +01:00
|
|
|
* Copyright (c) 2004-2020
|
2011-04-23 17:57:54 +02: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.,
|
2020-06-08 22:58:11 +02:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2011-04-23 17:57:54 +02:00
|
|
|
*
|
|
|
|
\******************************************************************************/
|
|
|
|
|
2019-07-09 08:52:38 +02:00
|
|
|
#pragma once
|
2011-04-23 17:57:54 +02:00
|
|
|
|
2013-01-02 21:41:04 +01:00
|
|
|
#include <QMutex>
|
2013-01-02 22:05:09 +01:00
|
|
|
#include <QMessageBox>
|
2011-04-23 17:57:54 +02:00
|
|
|
#include "../src/util.h"
|
|
|
|
#include "../src/global.h"
|
|
|
|
#include "../src/soundbase.h"
|
|
|
|
|
|
|
|
// 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"
|
|
|
|
|
|
|
|
|
|
|
|
/* Definitions ****************************************************************/
|
|
|
|
// stereo for input and output
|
|
|
|
#define NUM_IN_OUT_CHANNELS 2
|
|
|
|
|
|
|
|
|
|
|
|
/* Classes ********************************************************************/
|
|
|
|
class CSound : public CSoundBase
|
|
|
|
{
|
|
|
|
public:
|
2020-04-30 22:03:01 +02:00
|
|
|
CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
|
|
|
|
void* arg,
|
|
|
|
const int iCtrlMIDIChannel,
|
2020-04-30 22:18:11 +02:00
|
|
|
const bool ,
|
|
|
|
const QString& );
|
2020-04-30 20:48:48 +02:00
|
|
|
|
2011-10-18 22:04:56 +02:00
|
|
|
virtual ~CSound() { UnloadCurrentDriver(); }
|
2011-04-23 17:57:54 +02:00
|
|
|
|
|
|
|
virtual int Init ( const int iNewPrefMonoBufferSize );
|
|
|
|
virtual void Start();
|
|
|
|
virtual void Stop();
|
|
|
|
|
|
|
|
virtual void OpenDriverSetup() { ASIOControlPanel(); }
|
|
|
|
|
|
|
|
// channel selection
|
2018-03-26 17:57:16 +02:00
|
|
|
virtual int GetNumInputChannels() { return static_cast<int> ( lNumInChanPlusAddChan ); }
|
|
|
|
virtual QString GetInputChannelName ( const int iDiD ) { return channelInputName[iDiD]; }
|
2011-04-23 17:57:54 +02:00
|
|
|
virtual void SetLeftInputChannel ( const int iNewChan );
|
|
|
|
virtual void SetRightInputChannel ( const int iNewChan );
|
|
|
|
virtual int GetLeftInputChannel() { return vSelectedInputChannels[0]; }
|
|
|
|
virtual int GetRightInputChannel() { return vSelectedInputChannels[1]; }
|
|
|
|
|
|
|
|
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]; }
|
|
|
|
|
2013-12-17 21:52:38 +01:00
|
|
|
virtual double GetInOutLatencyMs() { return dInOutLatencyMs; }
|
|
|
|
|
2011-04-23 17:57:54 +02:00
|
|
|
protected:
|
2020-04-20 19:57:21 +02:00
|
|
|
virtual QString LoadAndInitializeDriver ( int iIdx,
|
|
|
|
bool bOpenDriverSetup );
|
2011-10-18 22:04:56 +02:00
|
|
|
virtual void UnloadCurrentDriver();
|
2011-04-23 17:57:54 +02:00
|
|
|
int GetActualBufferSize ( const int iDesiredBufferSizeMono );
|
|
|
|
QString CheckDeviceCapabilities();
|
|
|
|
bool CheckSampleTypeSupported ( const ASIOSampleType SamType );
|
2018-03-26 17:57:16 +02:00
|
|
|
bool CheckSampleTypeSupportedForCHMixing ( const ASIOSampleType SamType );
|
2011-04-23 17:57:54 +02:00
|
|
|
void ResetChannelMapping();
|
|
|
|
|
|
|
|
int iASIOBufferSizeMono;
|
|
|
|
int iASIOBufferSizeStereo;
|
|
|
|
|
|
|
|
long lNumInChan;
|
2018-03-26 17:57:16 +02:00
|
|
|
long lNumInChanPlusAddChan; // includes additional "added" channels
|
2011-04-23 17:57:54 +02:00
|
|
|
long lNumOutChan;
|
2013-12-17 21:52:38 +01:00
|
|
|
double dInOutLatencyMs;
|
2011-04-23 17:57:54 +02:00
|
|
|
CVector<int> vSelectedInputChannels;
|
|
|
|
CVector<int> vSelectedOutputChannels;
|
|
|
|
|
2020-04-23 20:54:58 +02:00
|
|
|
CVector<int16_t> vecsMultChanAudioSndCrd;
|
2011-04-23 17:57:54 +02:00
|
|
|
|
|
|
|
QMutex ASIOMutex;
|
|
|
|
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
// audio hardware buffer info
|
|
|
|
struct sHWBufferInfo
|
|
|
|
{
|
|
|
|
long lMinSize;
|
|
|
|
long lMaxSize;
|
|
|
|
long lPreferredSize;
|
|
|
|
long lGranularity;
|
|
|
|
} HWBufferInfo;
|
|
|
|
|
|
|
|
// ASIO stuff
|
|
|
|
ASIODriverInfo driverInfo;
|
2018-03-25 13:22:30 +02:00
|
|
|
ASIOBufferInfo bufferInfos[2 * MAX_NUM_IN_OUT_CHANNELS]; // for input and output buffers -> "2 *"
|
2011-04-23 17:57:54 +02:00
|
|
|
ASIOChannelInfo channelInfosInput[MAX_NUM_IN_OUT_CHANNELS];
|
2018-03-26 17:57:16 +02:00
|
|
|
QString channelInputName[MAX_NUM_IN_OUT_CHANNELS];
|
2011-04-23 17:57:54 +02:00
|
|
|
ASIOChannelInfo channelInfosOutput[MAX_NUM_IN_OUT_CHANNELS];
|
|
|
|
bool bASIOPostOutput;
|
|
|
|
ASIOCallbacks asioCallbacks;
|
|
|
|
|
|
|
|
// callbacks
|
|
|
|
static void bufferSwitch ( long index, ASIOBool processNow );
|
|
|
|
static ASIOTime* bufferSwitchTimeInfo ( ASIOTime* timeInfo, long index, ASIOBool processNow );
|
|
|
|
static void sampleRateChanged ( ASIOSampleRate ) {}
|
|
|
|
static long asioMessages ( long selector, long value, void* message, double* opt );
|
|
|
|
|
2011-10-12 21:06:39 +02:00
|
|
|
char* cDriverNames[MAX_NUMBER_SOUND_CARDS];
|
2011-04-23 17:57:54 +02:00
|
|
|
};
|