Mercurial > hg > ishara
view arrows/audiorec.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | beb8a3f4a345 |
children |
line wrap: on
line source
function a=audiorec(ch,rate,N,M,varargin) if nargin<4, M=N; end opts=options('buffer',1,'queue',4,'dspargs',{},varargin{:}); a=asysobj(@(sz)dsp.AudioRecorder('OutputDataType','double','NumChannels',ch,'SampleRate',rate, ... 'SamplesPerFrame',M,'BufferSizeSource','Property', ... 'BufferSize', opts.buffer*M, ... 'QueueDuration',opts.queue*M/rate, ... opts.dspargs{:}), ... 0,1,@(sz){[M,ch]}); if N>M OL=M+1:N; a=a*loop(@upd,@(sz)zeros(N-M,ch)); elseif N<M BLOCK=M-N+1:M; a=a*arr(@(x)x(BLOCK,:)); end function [y,s]=upd(x,s) y=[s;x]; s=y(OL,:); end end