modified play testing for mono devices, compiles OK but can't test as I don't have...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 25 Mar 2014 05:21:58 +0000 (05:21 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Tue, 25 Mar 2014 05:21:58 +0000 (05:21 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1480 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/dlg_audiooptions.cpp

index 59560e73dde64c4433490076de019a846073ac8d..994cc51ce692ed2489ff7967781656a1e4bb5531 100644 (file)
@@ -947,7 +947,7 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca
 
     // work out how many input channels this device supports.
 
-    deviceInfo = Pa_GetDeviceInfo(g_soundCard1InDeviceNum);
+    deviceInfo = Pa_GetDeviceInfo(devNum);
     if (deviceInfo == NULL) {
         wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card "), wxT("Error"), wxOK);
         return;
@@ -1035,12 +1035,13 @@ void AudioOptsDialog::plotDeviceInputForAFewSecs(int devNum, PlotScalar *plotSca
 //-------------------------------------------------------------------------
 void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotScalar) {
     PaStreamParameters  outputParameters;
+    const PaDeviceInfo *deviceInfo = NULL;
     PaStream           *stream = NULL;
     PaError             err;
     short               out48k_stereo_short[2*TEST_BUF_SIZE];
     short               out48k_short[TEST_BUF_SIZE];
     short               out8k_short[TEST_BUF_SIZE];
-    int                 numDevices, nBufs, i, j, src_error, n;
+    int                 numDevices, nBufs, i, j, src_error, n, outputChannels;
     float               t;
     SRC_STATE          *src;
     FIFO               *fifo;
@@ -1055,8 +1056,22 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotSc
     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 output channels this device supports.
+
+    deviceInfo = Pa_GetDeviceInfo(devNum);
+    if (deviceInfo == NULL) {
+        wxMessageBox(wxT("Couldn't get device info from Port Audio for Sound Card "), wxT("Error"), wxOK);
+        return;
+    }
+    if (deviceInfo->maxOutputChannels == 1)
+        outputChannels = 1;
+    else
+        outputChannels = 2;
+
+    printf("outputChannels: %d\n", outputChannels);
+
     outputParameters.device = devNum;
-    outputParameters.channelCount = 2;
+    outputParameters.channelCount = outputChannels;
     outputParameters.sampleFormat = paInt16;
     outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultHighOutputLatency;
     outputParameters.hostApiSpecificStreamInfo = NULL;
@@ -1086,8 +1101,13 @@ void AudioOptsDialog::plotDeviceOutputForAFewSecs(int devNum, PlotScalar *plotSc
     for(i=0, t=0.0, n=0; i<nBufs; i++, t+=(float)TEST_BUF_SIZE/TEST_FS) {
         for(j=0; j<TEST_BUF_SIZE; j++,n++) {
             out48k_short[j] = 2000.0*cos(6.2832*(n++)*400.0/TEST_FS);
-            out48k_stereo_short[2*j] = out48k_short[j];   // left channel
-            out48k_stereo_short[2*j+1] = out48k_short[j]; // right channel
+            if (outputChannels == 2) {
+                out48k_stereo_short[2*j] = out48k_short[j];   // left channel
+                out48k_stereo_short[2*j+1] = out48k_short[j]; // right channel
+            }
+            else {
+                out48k_stereo_short[j] = out48k_short[j];     // mono
+            }
         }
         Pa_WriteStream(stream, out48k_stereo_short, TEST_BUF_SIZE);