comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/@miraudio/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 varargout = mirplay(a,varargin)
2
3 % mirplay method for miraudio 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,a,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 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 tic
113 sound(di(:,j,l),f{k});
114 idealtime = size(di,1)/f{k};
115 practime = toc;
116 if practime < idealtime
117 pause(idealtime-practime)
118 end
119 end
120 if option.burst && sgk(end)>1
121 sound(rand(1,10))
122 end
123 end
124 end
125 end
126 end
127 noargout = {};