-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSFsparse2Env.m
More file actions
49 lines (41 loc) · 1.11 KB
/
Copy pathSFsparse2Env.m
File metadata and controls
49 lines (41 loc) · 1.11 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
function [ env_f, env_x ] = SFsparse2Env( sampled, r, tqs, maxenv, srate )
%SFMAKEENVR based on envelope samples, compute fixed and max envs
% sampled are the envelope samples
% r is the correction factor
% tqs is the threshold in quiet
% maxenv are the transcoded pulses
% srate is the per-channel sampling rate
% (c) Joachim Thiemann 2010
% for full license details see RunThesisCode.m
% and http://creativecommons.org/licenses/by/3.0/
[M,L] = size(sampled);
% get list of pulses
[mI,tI] = find(sampled>0);
Le = size(maxenv,2);
env_f = zeros(M,L);
env_x = zeros(M,L);
% find the peak of the transcoded env
offsets = zeros(M,1);
for m=1:M
[~, offsets(m)] = max(maxenv(m,:,m));
env_x(m,:) = tqs(m);
end
K = length(mI);
for k=1:K
m = mI(k);
t = tI(k);
a = sampled(m,t);
if (t<offsets(m)) || (t>(L-offsets(m)))
continue
end
sr2 = floor(srate(m)/2);
trange = -sr2:sr2;
env_f(m,trange+t) = a;
trange = (1:Le)-offsets(m);
env_x(:,trange+t) = max(env_x(:,trange+t),r*a*maxenv(:,:,m));
if mod(k,1000)==0
fprintf('.');
end
end
fprintf('\n');
end