/TimeScaleModification.jl

Time-scale modification for Julia

Primary LanguageJulia

TimeScaleModification.jl

CI codecov

The package implements time-scale modification algorithms to speed up or slow down an audio signal without alternating its pitch.

Installation

julia>]
pkg> add https://github.com/ymtoo/TimeScaleModification.jl.git

Usage

using Plots
using SignalAnalysis
using TimeScaleModification

fs = 96000
x = cw(5000, 0.5, fs) |> real |> collect
xburst = [repeat([eps()],10000);
          randn(1000);
          repeat([eps()],20000);
          randn(1000);
          repeat([eps()],16000)]

OLA

y = tsmodify(OLA(256,128,hanning), x, 1.5)
yburst = tsmodify(OLA(256,128,hanning), xburst, 1.5)

Sinusoidal signal

l = @layout [a b]
p1 = specgram(signal(x, fs); legend=:none, title="original")
p2 = specgram(signal(y, fs); ylabel="", legend=:none, title="time-scale modified")
plot(p1, p2; layout=l)

plot(signal(x[1:960], fs); legend=true, label="original")
plot!(signal(y[1:960], fs); legend=true, label="time-scale modified")

Burst signal

l = @layout [a b]
p1 = specgram(signal(xburst, fs); legend=:none, title="original")
p2 = specgram(signal(yburst, fs); ylabel="", legend=:none, title="time-scale modified")
plot(p1, p2; layout=l)

plot(signal(xburst, fs); legend=true, label="original")
plot!(signal(yburst, fs); legend=true, label="time-scale modified")

WSOLA

y = tsmodify(WSOLA(256,128,hanning,10), x, 1.5)
yburst = tsmodify(WSOLA(256,128,hanning,10), xburst, 1.5)

Sinusoidal signal

l = @layout [a b]
p1 = specgram(signal(x, fs); legend=:none, title="original")
p2 = specgram(signal(y, fs); ylabel="", legend=:none, title="time-scale modified")
plot(p1, p2; layout=l)

plot(signal(x[1:960], fs); legend=true, label="original")
plot!(signal(y[1:960], fs); legend=true, label="time-scale modified")

Burst signal

l = @layout [a b]
p1 = specgram(signal(xburst, fs); legend=:none, title="original")
p2 = specgram(signal(yburst, fs); ylabel="", legend=:none, title="time-scale modified")
plot(p1, p2; layout=l)

plot(signal(xburst, fs); legend=true, label="original")
plot!(signal(yburst, fs); legend=true, label="time-scale modified")

Phase Vocoder

y = tsmodify(PhaseVocoder(256,128,hanning,16,false,false,true), x, 1.5)
yburst = tsmodify(PhaseVocoder(256,128,hanning,16,false,false,true), xburst, 1.5)

Sinusoidal signal

l = @layout [a b]
p1 = specgram(signal(x, fs); legend=:none, title="original")
p2 = specgram(signal(y, fs); ylabel="", legend=:none, title="time-scale modified")
plot(p1, p2; layout=l)

plot(signal(x[1:960], fs); legend=true, label="original")
plot!(signal(y[1:960], fs); legend=true, label="time-scale modified")

Burst signal

l = @layout [a b]
p1 = specgram(signal(xburst, fs); legend=:none, title="original")
p2 = specgram(signal(yburst, fs); ylabel="", legend=:none, title="time-scale modified")
plot(p1, p2; layout=l)

plot(signal(xburst, fs); legend=true, label="original")
plot!(signal(yburst, fs); legend=true, label="time-scale modified")

Pitch shifting

xps = pitchshift(WSOLA(256,128,hanning,10), x, 6)
l = @layout [a b]
p1 = specgram(signal(x, fs); legend=:none, title="original")
p2 = specgram(signal(xps, fs); ylabel="", legend=:none, title="pitch-shifted")
plot(p1, p2; layout=l)

Time stretching

xburstts = timestretch(PhaseVocoder(256,128,hanning,16,false,false,true), xburst, 3; fixlen=false)
l = @layout [a b]
p1 = specgram(signal(xburst, fs); legend=:none, title="original")
p2 = specgram(signal(xburstts, fs); ylabel="", legend=:none, title="time-scaled")
plot(p1, p2; layout=l)

Reference

Driedger J, Müller M., "TSM Toolbox: MATLAB Implementations of Time-Scale Modification Algorithms", In DAFx, pp. 249-256. 2014.