-
Notifications
You must be signed in to change notification settings - Fork 0
/
mctranslate.m
73 lines (64 loc) · 1.92 KB
/
mctranslate.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
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
function d2 = mctranslate(d, X)
% Translates motion-capture data by a vector.
%
% syntax
% d2 = mctranslate(d, X);
%
% input parameters
% d: MoCap structure or data matrix
% X: translation vector
%
% output
% d2: MoCap structure or data matrix
%
% examples
% d2 = mctranslate(d, [0 1000 0]);
%
% Part of the Motion Capture Toolbox, Copyright 2008,
% University of Jyvaskyla, Finland
d2=[];
if nargin<2
disp([10, 'Not enough input arguments.', 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return;
end
if ~isnumeric(X) %kn2020-05-22 edit to allow framewise translation
disp([10, 'The second argument has to be numeric.' 10])
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
return
end
if length(X)==3 %kn2020-05-22 edit to allow framewise translation
if isfield(d,'type') && strcmp(d.type, 'MoCap data')
d2 = d;
d2.data(:,1:3:end) = d2.data(:,1:3:end) + X(1);
d2.data(:,2:3:end) = d2.data(:,2:3:end) + X(2);
d2.data(:,3:3:end) = d2.data(:,3:3:end) + X(3);
elseif isnumeric(d)
d2 = d;
d2(:,1:3:end) = d(:,1:3:end) + X(1);
d2(:,2:3:end) = d(:,2:3:end) + X(2);
d2(:,3:3:end) = d(:,3:3:end) + X(3);
else
disp([10, 'The first input argument has to be a variable with MoCap or norm data structure.', 10]);
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
end
else %kn2020-05-22 edit to allow framewise translation
if isfield(d,'type') && strcmp(d.type, 'MoCap data')
d2 = d;
d2.data(:,1:3:end) = d2.data(:,1:3:end) + X(:,1);
d2.data(:,2:3:end) = d2.data(:,2:3:end) + X(:,2);
d2.data(:,3:3:end) = d2.data(:,3:3:end) + X(:,3);
elseif isnumeric(d)
d2 = d;
d2(:,1:3:end) = d(:,1:3:end) + X(:,1);
d2(:,2:3:end) = d(:,2:3:end) + X(:,2);
d2(:,3:3:end) = d(:,3:3:end) + X(:,3);
else
disp([10, 'The first input argument has to be a variable with MoCap or norm data structure.', 10]);
[y,fs] = audioread('mcsound.wav');
sound(y,fs);
end
end