-
Notifications
You must be signed in to change notification settings - Fork 10
sig.compute
sig.compute
applies a given routine to the input, and adapts to the type of input. For instance, the input can be a single audio file, or a sets of audio file, and each file might also be decomposed into segments.
OUT = sig.compute(
routine,
ARG1,
ARG2,
etc.)
where:
- routine is the function handler to the routine.
- ARG1, ARG2, etc. are the additional argument(s) given to the routine
-
OUT is the output variable. There can be several output, of the form:
[
OUT1,
OUT2,
etc.] = sig.compute(
routine,
ARG1,
ARG2,
etc.)
The routine has to be of the form:
out=
routine(
arg1,
arg2,
etc.)
or
[
out1,
out2,
etc.] =
routine(
arg1,
arg2,
etc.)
with the same number of output variables out1, out2, etc. than output variables OUT1, OUT2, etc.
and the same number of input arguments arg1, arg2, etc. than input arguments ARG1, ARG2, etc.
Each individual input argument argi corresponds to one file, one segment corresponding to the argument ARGI.
Each combined output variable OUTi is a collection of the corresponding individual output variables outi.
function out = main(in,option)
x = in{1};
if ~strcmpi(x.yname,'Brightness')
res = sig.compute(@routine,x.Ydata,x.xdata,option.cutoff);
x = sig.Signal(res,'Name','Brightness',...
'Srate',x.Srate,'Sstart',x.Sstart,'Send',x.Send,...
'Ssize',x.Ssize,'FbChannels',x.fbchannels);
end
out = {x};
end
function out = routine(d,f,f0)
e = d.apply(@algo,{f,f0},{'element'},3);
out = {e};
end
Cf. sig.data.apply
function out = after(x,option)
if iscell(x)
x = x{1};
end
if ~option.median
if find(strcmp('element',x.Ydata.dims))
dim = 'element';
else
dim = 'sample';
end
x.Ydata = sig.compute(@routine_norm,x.Ydata,x.Ssize,dim);
end
out = {x};
end
function d = routine_norm(d,Ssize,dim)
d = d.apply(@afternorm,{Ssize},{dim},Inf);
end
Cf. sig.data.apply