wolffd@0: function varargout = mirplay(a,varargin) wolffd@0: wolffd@0: % mirplay method for miraudio objects. Help displayed in ../mirplay.m wolffd@0: wolffd@0: ch.key = 'Channel'; wolffd@0: ch.type = 'Integer'; wolffd@0: ch.default = 0; wolffd@0: option.ch = ch; wolffd@0: wolffd@0: sg.key = 'Segment'; wolffd@0: sg.type = 'Integer'; wolffd@0: sg.default = 0; wolffd@0: option.sg = sg; wolffd@0: wolffd@0: se.key = 'Sequence'; wolffd@0: se.type = 'Integer'; wolffd@0: se.default = 0; wolffd@0: option.se = se; wolffd@0: wolffd@0: inc.key = 'Increasing'; wolffd@0: inc.type = 'MIRtb'; wolffd@0: option.inc = inc; wolffd@0: wolffd@0: dec.key = 'Decreasing'; wolffd@0: dec.type = 'MIRtb'; wolffd@0: option.dec = dec; wolffd@0: wolffd@0: every.key = 'Every'; wolffd@0: every.type = 'Integer'; wolffd@0: option.every = every; wolffd@0: wolffd@0: burst.key = 'Burst'; wolffd@0: burst.type = 'Boolean'; wolffd@0: burst.default = 1; wolffd@0: option.burst = burst; wolffd@0: wolffd@0: specif.option = option; wolffd@0: wolffd@0: specif.eachchunk = 'Normal'; wolffd@0: wolffd@0: varargout = mirfunction(@mirplay,a,varargin,nargout,specif,@init,@main); wolffd@0: if nargout == 0 wolffd@0: varargout = {}; wolffd@0: end wolffd@0: wolffd@0: wolffd@0: function [x type] = init(x,option) wolffd@0: type = ''; wolffd@0: wolffd@0: wolffd@0: function noargout = main(a,option,postoption) wolffd@0: if iscell(a) wolffd@0: a = a{1}; wolffd@0: end wolffd@0: d = get(a,'Data'); wolffd@0: f = get(a,'Sampling'); wolffd@0: n = get(a,'Name'); wolffd@0: c = get(a,'Channels'); wolffd@0: fp = get(a,'FramePos'); wolffd@0: if not(option.se) wolffd@0: if length(d)>1 wolffd@0: if isfield(option,'inc') wolffd@0: [unused order] = sort(mirgetdata(option.inc)); wolffd@0: elseif isfield(option,'dec') wolffd@0: [unused order] = sort(mirgetdata(option.dec),'descend'); wolffd@0: else wolffd@0: order = 1:length(d); wolffd@0: end wolffd@0: if isfield(option,'every') wolffd@0: order = order(1:option.every:end); wolffd@0: end wolffd@0: else wolffd@0: order = 1; wolffd@0: end wolffd@0: else wolffd@0: order = option.se; wolffd@0: end wolffd@0: if not(isempty(order)) wolffd@0: for k = order(:)' wolffd@0: display(['Playing file: ' n{k}]) wolffd@0: dk = d{k}; wolffd@0: if not(iscell(dk)) wolffd@0: dk = {dk}; wolffd@0: end wolffd@0: if option.ch wolffd@0: if isempty(c{k}) wolffd@0: chk = option.ch; wolffd@0: else wolffd@0: [unused unused chk] = intersect(option.ch,c{k}); wolffd@0: end wolffd@0: else wolffd@0: chk = 1:size(dk{1},3); wolffd@0: end wolffd@0: if isempty(chk) wolffd@0: display('No channel to play.'); wolffd@0: end wolffd@0: for l = chk wolffd@0: if chk(end)>1 wolffd@0: display([' Playing channel #' num2str(l)]); wolffd@0: end wolffd@0: if option.sg wolffd@0: sgk = option.sg(find(option.sg<=length(dk))); wolffd@0: else wolffd@0: sgk = 1:length(dk); wolffd@0: end wolffd@0: for i = sgk wolffd@0: if sgk(end)>1 wolffd@0: display([' Playing segment #' num2str(i)]) wolffd@0: end wolffd@0: di = dk{i}; wolffd@0: for j = 1:size(di,2) wolffd@0: tic wolffd@0: sound(di(:,j,l),f{k}); wolffd@0: idealtime = size(di,1)/f{k}; wolffd@0: practime = toc; wolffd@0: if practime < idealtime wolffd@0: pause(idealtime-practime) wolffd@0: end wolffd@0: end wolffd@0: if option.burst && sgk(end)>1 wolffd@0: sound(rand(1,10)) wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: end wolffd@0: noargout = {};