From fe0b1f91a63a5fa8c6cffbd47b20c745a057df8c Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 25 Mar 2014 05:08:10 +0000 Subject: [PATCH] modified rec testing for mono devices git-svn-id: https://svn.code.sf.net/p/freetel/code@1478 01035d8c-6547-0410-b346-abe4f91aad63 --- fdmdv2/src/dlg_audiooptions.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/fdmdv2/src/dlg_audiooptions.cpp b/fdmdv2/src/dlg_audiooptions.cpp index 3d7f3eee..59560e73 100644 --- a/fdmdv2/src/dlg_audiooptions.cpp +++ b/fdmdv2/src/dlg_audiooptions.cpp @@ -923,12 +923,13 @@ void AudioOptsDialog::OnTxOutDeviceSelect(wxListEvent& evt) //------------------------------------------------------------------------- void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotScalar) { PaStreamParameters inputParameters; + const PaDeviceInfo *deviceInfo = NULL; PaStream *stream = NULL; PaError err; short in48k_stereo_short[2*TEST_BUF_SIZE]; short in48k_short[TEST_BUF_SIZE]; short in8k_short[TEST_BUF_SIZE]; - int numDevices, nBufs, i, j, src_error; + int numDevices, nBufs, i, j, src_error,inputChannels; float t; SRC_STATE *src; FIFO *fifo; @@ -944,14 +945,28 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca fifo = fifo_create((int)(DT*TEST_WAVEFORM_PLOT_FS*2)); assert(fifo != NULL); src = src_new(SRC_SINC_FASTEST, 1, &src_error); assert(src != NULL); + // work out how many input channels this device supports. + + deviceInfo = Pa_GetDeviceInfo(g_soundCard1InDeviceNum); + if (deviceInfo == NULL) { + wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card "), wxT("Error"), wxOK); + return; + } + if (deviceInfo->maxInputChannels == 1) + inputChannels = 1; + else + inputChannels = 2; + + // open device + inputParameters.device = devNum; - inputParameters.channelCount = 2; + inputParameters.channelCount = inputChannels; inputParameters.sampleFormat = paInt16; inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultHighInputLatency; inputParameters.hostApiSpecificStreamInfo = NULL; nBufs = TEST_WAVEFORM_PLOT_TIME*TEST_FS/TEST_BUF_SIZE; - printf("nBufs %d\n", nBufs); + printf("inputChannels: %d nBufs %d\n", inputChannels, nBufs); err = Pa_OpenStream( &stream, @@ -975,8 +990,14 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca for(i=0, t=0.0; i