}
}
-void MainFrame::initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDevice, int soundCard, int sampleRate)
+void MainFrame::initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDevice,
+ int soundCard, int sampleRate, int inputChannels)
{
// Note all of the wrapper functions below just set values in a
// portaudio struct so can't return any errors. So no need to trap
// init input params
pa->setInputDevice(inDevice);
- pa->setInputChannelCount(2); // stereo input
+ pa->setInputChannelCount(inputChannels); // stereo input
+ printf("maxInputChannels: %d\n", inputChannels);
pa->setInputSampleFormat(PA_SAMPLE_TYPE);
pa->setInputLatency(pa->getInputDefaultLowLatency());
pa->setInputHostApiStreamInfo(NULL);
//-------------------------------------------------------------------------
void MainFrame::startRxStream()
{
- int src_error;
+ int src_error;
+ const PaDeviceInfo *deviceInfo1 = NULL, *deviceInfo2 = NULL;
+ int inputChannels1, inputChannels2;
if(!m_RxRunning) {
cb_cnt = 0;
return;
}
- initPortAudioDevice(m_rxPa, g_soundCard1InDeviceNum, g_soundCard1OutDeviceNum, 1, g_soundCard1SampleRate);
+ // work out how many input channels this device supports.
+
+ deviceInfo1 = Pa_GetDeviceInfo(g_soundCard1InDeviceNum);
+ if (deviceInfo1 == NULL) {
+ wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card 1"), wxT("Error"), wxOK);
+ delete m_rxPa;
+ m_RxRunning = false;
+ return;
+ }
+ if (deviceInfo1->maxInputChannels == 1)
+ inputChannels1 = 1;
+ else
+ inputChannels1 = 2;
+
+ initPortAudioDevice(m_rxPa, g_soundCard1InDeviceNum, g_soundCard1OutDeviceNum, 1,
+ g_soundCard1SampleRate, inputChannels1);
// Init Sound Card 2 ------------------------------------------------
return;
}
-
- initPortAudioDevice(m_txPa, g_soundCard2InDeviceNum, g_soundCard2OutDeviceNum, 2, g_soundCard2SampleRate);
+ deviceInfo2 = Pa_GetDeviceInfo(g_soundCard2InDeviceNum);
+ if (deviceInfo2 == NULL) {
+ wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card 1"), wxT("Error"), wxOK);
+ delete m_rxPa;
+ m_RxRunning = false;
+ return;
+ }
+ if (deviceInfo2->maxInputChannels == 1)
+ inputChannels2 = 1;
+ else
+ inputChannels2 = 2;
+
+ initPortAudioDevice(m_txPa, g_soundCard2InDeviceNum, g_soundCard2OutDeviceNum, 2,
+ g_soundCard2SampleRate, inputChannels2);
}
// Init call back data structure ----------------------------------------------
m_rxUserdata = new paCallBackData;
- m_rxUserdata->pWFPanel = m_panelWaterfall;
- m_rxUserdata->pSPPanel = m_panelSpectrum;
+ m_rxUserdata->inputChannels1 = inputChannels1;
+ if (deviceInfo2 != NULL)
+ m_rxUserdata->inputChannels2 = inputChannels2;
// init sample rate conversion states
// assemble a mono buffer (just use left channel) and write to FIFO
assert(framesPerBuffer < MAX_FPB);
- for(i = 0; i < framesPerBuffer; i++, rptr += 2)
+
+ for(i = 0; i < framesPerBuffer; i++, rptr += cbData->inputChannels1)
{
indata[i] = *rptr;
}
//if (statusFlags)
// printf("statusFlags: 0x%x\n", statusFlags);
- for(i = 0; i < framesPerBuffer; i++, rptr += 2)
+ for(i = 0; i < framesPerBuffer; i++, rptr += cbData->inputChannels2)
{
indata[i] = *rptr;
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
typedef struct
{
- PlotSpectrum *pSPPanel;
- PlotWaterfall *pWFPanel;
-
// libresample states for 48 to 8 kHz conversions
SRC_STATE *insrc1;
struct FIFO *rxinfifo;
struct FIFO *rxoutfifo;
+ int inputChannels1, inputChannels2;
} paCallBackData;
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
CODEC2 *c2 // Codec 2 states
);
- void initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDevice, int soundCard, int sampleRate);
+ void initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDevice,
+ int soundCard, int sampleRate, int inputChannels);
protected:
// protected event handlers