Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Cable Connection and Testing

Lu, Han edited this page Mar 25, 2016 · 16 revisions

Audio Ports

PC/laptop/tablet/smart phone and other devices usually supports multiple audio ports:

  • DP
  • HDMI
  • Line in
  • Line out
  • Combo (mono mic + dual hp) ...

Line-out to line-in loop back connection

For line-out/line-in port, we can set up a loop back route with a TRS-TRS cable directly. bat-lineout-to-linein-loopback-connection

We can also use DP/HDMI audio paths by converting digital port into analog port:

  • DP ---> Line-out port on DP monitor
  • HDMI ---> Line-out port on HDMI monitor

Line-out to line-in loop back connection usually supports 2 channels.

Combo loop back connection

For combo port, an RC filter is required for isolating between hp out and mic in.

Pick up either way for loopback connection:

combo loopback

or

combo loopback1

(please refer to https://source.android.com/devices/audio/loopback.html)

Combo loop back connection usually supports only 1 channel, due to the mono mic.

Basic Commands

  • Play and capture

    • Playback though COMBO hp port, and capture from COMBO mic port:

        $ alsabat -D plughw:0,0 -c 1 --file test.wav
      
      or
      
        $ alsabat -P plughw:0,0 -C plughw:0,0 -c 1 -F 997
      
  • Single line mode

    • Playback through DP port, and capture from line in port on another machine:

      playback machine:
      
        $ alsabat -P plughw:0,3 -c 2 -F 250:500 -n10s
      
      capture machine:
      
        $ alsabat -C plughw:1,0 -c 2 -F 250:500
      
  • If target frequency (set by option "-F". 997 Hz by default) be detected, return 0. Otherwise return error code.

        $ alsabat -D plughw:1,0 -c 2 -F 250:500
    
        bat version 0.01
    
        Entering playback thread (ALSA).
        Playing generated audio sine wave
        Entering capture thread (ALSA).
        Recording ...
        Playback completed.
        Capture completed.
    
        BAT analysed signal has 88200 frames at 44100 Hz, 2 channels, 2 bytes per sample
    
        Channel 1 - Checking for target frequency 250.00 Hz
        Detected peak at 250.50 Hz of 43.28 dB
          Total 45.9 dB from 250.00 to 250.50 Hz
          PASS: Peak detected at target frequency
        Detected at least 1 signal(s) in total
    
        Channel 2 - Checking for target frequency 500.00 Hz
        Detected peak at 500.50 Hz of 44.87 dB
          Total 45.8 dB from 500.00 to 500.50 Hz
          PASS: Peak detected at target frequency
        Detected at least 1 signal(s) in total
    
        Return value is 0
    

Feature Testing

After install, a bash script can be used to test basic alsabat features. You need to loopback connect the line-in and the line-out port on your computer, and run

    $ alsabat-test.sh plughw:1,0 plughw:1,0

The parameters are for playback device and capture device. If they are the same device, the second parameter can be ignored. If no paramater, the script will use "default" as default device name. Your hardware may not support all features so some cases may fail. With the command above, In my Haswell PC, 20/20 cases passes with ALSA backend, and 14/20 cases passes with tinyalsa backend.