samer@10: % sinkdata - write sequence of arrays to sink samer@10: % samer@10: % sinkdata :: samer@10: % seq [[C,N]] ~'sequence of arrays of C channel signal', samer@10: % sigsink(C,R) ~'sink' samer@10: % natural ~'maximum size of arrays in input' samer@10: % -> action. samer@10: % samer@10: % Third argument defaults to maximum dimension of signal arrays. samer@10: % This function does not control the timing of the writes and samer@10: % so is suitable for non-real-time writes to eg audio files. samer@10: samer@10: function res=sinkdata(Y,S,maxbuf) samer@10: if nargin<3, maxbuf=max(size(Y)); end samer@10: u=construct(S); samer@10: try samer@10: W=u.writer(maxbuf); samer@10: u.start(); foreach(@write,Y); u.stop(); samer@10: catch ex samer@10: u.dispose(); samer@10: rethrow(ex); samer@10: end samer@10: u.dispose(); samer@10: samer@10: function write(x) samer@10: rem=W(x); samer@10: if rem>0, error('Sink is full'); end samer@10: end samer@10: end samer@10: samer@10: