aboutsummaryrefslogtreecommitdiff
path: root/src/modules/audio_processing/aecm/main/matlab/matlab/getBspectrum.m
blob: a4a533d6001de5e461f950c03583b803c33fe7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function bspectrum=getBspectrum(ps,threshold,bandfirst,bandlast)
% function bspectrum=getBspectrum(ps,threshold,bandfirst,bandlast)
% compute binary spectrum using threshold spectrum as pivot
% bspectrum = binary spectrum (binary)
% ps=current power spectrum (float)
% threshold=threshold spectrum (float)
% bandfirst = first band considered
% bandlast = last band considered
  
% initialization stuff
  if( length(ps)<bandlast | bandlast>32 | length(ps)~=length(threshold)) 
  error('BinDelayEst:spectrum:invalid','Dimensionality error');
end

% get current binary spectrum
diff = ps - threshold;
bspectrum=uint32(0);
for(i=bandfirst:bandlast)
  if( diff(i)>0 ) 
    bspectrum = bitset(bspectrum,i);
  end
end