mathieu@14
|
1 function [scoreEvent] = addUserOffsets(template,scoreEvent,timeMode,ebrMode)
|
mathieu@14
|
2
|
mathieu@14
|
3 % This program was written by Mathias Rossignol & Grégoire Lafay
|
mathieu@14
|
4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr>
|
mathieu@14
|
5 %
|
mathieu@14
|
6 % This program is free software: you can redistribute it and/or modify it
|
mathieu@14
|
7 % under the terms of the GNU General Public License as published by the Free
|
mathieu@14
|
8 % Software Foundation, either version 3 of the License, or (at your option)
|
mathieu@14
|
9 % any later version.
|
mathieu@14
|
10 %
|
mathieu@14
|
11 % This program is distributed in the hope that it will be useful, but
|
mathieu@14
|
12 % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
mathieu@14
|
13 % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
mathieu@14
|
14 % for more details.
|
mathieu@14
|
15 %
|
mathieu@14
|
16 % You should have received a copy of the GNU General Public License along
|
mathieu@14
|
17 % with this program. If not, see <http://www.gnu.org/licenses/>.
|
mathieu@14
|
18
|
mathieu@14
|
19 %% Create userOffsets matrix
|
mathieu@14
|
20 userOffset=zeros(length(template),4);
|
mathieu@14
|
21
|
mathieu@14
|
22 if length(scoreEvent)==1 && strcmp('',scoreEvent{1}{1}) % add the same offset to all the classes
|
mathieu@14
|
23 userOffset=[repmat(scoreEvent{1}{3},length(template),1) repmat(scoreEvent{1}{4},length(template),1) repmat(scoreEvent{1}{5},length(template),1) repmat(scoreEvent{1}{6},length(template),1)];
|
mathieu@33
|
24 fprintf(2, 'score.event if of length 1: classId will set to the class labels of the scene to replicate.\n')
|
mathieu@14
|
25 else % add class wise offsets
|
mathieu@14
|
26 for jj=1:length(scoreEvent) scoreEventClass{jj}=scoreEvent{jj}{1}; end;
|
mathieu@14
|
27 for ii=1:length(template)
|
mathieu@14
|
28 indClass=find(strcmp(template{ii}{1},scoreEventClass));
|
mathieu@14
|
29 if ~isempty(indClass)
|
mathieu@14
|
30 userOffset(ii,1:4)=[scoreEvent{indClass}{3} scoreEvent{indClass}{4} scoreEvent{indClass}{5} scoreEvent{indClass}{6}];
|
mathieu@14
|
31 if ~strcmp('',scoreEvent{indClass}{2})
|
mathieu@14
|
32 template{ii}{2}=scoreEvent{indClass}{2};
|
mathieu@14
|
33 end
|
mathieu@14
|
34 if scoreEvent{indClass}{7} ~= 0 % change class start time
|
mathieu@14
|
35 template{ii}{7}= scoreEvent{indClass}{7};
|
mathieu@14
|
36 end
|
mathieu@14
|
37 if scoreEvent{indClass}{8} ~= 0 % change class end time
|
mathieu@14
|
38 template{ii}{8}= scoreEvent{indClass}{8};
|
mathieu@14
|
39 end
|
mathieu@14
|
40 if scoreEvent{indClass}{9} ~= 0 % change fade in time
|
mathieu@14
|
41 template{ii}{9}= scoreEvent{indClass}{9};
|
mathieu@14
|
42 end
|
mathieu@14
|
43 if scoreEvent{indClass}{10} ~= 0 % change fade out time
|
mathieu@14
|
44 template{ii}{10}= scoreEvent{indClass}{10};
|
mathieu@14
|
45 end
|
mathieu@14
|
46 else
|
mathieu@14
|
47 userOffset(ii,1:4)=zeros(1,4);
|
mathieu@14
|
48 end
|
mathieu@14
|
49 end
|
mathieu@14
|
50 end
|
mathieu@14
|
51
|
mathieu@14
|
52 %% add user offsets to time
|
mathieu@14
|
53 switch timeMode
|
mathieu@14
|
54 case 'abstract'
|
mathieu@14
|
55 for ii=1:length(template)
|
mathieu@14
|
56 template{ii}{5}=template{ii}{5}+userOffset(ii,3);
|
mathieu@14
|
57 template{ii}{6}=template{ii}{6}+userOffset(ii,4);
|
mathieu@14
|
58 end
|
mathieu@14
|
59 end
|
mathieu@14
|
60
|
mathieu@14
|
61 %% add user offsets to ebr
|
mathieu@14
|
62 switch ebrMode
|
mathieu@14
|
63 case 'generate'
|
mathieu@14
|
64 for ii=1:length(template)
|
mathieu@14
|
65 template{ii}{3}=userOffset(ii,1);
|
mathieu@14
|
66 template{ii}{4}=userOffset(ii,2);
|
mathieu@14
|
67 end
|
mathieu@14
|
68 case 'abstract'
|
mathieu@14
|
69 for ii=1:length(template)
|
mathieu@14
|
70 template{ii}{3}=template{ii}{3}+userOffset(ii,1);
|
mathieu@14
|
71 template{ii}{4}=template{ii}{4}+userOffset(ii,2);
|
mathieu@14
|
72 end
|
mathieu@14
|
73 case 'replicate'
|
mathieu@14
|
74 for ii=1:length(template)
|
mathieu@14
|
75 template{ii}{13}=template{ii}{13}+userOffset(ii,1)+randn(length(template{ii}{13}),1)*userOffset(ii,2);
|
mathieu@14
|
76 template{ii}{3}=mean(template{ii}{13});
|
mathieu@14
|
77 template{ii}{4}=std(template{ii}{13});
|
mathieu@14
|
78 end
|
mathieu@14
|
79 end
|
mathieu@14
|
80
|
mathieu@14
|
81 scoreEvent=template;
|
mathieu@14
|
82
|