using UnderwaterAcoustics
using MAT
using Plots
ch = BasebandReplayChannel("uacr://red_1")Channel replay
Quickstart guide
The idea of channel replay was popularized in the underwater domain by the Watermark benchmark. The essential idea is to extract estimates of time-varying impulse response (TVIR) from measurements at sea, and to convolve it with a new signals to estimate what would have been received had that signal been transmitted during the measurement.
Loading a replay channel
To do channel replay using UnderwaterAcoustics.jl, we build a AbstractAcousticChannel from the measured TVIR using the BasebandReplayChannel() constructor. It can either take in a TVIR as a matrix or load a TVIR from a file or URL, e.g. uacr://red_1 for red_1.mat in version 1.0 of the UACR. Downloaded files are cached in $XDG_CACHE_HOME/UnderwaterAcoustics.jl (or ~/.cache/UnderwaterAcoustics.jl) on Linux and macOS, and in %LOCALAPPDATA%\UnderwaterAcoustics.jl\cache on Windows; the cache keyword argument sets another directory. Loading from a .mat file requires the MAT package to be loaded:
BasebandReplayChannel(3 × 47.8 s, 25000.0 Hz, 19200.0 Sa/s)
This channel has 3 receiving hydrophones and can replay up to 47.8 seconds of signal through the measured TVIR. The signal must fit within the frequency band that was used to probe the channel (for the red channel it is 25 ± 4.8 kHz).
We can visualize the TVIR for the first hydrophone by plotting it:
plot(ch)If we were interested in the second hydrophone, we could specify the hydrophone number to plot:
plot(ch, 2)Simulating a transmission
To pass a signal through the channel, we generate a signal and transmit() it just like through any other AbstractAcousticChannel:
using SignalAnalysis
x = cw(25000, 0.001, 192000; window=(tukey, 0.5)) |> real
y = transmit(ch, x; start=1)SampledSignal @ 192000.0 Hz, 7865×3 Matrix{Float64}:
-3.75082e-5 -0.000456731 -0.00029653
3.17797e-5 -0.00076475 -0.000410091
0.000120401 -0.000584061 -0.000242704
0.000170586 0.000127108 0.000178298
0.000118633 0.000986574 0.000608432
-6.91028e-5 0.00134971 0.000704595
-0.000295855 0.000833567 0.000335784
-0.000407201 -0.000438652 -0.000374343
-0.000266928 -0.00170954 -0.000992745
0.000125123 -0.00203684 -0.00105123
⋮
-3.56313e-6 -7.64416e-6 3.7483e-6
-3.22116e-6 -1.94038e-7 -3.23311e-6
-1.38939e-6 3.17671e-6 -4.44571e-6
1.87141e-8 2.07634e-6 -1.89661e-6
-0.0 -0.0 -0.0
-8.11036e-7 -7.35345e-8 -7.43043e-7
-1.06796e-6 1.68019e-6 -2.51219e-6
-1.94935e-7 2.982e-6 -2.7021e-6
1.09265e-6 2.23162e-6 -6.86318e-7
We have 3 channels of received data since we have 3 hydrophones in the replay TVIR. We plot the transmitted signal and the first 5 ms of the replayed received signal (hydrophone 2):
plot(
plot(x; xlims=(0,5)),
plot(y[:,2]; xlims=(0,5));
layout=(2,1)
)Adding noise
We can also simulate channels with noise. For example, if we wanted white Gaussian noise with standard deviation σ = 0.1, we can specify that when loading the channel:
ch = BasebandReplayChannel("uacr://red_1"; noise=WhiteGaussianNoise(0.1))y = transmit(ch, x; start=1)
plot(
plot(x; xlims=(0,5)),
plot(y[:,2]; xlims=(0,5));
layout=(2,1)
)