Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [372af6] Maximize Restore History

Fixes for #88 and #89.

prusa prusa 2013-08-28

changed comp/comp_wpfbt.m
changed testing/test_wfbt2filterbank.m
changed wavelets/wfbtmanip/nodesMultid.m
changed wavelets/wfbt2filterbank.m
changed wavelets/wfbtremove.m
copied wavelets/wpfbt2filterbank.m -> demos/demo_blockproc_denoising.m
comp/comp_wpfbt.m Diff Switch to side-by-side view
Loading...
testing/test_wfbt2filterbank.m Diff Switch to side-by-side view
Loading...
wavelets/wfbtmanip/nodesMultid.m Diff Switch to side-by-side view
Loading...
wavelets/wfbt2filterbank.m Diff Switch to side-by-side view
Loading...
wavelets/wfbtremove.m Diff Switch to side-by-side view
Loading...
wavelets/wpfbt2filterbank.m to demos/demo_blockproc_denoising.m
--- a/wavelets/wpfbt2filterbank.m
+++ b/demos/demo_blockproc_denoising.m
@@ -1,44 +1,68 @@
-function [g,a] = wpfbt2filterbank( wtdef, varargin)
-%WPFBT2FILTERBANK  WPFBT equivalent non-iterated filterbank
-%   Usage: [g,a] = wpfbt2filterbank(wtdef)
+function demo_blockproc_denoising(source,varargin)
+%DEMO_BLOCKPROC_DENOISING Variable coefficients thresholding
+%   Usage: demo_blockproc_denoising('gspi.wav')
 %
-%   Input parameters:
-%         wtdef : Wavelet filter tree definition
+%   For additional help call |demo_blockproc_denoising| without arguments.
 %
-%   Output parameters:
-%         g   : Cell array containing filters
-%         a   : Vector of sub-/upsampling factors
-%
-%   `wpfbtmultid(wtdef)` calculates the impulse responses *g* and the 
-%   subsampling factors *a* of non-iterated filterbank, which is equivalent
-%   to the wavelet filterbank tree described by *wtdef*. The returned 
-%   parameters can be used directly in |filterbank|, |ufilterbank| or 
-%   |filterbank|. 
-%   
-%   The filters are scaled if *a* is not returned. 
-%   
-%   See also: wfbtinit, wfbt2filterbank, filterbank
+%   The present demo allows you to set the coefficient threshold during the
+%   playback using the control panel.
+% 
+
+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},...
+               {'Thr','Treshold',0,0.1,0,1000}
+               });
+            
+%fobj = blockfigure();
+    
+% Buffer length
+bufLen = 1024;
+% Number of frequency channels
+M = 1000;
+
+% Setup blocktream
+if isoctave
+   fs=block(source,varargin{:},'L',bufLen);
+else
+   fs=block(source,varargin{:},'loadind',p,'L',bufLen);
+end
+
+% 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');
 
 
-if(nargin<1)
-    error('%s: Not enough input arguments',upper(mfilename));
+flag = 1;
+%Loop until end of the stream (flag) and until panel is opened
+while flag && p.flag
+   
+  % Obtain parameters from the control panel
+  gain = 10^(p.getParam('GdB')/20); % dB -> val
+  thres = p.getParam('Thr');
+  %bufLen = floor(p.getParam('bufLen'));
+
+  % Read block of length bufLen
+  [f,flag] = blockread(bufLen);
+  % Apply analysis frame
+  c = blockana(Fa, f*gain); 
+  % Plot
+  % blockplot(fobj,F,c);
+  % Apply thresholding
+  c = thresh(c,thres,'soft');
+  % Apply synthesis frame
+  fhat = real(blocksyn(Fs, c, size(f,1)));
+  % Play the block
+  %fhat = f;
+  blockplay(fhat);
 end
-
-% build the tree
-wt = wfbtinit({'strict',wtdef},varargin{:});
-
-wtPath = nodesBForder(wt);
-rangeLoc = cellfun(@(nEl) 1:numel(nEl.g),wt.nodes(wtPath),'UniformOutput',0);
-rangeOut = mat2cell(1:sum(rangeLocCount),1,...
-           cellfun(@(nEl) numel(nEl.g),wt.nodes(wtPath)));
-
-
-[g,a] = nodesMultid(wtPath,rangeLoc,rangeOut,wt);
-
-if nargout<2
-   % Scale filters if a is not returned
-   for nn=1:numel(g)
-       g{nn}.h = g{nn}.h/sqrt(a(nn));
-   end
-end
-
+% Close the control panel
+p.close();
+%fobj.close();