[7c7a96]: demos / demo_blockproc_dgtequalizer.m Maximize Restore History

Download this file

demo_blockproc_dgtequalizer.m    79 lines (59 with data), 2.0 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function demo_blockproc_dgtequalizer(source,varargin)
%DEMO_BLOCKPROC_DGTEQUALIZER Real-time audio manipulation in the transform domain
% Usage: demo_blockproc_dgtequalizer('gspi.wav')
%
% For additional help call |demo_blockproc_dgtequalizer| without arguments.
%
% This script demonstrates a real-time Gabor coefficient manipulation.
% Frequency bands of Gabor coefficients are multiplied (weighted) by
% values taken from sliders having a similar effect as a octave equalizer.
% The shown spectrogram is a result of a re-analysis of the synthetized
% block to show a frequency content of what is actually played.
%
if demo_blockproc_header(mfilename,nargin)
return;
end
M = 1000;
fobj = blockfigure();
octaves = 6;
voices = 1;
eqbands = (octaves)*voices;
d = floor((floor(M/2)+1)*2.^(-(0:eqbands-1)./(voices)));
d = fliplr([d,0]);
% Basic Control pannel (Java object)
parg = {{'GdB','Gain',-20,20,0,21}};
for ii=1:eqbands
parg{end+1} = {sprintf('G%idB',ii),sprintf('band%i',ii),-20,20,0,21};
end
p = blockpanel(parg);
bufLen = 1024;
% Setup blocktream
fs=block(source,varargin{:},'loadind',p,'L',bufLen);
% Window length in ms
winLenms = 20; %floor(fs*winLenms/1e3)
[F,Fdual] = framepair('dgtreal',{'hann',floor(fs*winLenms/1e3)},'dual',40,M);
[Fa,Fs] = blockframepairaccel(F,Fdual, bufLen,'segola');
flag = 1;
ola = [];
ola2 = [];
%Loop until end of the stream (flag) and until panel is opened
while flag && p.flag
gain = blockpanelget(p);
gain = 10.^(gain/20);
[f,flag] = blockread();
f=f*gain(1);
gain = gain(2:end);
[c, ola] = blockana(Fa, f, ola);
cc = framecoef2tf(Fa,c);
% Do the weighting
for ii=1:eqbands
cc(d(ii)+1:d(ii+1),:,:) = gain(ii)*cc(d(ii)+1:d(ii+1),:,:);
end
c = frametf2coef(Fa,cc);
fhat = blocksyn(Fs, c, size(f,1));
blockplay(fhat);
% Do re-analysis of the modified
[c2, ola2] = blockana(Fa, fhat, ola2);
blockplot(fobj,Fa,c2(:,1));
end
blockdone(p,fobj);