Menu

audio.py

Nathan Towne

audio.py

audio.py is a python utility that provides information about the audio environment, such as the names of the sound cards and devices, information about a particular device, the sample rate of a device at a given setting, and spectra of data from a device at a sample rate. It can also route samples to stdout and measure mean and standard deviation of samples.

Dependencies

Usage

Enter the program name without arguments to print a short usage description.

    $ audio

    usage
    audio.py hardware
    audio.py info        <device>
    audio.py statistics  <device> <framerate>
    audio.py spectrum    <device> <framerate> [<interval>]
    audio.py measurerate <device> <framerate> [<durationminutes> [<printintervalseconds>]]
    audio.py stdout      <device> <framerate> [<delay>]

hardware

The hardware (hw) subcommand lists sound cards and devices.

    $ audio hw

    sound cards  2
        HDMI
        PCH

    capture devices  21
                           null                    default                    lavrate
                     samplerate                  speexrate                       jack
                            oss                      pulse                      speex
                          upmix                   vdownmix        usbstream:CARD=HDMI
              hw:CARD=PCH,DEV=0          hw:CARD=PCH,DEV=2      plughw:CARD=PCH,DEV=0
          plughw:CARD=PCH,DEV=2        sysdefault:CARD=PCH       front:CARD=PCH,DEV=0
          dsnoop:CARD=PCH,DEV=0      dsnoop:CARD=PCH,DEV=2         usbstream:CARD=PCH

Spectra

To measure spectra from a device,

    $ audio spectrum plughw:CARD=PCH,DEV=0 88200 8

    sound device plughw:CARD=PCH,DEV=0
    framerate 88200
    fourier frame 2048
    frame count 344

When the sound card has no antenna connection, spectra can look like this:
Image

The sample rate is 72 kHz. Both polarizations are plotted. Note that the relative intensities of the two polarizations vary with the direction of the transmitter. Spectra should show a sharp high-frequency cutoff, and frequencies of monitored transmitters must be below that cutoff. If an antenna is connected to the sound card, the spectrum will show lines at transmitter frequencies, as in the next figure. Strong lines are at 21.4 kHz (NPM), 24.0 kHz (NAA), 24.8 kHz (NLK), and 25.2 kHz (NML). Line widths among these transmitters are consistently 100 Hz reflecting the same MSK bit rate among them.

Image

Sample rate measurement

To measure sample rate, use the measurerate subcommand.

    $ audio measurerate hw:CARD=PCH,DEV=0 96000 10 80

                  duration : 79.999382 s
               frame count : 7680000
                frame rate : 96000.74161 Hz
                byte count : 2048

                  duration : 79.999629 s
               frame count : 7680000
                frame rate : 96000.44520 Hz
                byte count : 2048

                  duration : 79.999088 s
               frame count : 7680000
                frame rate : 96001.09441 Hz
                byte count : 2048

Note that there is scatter in the readings. Longer intervals provide less scatter and better results. A good measurement of the sample rate that differs substantially from the frequency setting (compared to the transmitter line width) should be entered into the frameratemeasured field of the configuration file used in an observation at that setting. If the measurement does not differ substantially, or if there is a lot of scatter in the readings, stick with the sample-rate setting in the frameratemeasured field.

There are also the statistics and stdout subcommands, which have more specialized uses.


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.