Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[3deeb5]: demos / demo_blockproc_erblets.m Maximize Restore History

Download this file

demo_blockproc_erblets.m    62 lines (48 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function demo_blockproc_erblets(source,varargin)
%DEMO_BLOCKPROC_ERBLETS Basic real-time rolling erblet-spectrogram visualization
% Usage: demo_blockproc_erblets('gspi.wav')
%
% For additional help call |demo_blockproc_erblets| without arguments.
%
% This demo shows a simple rolling erblet-spectrogram of whatever is specified in
% source.
if demo_blockproc_header(mfilename,nargin)
return;
end
% Control pannel (Java object)
% Each entry determines one parameter to be changed during the main loop
% execution.
p = blockpanel({
{'GdB','Gain',-20,20,0,21},...
});
fobj = blockfigure();
% Buffer length
% Larger the number the higher the processing delay. 1024 with fs=44100Hz
% makes ~23ms.
% The value can be any positive integer.
% Note that the processing itself can introduce additional delay.
bufLen = 1024;
% Setup blocktream
fs=block(source,varargin{:},'loadind',p,'L',bufLen);
% Number of filters
M = 200;
[g,a]=erbfilters(fs,'fractional','L',2*bufLen,'M',M,'real');
[F,Fdual] = framepair('filterbankreal','dual',g,a,size(a,1));
[Fa,Fs] = blockframepairaccel(F,Fdual,bufLen,'sliced');
flag = 1;
%Loop until end of the stream (flag) and until panel is opened
while flag && p.flag
% Get parameters
gain = blockpanelget(p,'GdB');
gain = 10^(gain/20);
% Read block of length bufLen
[f,flag] = blockread();
f = f*gain;
% Apply analysis frame
c = blockana(Fa, f);
% Plot
blockplot(fobj,Fa,c(:,1));
fhat = real(blocksyn(Fs, c, size(f,1)));
blockplay(fhat);
end
blockdone(p,fobj,Fa,Fs);