Wave File Logging and -Analysis

Spectrum Lab is designed for real-time analysis of audio data. But you can also process data saved in wave files (and others), and you can save the in- or output signal in a wave-audio file without interrupting the analysis.

Contents

  1. Wave File Logging
  2. Triggered Audio Recorder
  3. Wave File Analysis
    1. Other supported file formats (for analysis)
  4. Audio Playlist
  5. Controlling audio files through the interpreter
  6. Wave files with 'I+Q' data (and the trouble with cos/sin or cos/-sin)
  7. Extra chunks in a wave file header (written by SpecLab)
  8. Auxiliary files (same name and folder as the logged audio file, but different file extension: *.aux; may contain GPS- and other data)

See also:

Triggered Audio Recorder (features a pre-trigger buffer);
Transmitting and receiving Ogg / Vorbis internet audio streams;
Analysing other audio file formats using Winamp (2) plugins;
Spectrum Lab's main index, 'A to Z' .


1. Wave File Logging

While audio streams are processed by SL in real time, they can be saved as a wave file (for "logging", "archiving" etc).

You can tap the recorder to any node in SL's circuit window, for example L1/R1 = input, L5/R5 = output, or (for the EbNaut recorder) to the decimated input for the main frequency analyser's FFT . For most applications you will save the input as a wave file to have all opportunities for later post-processing (except, maybe, when only a small portion of the frequency range is of interest and the file size shall be kept low.. more on that later).

You don't necessarily have to save the wave file data with the same sample rate as the ADC. Instead, you can use the lowest possible sample rate for the wave file to save a lot of disk space... consider this: A software VLF radio uses an ADC running at 44.1ksamples/second, and converts the signal down to 650 Hz, filtered to a bandwidth of 100Hz. Practically, it would be enough here to save the "downconverted" signal with 5512 samples/second which occupies only 12.5 % of the disk space. (5512 is the lowest "standard" sample rate supported by most soundcards, but don't bet on that)

The settings for wave file logging can be modified in the configuration dialog, which can be opened through the main menu (Options .. Wave file settings) :

wave file settings

To start or stop logging, use either the file menu (File..Audio Files and Streams.. 'Save input as audio file' or 'Save output as audio file'), or one of Spectrum Lab's interpreter commands.
In the save dialog (which can be opened with a double click into the 'name' field), you can manually enter a template instead of a normal filename, for example:
    C:\vlf\<YYYYMMDD_hhmm>.wav
The string between angle brackets will be replaced by the current date and time when actually creating the file, as explained for the 'stream log' (in fact, such name templates can be used for the audio recorder, and in a few other places too). When creating a file on January 16, 2015 at 19:30 UTC, the example shown above would create a file named
    C:\vlf\20150116_1930.wav .
This feature saves a few seconds (time not wasted in a stupid fileselector box) when in a hurry to record a new file. The same applies to the triggered audio recorder, which in fact uses the same filename (or its template) as described above for normal audio logging.


While saving the audio stream in a wave file, the progress button will tell you how many kBytes are already written to the file. Be careful not to run out of disk space while logging, because Windows may crash in that case. If this is an issue, use a different partition of even a different harddisk to record wave files.

If a GPS is connected (and configured), there may be an auxiliary file (*.aux) written along with each audio file (*.wav). The auxiliary file will contain GPS coordinates, timestamps, and possibly some other data. If you don't need the AUX files, set the GPS output interval to zero in the GPS configuration window. Except for the file extension, aux files have the same names as their corresponding wave audio files. Without auxiliary files, there will only be one single GPS position in an extra chunk ("inf1") of the wave file header. More details about logging (exporting) GPS data along with audio files can be found in an extra document (gps_decoder.htm).

(*) In the author's opinion, a kByte ("kilobyte") still consists of 1024 bytes. Don't urge me to call this a "kibibyte" from now on, just because some egghead discovered that 1024 is not equal to 1000. A "kilobyte" has never been 1000 bytes. Full stop. :o)

back to top


2. Triggered Audio Recorder

As an alternative to the "normal" logging of wave files as explained in the previous chapter, the recording of audio files can also be started automatically (without using the FILE menu, and without the help of the interpreter). For example, you want to record the raw input only if "something interesting" happens (for example, the call of a bat in a certain frequency range). You may also want to record a few seconds before the event actually happened, and a only few seconds after that (to avoid filling the disk with useless data).

control panel for triggered audio recorder

To configure the triggered recoder, select Options..Wave File Settings in SpecLab's main menu, on the panel labelled Triggered Audio Recorder (details in an extra document, please follow the link).

back to top


3. Wave File Analysis

To start or stop wave file analysis, use Spectrum Lab's main menu (under "File" ... "Audio Files & Streams" ).

Decide which of this file analysis modes you want to use by choosing the corresponding submenu. Then a file selector box opens in which you can select the audio file.

Note:
To analyse more than one file in a single over, use the CTRL- or shift-key in the file selector. This way you can select more than one file, like a little "play list".

After selecting one or more wave-file to be analysed, a dialog window appears where some parameters of the wave file are displayed. Some parameters (like the sample rate) can be adjusted for the following analysis.

The sample rate in a file is often different from the sample rate of the soundcard. For ELF work, the wave files are often decimated to a low sample rate to save disk space. For this reason, you often need a different FFT size to analyse files than for real-time analysis with the soundcard. Before the above dialog opens, the program calculates the best FFT size to achieve a similar frequency resolution as for real-time analysis. The resulting resolution is shown in the audio file analysis dialog (see screenshot above). If you are not satisfied with the FFT settings, you can modify the settings before clicking "OK" to start the file analysis.

While the analysis runs, the progress button shows the current playing time, the file name, and some other info.

Note: The file analysis without playback runs much faster than the real-time analysis. You can select "slow","medium" and "fast" analysis in the dialog, or on the "Wave Files" tab in the configuration dialog. The different "speeds" have the following effects (in fast file analysis mode only !):

Note: The option 'plotting the result in fast file analysis mode' was implemented in October 2004. It didn't work in older versions !

When finishing Fast File Analysis, the program will not automatically switch back to real-time operation (analyse samples from the soundcard), because you may want to analyse other files too, and see the result in the same spectrogram and/or plot of analysed data. To return to real-time processing with the soundcard, use the main menu, "Start/Stop"..."Start Audio Thread".

3.1 Other supported file formats (for input)

Besides the uncompressed wave file format, the program supports the following file formats for input (analysis):

3.2 Analysing 'Raw' (headerless) binary data files

These raw, uncompressed, headerless data files - for example, the output of a 16-bit DAC dumped into a file without any format conversion.

To analyse these files, you will need to fill out some additional fields in the 'File Analysis' dialog which automatically pops up after selecting the file:

back to top


4. Audio Playlist

Explained in a separate file .


5. Controlling audio files via interpreter commands

The recording and playback can be controlled by interpreter commands, for example through one of the programmable buttons in the left part of the main window. You can assign any function to a button, for example to start / stop a recording, or to temporarily pause replay / analysis.

A list of commands related with wave-audio file can be found in the file 'interpr.htm#wave_proc' . Here just an excerpt:

In addition, there's an extra set of commands for the Triggered Audio Recorder .


6. Wave files with 'I+Q' data (and the trouble with cos & sin or cos & -sin)

For software defined radio applications, the complex stream received from an external SDR, or the downconverted / decimated signal 'received' with a soundcard, can be saved as a stereo wave file.
By convention first seen in the SpectraVue software (software provided along with the SDR-IQ by RFspace), the convention for I/Q streams seems to be the same as used by the DDC (digital downconverter, here: an AD6620):

  1st channel ('left' audio channel) = 'I' : RF input multiplied by cos( omega * t) from the NCO
  2nd channel ('right' audio channel) = 'Q' : RF input multiplied by -sin( omega * t) from the NCO

      where   omega = complex angular frequency (in german: Kreisfrequenz) = 2 * pi * frequency 'f'

Note the negative sign before the oscillator's 'sine' output for the 'Q' channel !
Example: When recording an RF carrier at 77500 Hz, with the SDR's NCO (complex Numerically Controlled Oscillator) set to 77490 Hz, the recorded wave file would contain a signal at a baseband frequency of 77500 Hz - 77490 Hz = +10 Hz.
  (note the positive sign in this example - frequencies can be negative in the complex baseband, aka analytic signal)

Unfortunately, there doesn't seem to be an established 'standard' for storing I/Q samples in audio files. In other cases, the 'Q' (quadrature) component is multiplied by +sin(omega * t):

  1st channel ('left' audio channel) = 'I' : RF input multiplied by cos( omega * t) from the NCO
  2nd channel ('right' audio channel) = 'Q' : RF input multiplied by sin( omega * t) from the NCO

To accomodate both conventions, Spectrum Lab can be configured to read and write wave files with both 'polarities' for the Q-channel.
Due to a lack of space in various dialog screens, the SL author decided to call the 2nd format (with I=cos(omega*t), and Q=sin(omega*t) for a positive baseband frequency) I/-Q instead of I/Q. If, during analysis of an 'I / Q wave file' the frequencies appear mirrored in the spectrum display, try "I/-Q" instead of "I/Q".
Equivalent settings are available for recording as well as analysing I/Q wave files.

Wave files recorded by SpectraVue (and, most likely, similar SDR 'frontends') use the 'I/Q' settings.
For EbNaut and the vlfrx-tools by Paul Nicholson, use the 'I/-Q' setting instead.


7. Extra chunks in a wave file header (written by Spectrum Lab)

For certain applications (like the EbNaut wave recorder), it was necessary to embed some 'extra' information in wave files written by Spectrum Lab.

If this causes problems with other programs (which cannot skip such unknown chunks, like very old versions of Spectrum Lab..), you can turn off this feature in the configuration dialog .

The following 'extra' RIFF chunks may be written in wave audio files by Spectrum Lab, depending on the configuration :

"inf1" :  Info-Chunk #1
Contains  various "info" as an easily parseable text string (zero-terminated like a "C" string, variable length).
Format:  <token>=<value> (space delimited if more than one token/value pair exist in the string)
Example: sr=999.9937 rf=77400.0000 ut=1420973481.3155986 glat=52.1 glon=8.4 masl=108.9 kmh=0.0
Don't assume anything about the number of decimal places, and the parameter sequence.
Key to decode the string:
  sr= precise sampling rate (samples per second), "measured" or "calibrated".
  rf= radio frequency (useful if the recording contains downconverted, decimated I/Q samples.
        Sometimes added to the baseband frequency for the display)
  ut= Unix timestamp (seconds elapsed since 1970-01-01 00:00:00 UTC)
  glat= geographic latitude in degrees, positive north, negative south.
  glon= geographic longitude in degrees, positive east, negative west.
  masl= GPS height in meters above sea level. Only valid (and non-zero) if a GPS receiver is connected and operating .
  kmh= GPS speed in kilometers per hour .
Note: If no GPS receiver is connected, the lat/lon fields may still contain valid data. If GPS is not available (or not activated), the geographic position will be taken from the 'System Settings' .


8. Auxiliary files (to log "other data", like GPS, along with the audio files)

If a GPS is connected (and configured), there may be an auxiliary file (*.aux) written along with each audio file (*.wav). The auxiliary file will contain GPS coordinates, timestamps, and possibly some other data. If you don't need the AUX files, turn off the option 'save extra data in auxiliary files' on the 'Wave Files' tab in SL's configuration screen:

wave file settings

To change the interval in which GPS data are emitted to the aux file, modify the GPS output interval in the GPS configuration panel (see right image below, default is 1 second) :

Screenshot of the GPS Receiver Control Panel      

Except for the file extension, aux files have the same names as their corresponding wave audio files. Without auxiliary files, there will only be one single GPS position in an extra chunk ("inf1") of the wave file header.

All details about logging (exporting) GPS data along with audio files can be found in an extra document (gps_decoder.htm).
An example of an aux file with GPS- and additional data (added by means of an interpreter command) is here .


Last modified: 2015-12-13 .

Benötigen Sie eine deutsche Übersetzung ? Vielleicht hilft dieser Übersetzer - auch wenn das Resultat z.T. recht "drollig" ausfällt !
Avez-vous besoin d'une traduction en français ? Peut-être que ce traducteur vous aidera !

back to top