Dan Ellis : Resources: Matlab:

# SKEWVIEW - Tool to visualize timing skew between files

`skewview` is a Matlab script that can be used to visualize the timing skew between two sound files. It breaks both files up into a set of short pieces (by default 4 seconds long) performs a normalized cross-correlation between corresponding pieces, then plots the time of the peak of this correlation as a function of time within the file. If the files contain versions of the same signal, the peak of the correlation will usually indicate the relative timing skew (delay) between the two files. This can be used to check for such a skew/delay.

`skewview` supports a range of input sound file formats, including WAV and FLAC (the latter provided via an external flac binary).

## Contents

- Example usage
- Optional arguments
- Compiled target usage
- Installation
- Changelog
- Acknowledgment

## Example usage

In the code below, we plot the timing skew between the two excerpted files, 20110221_1452+60.xr_lre.xxx.clean.flac (which is a clean source signal), and 20110221_1452+60.xr_lre.xxx.tsx300_tsx300.flac (which is the signal recorded after transmission across a radio link). The piecewise-constant time skew between the recordings is clearly shown. The (optional) later arguments in this case set the start and end times (in seconds) for the analysis.

    skewview('20110221_1452+60.xr_lre.xxx.clean.flac','20110221_1452+60.xr_lre.xxx.tsx300_tsx300.flac','-start',0,'-end',60);

    Reading 20110221_1452+60.xr_lre.xxx.clean.flac ...
    Reading 20110221_1452+60.xr_lre.xxx.tsx300_tsx300.flac ...
    Calculating short-time cross-correlation...
    Plotting...
    +++ SkewView v0.7 for 20110221_1452+60.xr_lre.xxx.tsx300_tsx300.flac
     ref=20110221_1452+60.xr_lre.xxx.clean.flac
     times start=0 end=60
     win=4 hop=0.5 maxlag=2 peakth=0.1
     MEDIAN LAG = -0.131 s, STDDEV = 0.308 s,  ABVTHRESH = 0.823

## Optional arguments

Behavior is controlled by optional arguments specified as param/value pairs:

    skewview -help

    skewview v0.7 of 20110909
    usage: skewview REFFILE TARGFILE [param value ...]
     where the param and value pairs can be:
    -start <time>  start analysis at this point in the files (0)
    -end   <time>  end analysis at this point in the files (end)
    -disp  <0/1>   generate graphical representation (1)
    -win   <time>  window length for xcorr analysis in sec (4.0)
    -hop   <time>  hop between successive windows in sec (0.5)
    -maxlag <time> largest lag time to consider (2.0)
    -peakth <val>  xcorr threshold to be considered a match (0.1)
    -initialdelay <time>  Center skew estimation around this delay (0.0)
    -samplerate <rate_hz> Downsample signals before correlation (0 = none)
    -pngout <name> Make a PNG-format screen dump of the plot (none)
    -textout <name> Write a text file of <time skew> pairs (none)

## Compiled target usage

Invoking the compiled target is the same as above, except without the punctuation e.g.

    ./run_skewview_prj.sh 20110221_1452+60.xr_lre.xxx.clean.flac 20110221_1452+60.xr_lre.xxx.tsx300_tsx300.flac -start 0 -end 60

## Installation

This package has been compiled for several targets using the Matlab compiler. You will also need to download and install the Matlab Compiler Runtime (MCR) Installer. Please see the table below:

Architecture | Compiled package | MCR Installer
--- | --- | ---
32 bit Linux | skewview_GLNX86.zip | Linux MCR Installer
64 bit Linux | skewview_GLNXA64.zip | Linux 64 bit MCR Installer
64 bit MacOS | skewview_MACI64.zip | MACI64 MCR Installer

The original Matlab code used to build this compiled target is available at

     <http://labrosa.ee.columbia.edu/projects/skewview/>

All sources are in the package skewview.zip.

Feel free to contact me with any problems.

## Changelog

2011-09-09 v0.7 Incorporated new audioread to allow efficient access to parts of very large files; added help message in program.

2011-09-06 v0.6 Modified audio reading code to better handle large/high SR files.

2011-08-03 v0.5 Added version number in text report output.

2011-07-19 v0.4 Added -textout option to allow raw text file dump of local skew times.

2011-05-03 v0.3 Added -initialdelay to handle files with large default skews, and -samplerate to specify an optional lower sampling rate at which to perform analysis, to accommodate much larger maximum lags and total file durations without exhausting memory.

2011-04-19 v0.2 Added text report of mean and SD of skew, and multiple command-line options to control the various internal parameters

2011-03-15 v0.1 Initial release

## Acknowledgment

This work was supported by DARPA under the RATS program via a subcontract from the SRI-led team SCENIC. My work was on behalf of ICSI.

Last updated: $Date: 2011/08/04 01:34:37 $ Dan Ellis dpwe@ee.columbia.edu