comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/@mirenvelope/mirplay.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function mirplay(e,varargin)
2
3 % mirplay method for mirenvelope objects. Help displayed in ../mirplay.m
4
5 ch.key = 'Channel';
6 ch.type = 'Integer';
7 ch.default = 0;
8 option.ch = ch;
9
10 sg.key = 'Segment';
11 sg.type = 'Integer';
12 sg.default = 0;
13 option.sg = sg;
14
15 se.key = 'Sequence';
16 se.type = 'Integer';
17 se.default = 0;
18 option.se = se;
19
20 inc.key = 'Increasing';
21 inc.type = 'MIRtb';
22 option.inc = inc;
23
24 dec.key = 'Decreasing';
25 dec.type = 'MIRtb';
26 option.dec = dec;
27
28 every.key = 'Every';
29 every.type = 'Integer';
30 option.every = every;
31
32 burst.key = 'Burst';
33 burst.type = 'Boolean';
34 burst.default = 1;
35 option.burst = burst;
36
37 specif.option = option;
38
39 specif.eachchunk = 'Normal';
40
41 varargout = mirfunction(@mirplay,e,varargin,nargout,specif,@init,@main);
42 if nargout == 0
43 varargout = {};
44 end
45
46
47 function [x type] = init(x,option)
48 type = '';
49
50
51 function noargout = main(a,option,postoption)
52 if iscell(a)
53 a = a{1};
54 end
55 d = get(a,'Data');
56 f = get(a,'Sampling');
57 n = get(a,'Name');
58 c = get(a,'Channels');
59 fp = get(a,'FramePos');
60 if not(option.se)
61 if length(d)>1
62 if isfield(option,'inc')
63 [unused order] = sort(mirgetdata(option.inc));
64 elseif isfield(option,'dec')
65 [unused order] = sort(mirgetdata(option.dec),'descend');
66 else
67 order = 1:length(d);
68 end
69 if isfield(option,'every')
70 order = order(1:option.every:end);
71 end
72 else
73 order = 1;
74 end
75 else
76 order = option.se;
77 end
78 if not(isempty(order))
79 for k = order(:)'
80 display(['Playing envelope of file: ' n{k}])
81 dk = d{k};
82 if not(iscell(dk))
83 dk = {dk};
84 end
85 if option.ch
86 if isempty(c{k})
87 chk = option.ch;
88 else
89 [unused unused chk] = intersect(option.ch,c{k});
90 end
91 else
92 chk = 1:size(dk{1},3);
93 end
94 if isempty(chk)
95 display('No channel to play.');
96 end
97 for l = chk
98 if chk(end)>1
99 display([' Playing channel #' num2str(l)]);
100 end
101 if option.sg
102 sgk = option.sg(find(option.sg<=length(dk)));
103 else
104 sgk = 1:length(dk);
105 end
106 for i = sgk
107 if sgk(end)>1
108 display([' Playing segment #' num2str(i)])
109 end
110 di = dk{i};
111 for j = 1:size(di,2)
112 djl = resample(di(:,j,l),11025,round(f{k}));
113 djl = djl/max(djl);
114 djl = rand(length(djl),1).*djl;
115 sound(djl,11025);
116 idealtime = length(djl)/11025;
117 practime = toc;
118 if practime < idealtime
119 pause(idealtime-practime)
120 end
121 end
122 if option.burst && sgk(end)>1
123 sound(rand(1,10))
124 end
125 end
126 end
127 end
128 end
129 noargout = {};