forked from yzyouzhang/AIR-ASVspoof
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeltas.m
executable file
·35 lines (26 loc) · 823 Bytes
/
deltas.m
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
function d = deltas(x, w)
% D = deltas(X,W) Calculate the deltas (derivatives) of a sequence
% Use a W-point window (W odd, default 9) to calculate deltas using a
% simple linear slope. This mirrors the delta calculation performed
% in feacalc etc. Each row of X is filtered separately.
% 2003-06-30 dpwe@ee.columbia.edu
if nargin < 2
w = 9;
end
[nr,nc] = size(x);
if nc == 0
% empty vector passed in; return empty vector
d = x;
else
% actually calculate deltas
% Define window shape
hlen = floor(w/2);
w = 2*hlen + 1;
win = hlen:-1:-hlen;
% pad data by repeating first and last columns
xx = [repmat(x(:,1),1,hlen),x,repmat(x(:,end),1,hlen)];
% Apply the delta filter
d = filter(win, 1, xx, [], 2); % filter along dim 2 (rows)
% Trim edges
d = d(:,2*hlen + [1:nc]);
end