experimental support for mono record devices such as the rig blaster, still testing
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 16 Nov 2012 04:08:38 +0000 (04:08 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 16 Nov 2012 04:08:38 +0000 (04:08 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@978 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/dlg_audiooptions.cpp
fdmdv2/src/fdmdv2_main.cpp
fdmdv2/src/fdmdv2_main.h

index f215eb9f65664e17c77d96090b67660d89b0fb1b..4cdec284080925d1e4f8f9e907742d9280f5247a 100644 (file)
@@ -678,7 +678,7 @@ int AudioOptsDialog:: buildListOfSupportedSampleRates(wxComboBox *cbSampleRate,
     outputParameters.hostApiSpecificStreamInfo = NULL;
     
     cbSampleRate->Clear();
-    printf("devNum %d supports: ", devNum);
+    //printf("devNum %d supports: ", devNum);
     numSampleRates = 0;
     for(i = 0; standardSampleRates[i] > 0; i++)
     {      
index 1010f80b568c5d247f5f0cdbea2ace8644838ffa..84b5d061407c73b8dfad31b1881c5b85c3367f37 100644 (file)
@@ -1153,7 +1153,8 @@ void MainFrame::autoDetectSoundCards(PortAudioWrap *pa)
     }
 }
 
-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
@@ -1162,7 +1163,8 @@ void  MainFrame::initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDev
     // 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);
@@ -1194,7 +1196,9 @@ void  MainFrame::initPortAudioDevice(PortAudioWrap *pa, int inDevice, int outDev
 //-------------------------------------------------------------------------
 void MainFrame::startRxStream()
 {
-    int src_error;
+    int   src_error;
+    const PaDeviceInfo *deviceInfo1 = NULL, *deviceInfo2 = NULL;
+    int   inputChannels1, inputChannels2;
 
     if(!m_RxRunning) {
         cb_cnt = 0;
@@ -1229,7 +1233,22 @@ void MainFrame::startRxStream()
             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 ------------------------------------------------
 
@@ -1252,15 +1271,28 @@ void MainFrame::startRxStream()
                 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
 
@@ -1528,7 +1560,8 @@ int MainFrame::rxCallback(
     // 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;
     }
@@ -1874,7 +1907,7 @@ int MainFrame::txCallback(
     //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;
     }
index 025a2b645b3ef574c1adbf6576aa70b6633ea7e3..0d28362e1af8b13604533f6fd04d7cd5e5dd59fd 100644 (file)
@@ -136,9 +136,6 @@ DECLARE_APP(MainApp)
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
 typedef struct
 {
-    PlotSpectrum    *pSPPanel;
-    PlotWaterfall   *pWFPanel;
-
     // libresample states for 48 to 8 kHz conversions
 
     SRC_STATE      *insrc1;
@@ -161,6 +158,7 @@ typedef struct
     struct FIFO    *rxinfifo;
     struct FIFO    *rxoutfifo;
 
+    int             inputChannels1, inputChannels2;
 } paCallBackData;
 
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=
@@ -235,7 +233,8 @@ class MainFrame : public TopFrame
                                             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