23
Zdenˇ ek Pr˚ sa Acoustics Research Institute, Austrian Academy of Sciences OctConf 2013, June 25, 2013

Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Zdenek Prusa

Acoustics Research Institute, Austrian Academy of Sciences

OctConf 2013, June 25, 2013

Page 2: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Overview

Wavelets in the LTFAT.

Real-time audio block-stream processing framework.

Example of a real-time audio wavelet processing inOctave.

Zdenek Prusa http://ltfat.sourceforge.net/

2/ 23

Page 3: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Introduction

LTFAT is a modern Octave/Matlab toolbox for doingtime/frequency, wavelet and frame analysis.

Started in 2004 by Peter L. Søndergaard. Version 1.0 released in2011.

Its purposes are:

To support teaching and learning in Fourier analysis, harmonicanalysis and digital signal processing.To provide a tested and documented toolbox of such qualitythat it can be used for new scientific developments.As a method for engineers and researchers to quickly try out amethod/transform.As a method for researchers to push their discoveries to alarger audience.

Zdenek Prusa http://ltfat.sourceforge.net/

3/ 23

Page 4: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Time-frequency representation example

Zdenek Prusa http://ltfat.sourceforge.net/

4/ 23

Page 5: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Features

Basic Fourier analysis and signal processing, FIR windows

Discrete Gabor transform and its inverse

Time-frequency bases: Wilson and WMDCT

Filterbanks and non-stationary Gabor systems

Reassignment (sharpening) and instantaneous frequencyestimation

Non-linear analysis and synthesis methods

Backend in C linked to OCT interfaces.

(NEW) Discrete Wavelet Transform

(NEW) Block-stream processing framework

. . .

Zdenek Prusa http://ltfat.sourceforge.net/

5/ 23

Page 6: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Wavelets in the LTFAT overview

fwt – Discrete Wavelet Transform (Mallat’s algorithm)

ufwt – Undecimated fwt (A-trous algorithm).

wfbt/uwfbt – (Undecimated) Arbitrary tree-shaped Waveletfilterbank.

wpfbt/uwpfbt – (Undecimated) Arbitrary tree-shapedWavelet filterbank.

wpbest – Best basis selection from bases derived from thewavelet packet.

fwt2 – Basic 2D Discrete wavelet transform.

Wavelet filters library.

Plotting routines.

Zdenek Prusa http://ltfat.sourceforge.net/

6/ 23

Page 7: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

DWT as a matrix multiplication

c = f

f = c

Daubechies 4, 3 scale levels, N = 64

Zdenek Prusa http://ltfat.sourceforge.net/

7/ 23

Page 8: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

DWT as a filterbank

f b

h4

h3

h2

h1 ↓8

↓8

↓4

↓2

f

g4

g3

g2

g1c1

c2

c3

c4

↑8

↑8

↑4

↑2

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

2.5

3

|G4(ω)|

|G3(ω)|

|G2(ω)|

|G1(ω)|

ω[π · rad] →

|G(ω

)|→

0 5 10 15 20 25 30 35 40 45 50−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

1.2

g4

g3

g2

g1

n →

g[n]→

Daubechies 4, 3 scale levels.

To ufwtZdenek Prusa http://ltfat.sourceforge.net/

8/ 23

Page 9: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Fast Wavelet Transform

↓2

↓2

↓2

↓2

↓2

↓2

f b

h1

h2

b

h1

h2

h1

h2

b

c4

c3

c1

c2

f

g1

g2c4

g1

g2c3

g1

g2

c1

c2

↑2

↑2

↑2

↑2

↑2

↑2

Mallat’s fast algorithm, h1/h2 (g1/g2) – lowpass/highpass filters.

Zdenek Prusa http://ltfat.sourceforge.net/

9/ 23

Page 10: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Fast Wavelet Transform – fwt/ifwt

Example:

c = fwt(f,’db4’,3);

fhat = ifwt(c,’db4’,3,size(f,1));

Other filterbank constructions with different number of filters inthe basic filterbank. Offers more convenient filters.

db4, 3 levels

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

2.5

3

dden2, 3 levels

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

2.5

3

Zdenek Prusa http://ltfat.sourceforge.net/

10/ 23

Page 11: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Fast Undecimated Wavelet Transform

f b

h1

h2

b

↑2h1

↑2h2

↑4h1

↑4h2

b

f

g1

g2c4

↑2g1

↑2g2c3

↑4g1

↑4g2

c1

c2

A-trous algorithm, h1/h2 (g1/g2) – lowpass/highpass filters, ↑N –upsampling by factor of N

Zdenek Prusa http://ltfat.sourceforge.net/

11/ 23

Page 12: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Undec. Wavelet Transform – ufwt/iufwt

c = f , f = c

Example:

c = ufwt(f,’db4’,3);

fhat = iufwt(c,’db4’,3);

Highly redundant, shift-independent transform.

To fwt

Zdenek Prusa http://ltfat.sourceforge.net/

12/ 23

Page 13: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Arbitrary Wavelet filterbank – wfbt/iwfbt

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2f b

h1

h2

b

h1

h2

h1

h2

b

h1

h2

b

h1

h2

b

h1

h2

b

h1

h2

b

c1

c2

c3

c4

c5

c6

c7

c8

Example of a full 3 level tree:

c = wfbt(f,{’db4’,3,’full’});

fhat = iwfbt(c,{’db4’,3,’full’},size(f,1));

Zdenek Prusa http://ltfat.sourceforge.net/

13/ 23

Page 14: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Arbitrary Wavelet filterbank – wfbt/iwfbt

c = f , f = c

Allows flexible frequency covering via splitting further thehigh-pass output.

db4, 3 levels

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

2.5

3

Zdenek Prusa http://ltfat.sourceforge.net/

14/ 23

Page 15: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Wavelet Packet filterbank – wpfbt/iwpfbt

c = f , f = c

Example of a full 3 level tree:

c = wpfbt(f,{’db4’,3,’full’});

fhat = iwpfbt(c,{’db4’,3,’full’},size(f,1));

Zdenek Prusa http://ltfat.sourceforge.net/

15/ 23

Page 16: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Best subtree – wpbest

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

↓2

f b

h1

h2

b

h1

h2

h1

h2

b

h1

h2

b

h1

h2

b

c1

c2

c3

c4

c5

c6

Example

[c,wt] = wpbest(f,’db4’,3,’entropy’,’shannon’);

fhat = iwfbt(c,wt,size(f,1));

Zdenek Prusa http://ltfat.sourceforge.net/

16/ 23

Page 17: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Best subtree – wpbest

c = f , f = c

db4, 3 levels

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 10

0.5

1

1.5

2

2.5

3

Zdenek Prusa http://ltfat.sourceforge.net/

17/ 23

Page 18: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Real-time audio processing in LTFAT

Simple framework for a non-blocking real-time audioprocessing and playback.

Based on Playrec (http://www.playrec.co.uk/) MEXinterface to Portaudio library(http://www.portaudio.com/).

Takes input from a sound file or any audio input (microphone,line-in) and routes to any output device (speakers, line-out)allowing processing sample blocks on-the-fly.

Zdenek Prusa http://ltfat.sourceforge.net/

18/ 23

Page 19: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Real-time audio processing in LTFAT cont.

Example:

block(’gspi.wav’); % Input is a wav file.

% block(’playrec’); % Input is an microphone.

% Setup GUI control panel containing one slider.

p = blockpanel({’GdB’,’Gain’,-20,20,0,21});

while p.flag

% Obtain parameter from a GUI

gain = 10^(p.getParam(’GdB’)/20);

% Read 1024 samples from the input

f = blockread(1024);

% Enqueue samples to be played

blockplay(f*gain);

end

p.close();

Page 20: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

SegDWT (Prusa, Rajmic 2012)

Avoiding block-artifacts after coefficient manipulation.

x[n]

y [n]

90 275

14

16

2117

21

15

17

45

22

11

11

6

2

46

23

11

11

7

2

46

23

12

12

9

3

47

24

12

12

7

2

0 183 369

16

0 90 275183 36921

Currently only fwt/ifwt routines are supported. The plan is toextend the idea of SegDWT to more filterbank types.

Zdenek Prusa http://ltfat.sourceforge.net/

20/ 23

Page 21: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

SegDWT example

block(’gspi.wav’); % block(’playrec’);

F = frame(’fwt’,’sym8’,4);

% Setup GUI control panel containing two sliders.

p = blockpanel({{’GdB’,’Gain’,-20,20,0,21},...

{’Thr’,’Treshold’,0,0.1,0,1000}});

while p.flag

% Get the current slider value.

gain = 10^(p.getParam(’GdB’)/20);

thres = p.getParam(’Thr’);

% Read 1024 samples of the input and process.

f = blockread(1024);

c = blockana(F, f*gain);

c = thresh(c,thres,’soft’);

fhat = blocksyn(F, c, size(f,1));

% Enqueue the samples to be played.

blockplay(fhat);

end

p.close();

Page 22: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Wavelet-related plans

Long standing inclusion request from YAWTBhttp://sites.uclouvain.be/ispgroup/yawtb/.

(Discretized) Continuous Wavelet Transfom – CWT (Morlet,Mexican hat, . . . ).Directional ”framed” 2D Wavelet Transform.Wavelet transform on a sphere.

General Wavelets frames.

Making LTFAT a proper Octave package ;)

Zdenek Prusa http://ltfat.sourceforge.net/

22/ 23

Page 23: Zdenˇek Pr˚uˇsa Acoustics Research ... - GNU Octave Wikiwiki.octave.org/wiki/images/0/0c/Slides_octconf_zdenel_prusa.pdf · LTFAT is a modern Octave/Matlab toolbox for doing time/frequency,

Thank you for listening.

http://ltfat.sourceforge.net/