preparation work for local audio selection in client instead of sound interface

This commit is contained in:
Volker Fischer 2020-04-23 20:54:58 +02:00
parent 009f30b4df
commit f7ef88178f
5 changed files with 79 additions and 58 deletions

View file

@ -835,6 +835,7 @@ void CClient::Init()
vecCeltData.Init ( iCeltNumCodedBytes ); vecCeltData.Init ( iCeltNumCodedBytes );
vecZeros.Init ( iStereoBlockSizeSam, 0 ); vecZeros.Init ( iStereoBlockSizeSam, 0 );
vecsStereoSndCrdTMP.Init ( iStereoBlockSizeSam ); vecsStereoSndCrdTMP.Init ( iStereoBlockSizeSam );
vecsStereoSndCrdMuteStream.Init ( iStereoBlockSizeSam );
opus_custom_encoder_ctl ( CurOpusEncoder, opus_custom_encoder_ctl ( CurOpusEncoder,
OPUS_SET_BITRATE ( OPUS_SET_BITRATE (
@ -883,22 +884,38 @@ void CClient::AudioCallback ( CVector<int16_t>& psData, void* arg )
// process audio data // process audio data
pMyClientObj->ProcessSndCrdAudioData ( psData ); pMyClientObj->ProcessSndCrdAudioData ( psData );
}
void CClient::ProcessSndCrdAudioData ( CVector<int16_t>& vecsStereoSndCrd )
{
/* /*
// TEST do a soundcard jitter measurement // TEST do a soundcard jitter measurement
static CTimingMeas JitterMeas ( 1000, "test2.dat" ); static CTimingMeas JitterMeas ( 1000, "test2.dat" );
JitterMeas.Measure(); JitterMeas.Measure();
*/ */
}
void CClient::ProcessSndCrdAudioData ( CVector<int16_t>& vecsMultChanAudioSndCrd )
{
// TODO output mapping from stereo to multi channel: We want to change all the different sound interfaces that they
// do not select the input and output channels but we do it here at the client. This has the advantage that, e.g.,
// the special add modes supported for Windows (i.e. if 4 input channels available, you can mix channel 1+3 or 1+4)
// can then be used for Mac as well without the need of changing anything in the actual Mac sound interface.
// Since a multichannel signal arrives and must be converted to a stereo signal, we need an additional buffer: vecsStereoSndCrdTMP.
// TEST input channel selection/mixing
//const int iNumInCh = 2;
//for ( int i = 0; i < iNumInCh; i++ )
//{
// for ( int j = 0; j < iMonoBlockSizeSam; j++ )
// {
// vecsStereoSndCrdTMP[2 * j + i] = vecsMultChanAudioSndCrd[iNumInCh * j + i];
// }
//}
vecsStereoSndCrdTMP = vecsMultChanAudioSndCrd; // TEST just copy the stereo data for now
// check if a conversion buffer is required or not // check if a conversion buffer is required or not
if ( bSndCrdConversionBufferRequired ) if ( bSndCrdConversionBufferRequired )
{ {
// add new sound card block in conversion buffer // add new sound card block in conversion buffer
SndCrdConversionBufferIn.Put ( vecsStereoSndCrd, vecsStereoSndCrd.Size() ); SndCrdConversionBufferIn.Put ( vecsStereoSndCrdTMP, vecsStereoSndCrdTMP.Size() );
// process all available blocks of data // process all available blocks of data
while ( SndCrdConversionBufferIn.GetAvailData() >= iStereoBlockSizeSam ) while ( SndCrdConversionBufferIn.GetAvailData() >= iStereoBlockSizeSam )
@ -913,14 +930,17 @@ JitterMeas.Measure();
} }
// get processed sound card block out of the conversion buffer // get processed sound card block out of the conversion buffer
SndCrdConversionBufferOut.Get ( vecsStereoSndCrd, vecsStereoSndCrd.Size() ); SndCrdConversionBufferOut.Get ( vecsStereoSndCrdTMP, vecsStereoSndCrdTMP.Size() );
} }
else else
{ {
// regular case: no conversion buffer required // regular case: no conversion buffer required
// process audio data // process audio data
ProcessAudioDataIntern ( vecsStereoSndCrd ); ProcessAudioDataIntern ( vecsStereoSndCrdTMP );
} }
// TODO output mapping from stereo to multi channel, see comment above for the input mapping
vecsMultChanAudioSndCrd = vecsStereoSndCrdTMP; // TEST just copy the stereo data for now
} }
void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd ) void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
@ -1101,7 +1121,7 @@ void CClient::ProcessAudioDataIntern ( CVector<int16_t>& vecsStereoSndCrd )
// in case of mute stream, store local data // in case of mute stream, store local data
if ( bMuteOutStream ) if ( bMuteOutStream )
{ {
vecsStereoSndCrdTMP = vecsStereoSndCrd; vecsStereoSndCrdMuteStream = vecsStereoSndCrd;
} }
for ( i = 0; i < iSndCrdFrameSizeFactor; i++ ) for ( i = 0; i < iSndCrdFrameSizeFactor; i++ )
@ -1158,7 +1178,7 @@ fflush(pFileDelay);
for ( i = 0; i < iStereoBlockSizeSam; i++ ) for ( i = 0; i < iStereoBlockSizeSam; i++ )
{ {
vecsStereoSndCrd[i] = Double2Short ( vecsStereoSndCrd[i] = Double2Short (
static_cast<double> ( vecsStereoSndCrd[i] ) + vecsStereoSndCrdTMP[i] ); static_cast<double> ( vecsStereoSndCrd[i] ) + vecsStereoSndCrdMuteStream[i] );
} }
} }

View file

@ -304,7 +304,7 @@ protected:
static void AudioCallback ( CVector<short>& psData, void* arg ); static void AudioCallback ( CVector<short>& psData, void* arg );
void Init(); void Init();
void ProcessSndCrdAudioData ( CVector<short>& vecsStereoSndCrd ); void ProcessSndCrdAudioData ( CVector<short>& vecsMultChanAudioSndCrd );
void ProcessAudioDataIntern ( CVector<short>& vecsStereoSndCrd ); void ProcessAudioDataIntern ( CVector<short>& vecsStereoSndCrd );
int PreparePingMessage(); int PreparePingMessage();
@ -359,6 +359,7 @@ protected:
CBufferBase<int16_t> SndCrdConversionBufferOut; CBufferBase<int16_t> SndCrdConversionBufferOut;
CVector<int16_t> vecDataConvBuf; CVector<int16_t> vecDataConvBuf;
CVector<int16_t> vecsStereoSndCrdTMP; CVector<int16_t> vecsStereoSndCrdTMP;
CVector<int16_t> vecsStereoSndCrdMuteStream;
CVector<int16_t> vecZeros; CVector<int16_t> vecZeros;
bool bFraSiFactPrefSupported; bool bFraSiFactPrefSupported;

View file

@ -69,7 +69,7 @@ double CStereoSignalLevelMeter::UpdateCurLevel ( double dCurLevel,
// TODO Calculate factor from sample rate and frame size (64 or 128 samples frame size). // TODO Calculate factor from sample rate and frame size (64 or 128 samples frame size).
// But tests with 128 and 64 samples frame size have shown that the meter fly back // But tests with 128 and 64 samples frame size have shown that the meter fly back
// is ok for both numbers of samples frame size. // is ok for both numbers of samples frame size.
dCurLevel *= 0.95; dCurLevel *= 0.97;
} }
else else
{ {

View file

@ -404,7 +404,7 @@ int CSound::Init ( const int iNewPrefMonoBufferSize )
ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE_HZ ); ASIOSetSampleRate ( SYSTEM_SAMPLE_RATE_HZ );
// create memory for intermediate audio buffer // create memory for intermediate audio buffer
vecsTmpAudioSndCrdStereo.Init ( iASIOBufferSizeStereo ); vecsMultChanAudioSndCrd.Init ( iASIOBufferSizeStereo );
// create and activate ASIO buffers (buffer size in samples), // create and activate ASIO buffers (buffer size in samples),
// dispose old buffers (if any) // dispose old buffers (if any)
@ -601,7 +601,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// get references to class members // get references to class members
int& iASIOBufferSizeMono = pSound->iASIOBufferSizeMono; int& iASIOBufferSizeMono = pSound->iASIOBufferSizeMono;
CVector<int16_t>& vecsTmpAudioSndCrdStereo = pSound->vecsTmpAudioSndCrdStereo; CVector<int16_t>& vecsMultChanAudioSndCrd = pSound->vecsMultChanAudioSndCrd;
// perform the processing for input and output // perform the processing for input and output
pSound->ASIOMutex.lock(); // get mutex lock pSound->ASIOMutex.lock(); // get mutex lock
@ -625,7 +625,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = pASIOBuf[iCurSample]; vecsMultChanAudioSndCrd[2 * iCurSample + i] = pASIOBuf[iCurSample];
} }
if ( iSelAddCH >= 0 ) if ( iSelAddCH >= 0 )
@ -635,8 +635,8 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
Double2Short ( (double) vecsTmpAudioSndCrdStereo[2 * iCurSample + i] + Double2Short ( (double) vecsMultChanAudioSndCrd[2 * iCurSample + i] +
(double) pASIOBufAdd[iCurSample] ); (double) pASIOBufAdd[iCurSample] );
} }
} }
@ -650,7 +650,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, 3 ); memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, 3 );
iCurSam >>= 8; iCurSam >>= 8;
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = static_cast<int16_t> ( iCurSam ); vecsMultChanAudioSndCrd[2 * iCurSample + i] = static_cast<int16_t> ( iCurSam );
} }
if ( iSelAddCH >= 0 ) if ( iSelAddCH >= 0 )
@ -662,8 +662,8 @@ void CSound::bufferSwitch ( long index, ASIOBool )
memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelAddCH].buffers[index] ) + iCurSample * 3, 3 ); memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelAddCH].buffers[index] ) + iCurSample * 3, 3 );
iCurSam >>= 8; iCurSam >>= 8;
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
Double2Short ( (double) vecsTmpAudioSndCrdStereo[2 * iCurSample + i] + Double2Short ( (double) vecsMultChanAudioSndCrd[2 * iCurSample + i] +
(double) static_cast<int16_t> ( iCurSam ) ); (double) static_cast<int16_t> ( iCurSam ) );
} }
} }
@ -675,7 +675,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( pASIOBuf[iCurSample] >> 16 ); static_cast<int16_t> ( pASIOBuf[iCurSample] >> 16 );
} }
@ -686,8 +686,8 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
Double2Short ( (double) vecsTmpAudioSndCrdStereo[2 * iCurSample + i] + Double2Short ( (double) vecsMultChanAudioSndCrd[2 * iCurSample + i] +
(double) static_cast<int16_t> ( pASIOBufAdd[iCurSample] >> 16 ) ); (double) static_cast<int16_t> ( pASIOBufAdd[iCurSample] >> 16 ) );
} }
} }
@ -698,7 +698,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( static_cast<float*> ( static_cast<int16_t> ( static_cast<float*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT );
} }
@ -708,7 +708,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( static_cast<double*> ( static_cast<int16_t> ( static_cast<double*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] * _MAXSHORT );
} }
@ -718,7 +718,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( static_cast<int32_t*> ( static_cast<int16_t> ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFF ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFF );
} }
@ -728,7 +728,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( ( static_cast<int32_t*> ( static_cast<int16_t> ( ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0x3FFFF ) >> 2 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0x3FFFF ) >> 2 );
} }
@ -738,7 +738,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( ( static_cast<int32_t*> ( static_cast<int16_t> ( ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFF ) >> 4 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFF ) >> 4 );
} }
@ -748,7 +748,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( ( static_cast<int32_t*> ( static_cast<int16_t> ( ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFFF ) >> 8 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] & 0xFFFFFF ) >> 8 );
} }
@ -759,7 +759,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// flip bits // flip bits
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
Flip16Bits ( ( static_cast<int16_t*> ( Flip16Bits ( ( static_cast<int16_t*> (
pSound->bufferInfos[iSelCH].buffers[index] ) )[iCurSample] ); pSound->bufferInfos[iSelCH].buffers[index] ) )[iCurSample] );
} }
@ -774,7 +774,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
int iCurSam = 0; int iCurSam = 0;
memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, 3 ); memcpy ( &iCurSam, ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, 3 );
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
Flip16Bits ( static_cast<int16_t> ( iCurSam ) ); Flip16Bits ( static_cast<int16_t> ( iCurSam ) );
} }
break; break;
@ -784,7 +784,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
// flip bits and convert to 16 bit // flip bits and convert to 16 bit
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( Flip32Bits ( static_cast<int32_t*> ( static_cast<int16_t> ( Flip32Bits ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) >> 16 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) >> 16 );
} }
@ -794,7 +794,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( static_cast<float> ( static_cast<int16_t> ( static_cast<float> (
Flip32Bits ( static_cast<int32_t*> ( Flip32Bits ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * _MAXSHORT ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * _MAXSHORT );
@ -805,7 +805,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( static_cast<double> ( static_cast<int16_t> ( static_cast<double> (
Flip64Bits ( static_cast<int64_t*> ( Flip64Bits ( static_cast<int64_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * _MAXSHORT ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) ) * _MAXSHORT );
@ -816,7 +816,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( Flip32Bits ( static_cast<int32_t*> ( static_cast<int16_t> ( Flip32Bits ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFF ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFF );
} }
@ -826,7 +826,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( ( Flip32Bits ( static_cast<int32_t*> ( static_cast<int16_t> ( ( Flip32Bits ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0x3FFFF ) >> 2 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0x3FFFF ) >> 2 );
} }
@ -836,7 +836,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( ( Flip32Bits ( static_cast<int32_t*> ( static_cast<int16_t> ( ( Flip32Bits ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFF ) >> 4 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFF ) >> 4 );
} }
@ -846,7 +846,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// NOT YET TESTED // NOT YET TESTED
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] = vecsMultChanAudioSndCrd[2 * iCurSample + i] =
static_cast<int16_t> ( ( Flip32Bits ( static_cast<int32_t*> ( static_cast<int16_t> ( ( Flip32Bits ( static_cast<int32_t*> (
pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFFF ) >> 8 ); pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] ) & 0xFFFFFF ) >> 8 );
} }
@ -855,7 +855,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
} }
// call processing callback function // call processing callback function
pSound->ProcessCallback ( vecsTmpAudioSndCrdStereo ); pSound->ProcessCallback ( vecsMultChanAudioSndCrd );
// PLAYBACK ------------------------------------------------------------ // PLAYBACK ------------------------------------------------------------
@ -874,7 +874,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
pASIOBuf[iCurSample] = vecsTmpAudioSndCrdStereo[2 * iCurSample + i]; pASIOBuf[iCurSample] = vecsMultChanAudioSndCrd[2 * iCurSample + i];
} }
break; break;
} }
@ -885,7 +885,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert current sample in 24 bit format // convert current sample in 24 bit format
int32_t iCurSam = static_cast<int32_t> ( int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
iCurSam <<= 8; iCurSam <<= 8;
@ -901,7 +901,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
pASIOBuf[iCurSample] = ( iCurSam << 16 ); pASIOBuf[iCurSample] = ( iCurSam << 16 );
} }
@ -913,7 +913,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
const float fCurSam = static_cast<float> ( const float fCurSam = static_cast<float> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<float*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<float*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
fCurSam / _MAXSHORT; fCurSam / _MAXSHORT;
@ -925,7 +925,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
const double fCurSam = static_cast<double> ( const double fCurSam = static_cast<double> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<double*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<double*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
fCurSam / _MAXSHORT; fCurSam / _MAXSHORT;
@ -938,7 +938,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
iCurSam; iCurSam;
@ -951,7 +951,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
( iCurSam << 2 ); ( iCurSam << 2 );
@ -964,7 +964,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
( iCurSam << 4 ); ( iCurSam << 4 );
@ -977,7 +977,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
( iCurSam << 8 ); ( iCurSam << 8 );
@ -990,7 +990,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
( (int16_t*) pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = ( (int16_t*) pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
Flip16Bits ( vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); Flip16Bits ( vecsMultChanAudioSndCrd[2 * iCurSample + i] );
} }
break; break;
@ -1001,7 +1001,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
// because the bits are flipped, we do not have to perform the // because the bits are flipped, we do not have to perform the
// shift by 8 bits // shift by 8 bits
int32_t iCurSam = static_cast<int32_t> ( Flip16Bits ( int32_t iCurSam = static_cast<int32_t> ( Flip16Bits (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ) ); vecsMultChanAudioSndCrd[2 * iCurSample + i] ) );
memcpy ( ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, &iCurSam, 3 ); memcpy ( ( (char*) pSound->bufferInfos[iSelCH].buffers[index] ) + iCurSample * 3, &iCurSam, 3 );
} }
@ -1013,7 +1013,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit and flip bits // convert to 32 bit and flip bits
int iCurSam = static_cast<int32_t> ( int iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
Flip32Bits ( iCurSam << 16 ); Flip32Bits ( iCurSam << 16 );
@ -1025,7 +1025,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
const float fCurSam = static_cast<float> ( const float fCurSam = static_cast<float> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<float*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<float*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
static_cast<float> ( Flip32Bits ( static_cast<int32_t> ( static_cast<float> ( Flip32Bits ( static_cast<int32_t> (
@ -1038,7 +1038,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ ) for ( iCurSample = 0; iCurSample < iASIOBufferSizeMono; iCurSample++ )
{ {
const double fCurSam = static_cast<double> ( const double fCurSam = static_cast<double> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<float*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<float*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
static_cast<double> ( Flip64Bits ( static_cast<int64_t> ( static_cast<double> ( Flip64Bits ( static_cast<int64_t> (
@ -1052,7 +1052,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
Flip32Bits ( iCurSam ); Flip32Bits ( iCurSam );
@ -1065,7 +1065,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
Flip32Bits ( iCurSam << 2 ); Flip32Bits ( iCurSam << 2 );
@ -1078,7 +1078,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
Flip32Bits ( iCurSam << 4 ); Flip32Bits ( iCurSam << 4 );
@ -1091,7 +1091,7 @@ void CSound::bufferSwitch ( long index, ASIOBool )
{ {
// convert to 32 bit // convert to 32 bit
const int32_t iCurSam = static_cast<int32_t> ( const int32_t iCurSam = static_cast<int32_t> (
vecsTmpAudioSndCrdStereo[2 * iCurSample + i] ); vecsMultChanAudioSndCrd[2 * iCurSample + i] );
static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] = static_cast<int32_t*> ( pSound->bufferInfos[iSelCH].buffers[index] )[iCurSample] =
Flip32Bits ( iCurSam << 8 ); Flip32Bits ( iCurSam << 8 );

View file

@ -117,7 +117,7 @@ protected:
CVector<int> vSelectedInputChannels; CVector<int> vSelectedInputChannels;
CVector<int> vSelectedOutputChannels; CVector<int> vSelectedOutputChannels;
CVector<int16_t> vecsTmpAudioSndCrdStereo; CVector<int16_t> vecsMultChanAudioSndCrd;
QMutex ASIOMutex; QMutex ASIOMutex;