Semi-Constant-Q Dyadic Filter BankΒΆ

using NBInclude
using Plots
@nbinclude("GPUFilterBanks.ipynb");
@nbinclude("AudioTools.ipynb");
tetris = load("korobeiniki.wav");
fs = round(Int,tetris.samplerate);
original = audio_to_float( truncate_audio(tetris.data,nextpow(2,10*fs)) );
float_to_audio(original,fs)
num_octaves = 10;

filters = [
    WT.makeqmfpair(wavelet(WT.haar)),
    WT.makereverseqmfpair(wavelet(WT.haar))
];
LA = tensor(Float32.(filters[1][1]));
HA = tensor(Float32.(filters[1][2]));
LS = tensor(Float32.(filters[2][1]));
HS = tensor(Float32.(filters[2][2]));

x = [tensor(original)];

size.(x)
1-element Vector{NTuple{4, Int64}}:
 (524288, 1, 1, 1)
y = analysis_filterbank(x, LA, HA)
size.(y)
11-element Vector{NTuple{4, Int64}}:
 (8192, 32, 1, 1)
 (4096, 32, 1, 1)
 (2048, 32, 1, 1)
 (1024, 32, 1, 1)
 (512, 32, 1, 1)
 (256, 32, 1, 1)
 (128, 32, 1, 1)
 (64, 32, 1, 1)
 (32, 32, 1, 1)
 (16, 32, 1, 1)
 (16, 32, 1, 1)
S1 = [];
for octave ∈ 1:(num_octaves+1)
    y_i = collect(y[octave]);
    h = heatmap(abs.(y_i[:,:]'), 
        axis=nothing, colorbar=nothing, size=(1000,2000));
    append!(S1,[h]);
end
l = @layout [p1;p2;p3;p4;p5;p6;p7;p8;p9;p10;p11];
plot(S1..., layout=l)
_images/dyadic_6_0.svg
x = synthesis_filterbank(y, LS, HS)
size.(x)
1-element Vector{NTuple{4, Int64}}:
 (524288, 1, 1, 1)
float_to_audio(collect(x[1][:]),fs)