some more work on sound card channel mapping support for Windows

This commit is contained in:
Volker Fischer 2010-03-20 08:55:42 +00:00
parent 9828ceec81
commit cc6b8a85f8
3 changed files with 222 additions and 14 deletions

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>310</height>
<width>535</width>
<height>382</height>
</rect>
</property>
<property name="windowTitle" >
@ -205,6 +205,150 @@
</property>
</widget>
</item>
<item>
<widget class="QFrame" name="FrameSoundcardChannelSelection" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Plain</enum>
</property>
<layout class="QVBoxLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="lbInChannelMapping" >
<property name="text" >
<string>Input Channel Mapping</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="labelLInChan" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>L</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelRInChan" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>R</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>3</number>
</property>
<item>
<widget class="QComboBox" name="cbLInChan" />
</item>
<item>
<widget class="QComboBox" name="cbRInChan" />
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lbOutChannelMapping" >
<property name="text" >
<string>Output Channel Mapping</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" >
<number>3</number>
</property>
<item>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="labelLOutChan" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>L</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelROutChan" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>R</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>3</number>
</property>
<item>
<widget class="QComboBox" name="cbLOutChan" />
</item>
<item>
<widget class="QComboBox" name="cbROutChan" />
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
@ -212,8 +356,8 @@
</property>
<property name="sizeHint" >
<size>
<width>71</width>
<height>16</height>
<width>153</width>
<height>0</height>
</size>
</property>
</spacer>

View File

@ -231,8 +231,6 @@ QString CSound::CheckDeviceCapabilities()
}
// check the number of available channels
long lNumInChan;
long lNumOutChan;
ASIOGetChannels ( &lNumInChan, &lNumOutChan );
if ( ( lNumInChan < NUM_IN_OUT_CHANNELS ) ||
( lNumOutChan < NUM_IN_OUT_CHANNELS ) )
@ -298,10 +296,50 @@ QString CSound::CheckDeviceCapabilities()
}
}
// the device has changed, per definition we reset the channel
// mapping to the defaults (first two available channels)
ResetChannelMapping();
// everything is ok, return empty string for "no error" case
return "";
}
void CSound::SetLeftInputChannel ( const int iNewChan )
{
// apply parameter after input parameter check
if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChan ) )
{
vSelectedInputChannels[0] = iNewChan;
}
}
void CSound::SetRightInputChannel ( const int iNewChan )
{
// apply parameter after input parameter check
if ( ( iNewChan >= 0 ) && ( iNewChan < lNumInChan ) )
{
vSelectedInputChannels[1] = iNewChan;
}
}
void CSound::SetLeftOutputChannel ( const int iNewChan )
{
// apply parameter after input parameter check
if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) )
{
vSelectedOutputChannels[0] = iNewChan;
}
}
void CSound::SetRightOutputChannel ( const int iNewChan )
{
// apply parameter after input parameter check
if ( ( iNewChan >= 0 ) && ( iNewChan < lNumOutChan ) )
{
vSelectedOutputChannels[1] = iNewChan;
}
}
int CSound::GetActualBufferSize ( const int iDesiredBufferSizeMono )
{
int iActualBufferSizeMono;
@ -485,7 +523,9 @@ void CSound::Stop()
CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ), void* arg ) :
CSoundBase ( true, fpNewCallback, arg ),
vSelectedInputChannels ( NUM_IN_OUT_CHANNELS ),
vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS )
vSelectedOutputChannels ( NUM_IN_OUT_CHANNELS ),
lNumInChan ( 0 ),
lNumOutChan ( 0 )
{
int i;
@ -517,12 +557,8 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
// init device index with illegal value to show that driver is not initialized
lCurDev = -1;
// init selected channel numbers with defaults: use first available
// channels for input and output
vSelectedInputChannels[0] = 0;
vSelectedInputChannels[1] = 1;
vSelectedOutputChannels[0] = 0;
vSelectedOutputChannels[1] = 1;
// init channel mapping
ResetChannelMapping();
// set up the asioCallback structure
asioCallbacks.bufferSwitch = &bufferSwitch;
@ -531,6 +567,16 @@ CSound::CSound ( void (*fpNewCallback) ( CVector<int16_t>& psData, void* arg ),
asioCallbacks.bufferSwitchTimeInfo = &bufferSwitchTimeInfo;
}
void CSound::ResetChannelMapping()
{
// init selected channel numbers with defaults: use first available
// channels for input and output
vSelectedInputChannels[0] = 0;
vSelectedInputChannels[1] = 1;
vSelectedOutputChannels[0] = 0;
vSelectedOutputChannels[1] = 1;
}
CSound::~CSound()
{
// cleanup ASIO stuff

View File

@ -63,22 +63,40 @@ public:
virtual void OpenDriverSetup() { ASIOControlPanel(); }
// device selection
int GetNumDev() { return lNumDevs; }
QString GetDeviceName ( const int iDiD ) { return cDriverNames[iDiD]; }
QString SetDev ( const int iNewDev );
int GetDev() { return lCurDev; }
// channel selection
int GetNumInputChannels() { return static_cast<int> ( lNumInChan ); }
QString GetInputChannelName ( const int iDiD ) { return channelInfosInput[iDiD].name; }
void SetLeftInputChannel ( const int iNewChan );
void SetRightInputChannel ( const int iNewChan );
int GetLeftInputChannel() { return vSelectedInputChannels[0]; }
int GetRightInputChannel() { return vSelectedInputChannels[1]; }
int GetNumOutputChannels() { return static_cast<int> ( lNumOutChan ); }
QString GetOutputChannelName ( const int iDiD ) { return channelInfosOutput[iDiD].name; }
void SetLeftOutputChannel ( const int iNewChan );
void SetRightOutputChannel ( const int iNewChan );
int GetLeftOutputChannel() { return vSelectedOutputChannels[0]; }
int GetRightOutputChannel() { return vSelectedOutputChannels[1]; }
protected:
QVector<QString> LoadAndInitializeFirstValidDriver();
QString LoadAndInitializeDriver ( int iIdx );
int GetActualBufferSize ( const int iDesiredBufferSizeMono );
QString CheckDeviceCapabilities();
bool CheckSampleTypeSupported ( const ASIOSampleType SamType );
void ResetChannelMapping();
int iASIOBufferSizeMono;
int iASIOBufferSizeStereo;
long lNumInChan;
long lNumOutChan;
CVector<int> vSelectedInputChannels;
CVector<int> vSelectedOutputChannels;