Using Baudline for Frequency Measurement

I've been using Baudline, which is a soundcard-based spectrum analyzer program for Linux, as a key tool in my technique for measuring the frequency of signals off the air.

This page has some notes, mainly gleaned from correspondence with Erik Olson, Baudline's author, on how to configure and use Baudline for this application.

These are presently in no particular order; someday I'll make this into more of a tutorial page.

Baudline offers two ways to get increased frequency resolution. First, you can set the size of the FFT transform, up to 65536 samples. Second, you can decimate the signal to reduce the sample rate.

Ordinary decimation causes a problem because it reduces the bandwidth. However, Baudline includes a digital downconverter that allows you to move the chunk of spectrum covered by the decimation.

You can't directly stream data to disk from Baudline. You can record data, then pause, then select a section of the waterfall display, then save that as a .wav file (the default is all data if none is manually selected). You may need to set the buffer size to allow more data to be captured. Do that in the Scroll Control window. Alternatively, you can record raw samples as shown below.

One neat feature of Baudline is that it can pipe data. This means you can run two instances at once, and also save raw data. Here's an example:

baudline -session top -fftsize 2048 -samplerate 8000 -record -stdout | \
baduline -session bottom -fftsize 65536 -sampelrate 8000 -decimateby32 \
-overlap 100 -stdin -channels 1

You can capture raw samples to a file with something like:

baudline -session top -stdout -record | \ tee file.raw | \ baudline -session bottom -stdin -record

The file of raw samples won't have any header info, so to play it you'll need to either pipe it to baudline using "-stdin" or use file format "raw" in the Baudline "Input/Open File" window.

To pipe data from the first session to the second, highlight the area in the first session's waterfall window, then hit Alt+| to ship it to the second session.

Using the decimation and the downmix functions are destructive -- data is recorded at the new (lower) sample rate. That's why you may want to run a pair of Baudline sessions as described above so you can capture raw data without losing any of it.

A one-minute sample of data implies some limits in how deep the FFT can be. If you're sampling at 8000 samples/second, an FFT deepter than about 2048 will probably have some non-signal data leaking in. Consider what window to use -- a Kaiser window with a larger beta value will reduce the leakage, but will make the lobes fatter -- so you may not gain anything.

A sqare window will have lots of leakage, but a very sharp lobe. The Welch window is good for weak-signal work.

Some decimation/FFT size tradeoffs:

  • a larger FFT gives more bins for display or scrolling
  • there's no SNR difference
  • more decimation is better if the signal is wandering
  • a smaller FFT is better if the signal wanders

    To set the decimation/digital down conversion window in the second Baudline session, do something like:

    cat file.raw | baudline -stdin -channels 1 -pause

    then open up the Input devices window and select the decimation and downconversion settings. The choose record and Baudline will process and collect the data much faster than real-time.

    The other method is to use two instances of Baudline. Load the data file into the top session and select a section of data. Then make sure the lower session is in record mode and adjust its decimation rate and down mixer frequency to your liking. Next, in the upper session press Alt+| or choose "Paste stdout" from the Output menu. The sample data you selected will now be sent from the uper to the lower session. You can redo this as often as you'd like in the bottom session. The upper session serves as the source, and the lower session as the sink.

    Finally, the latest version of Baudline has high-resolution frequency measurement capability built in. Selecting "Measurements/Offset" allows you to display the frequency of the peak signal in the display, the second peak signal, or the delta between the two. The resolution is much higher than doing mouse-based delta measurements and can be up to 1 microHz.

    Here's a picture of what Baudline can do with decimation, downconversion, and the measurements menu: