OK, so I presume that you have created a 'signal filter' extension and
you want this extension to apply your code to the signal being
browsed.
Your extension should have a 'compute' function, have you done this?
Once you have this, which will be in FILTER_ROOT/private/compute.m
you will see that it has the following signature:
[X, context] = compute(X, parameter, context)
Your function has a signature:
> function [y] = spec_sub(x,Fs,t,nf)
Try calling your existing function from within the filter's compute
function ... you just have to figure out how to set 't' and 'nf', Fs
is available as get_sound_rate(context.sound) ... in current
development versions of XBAT it is simply context.sound.rate you can
test if it is available in the current preview release I can't
remember.
So if you were to edit the filter's compute function to be something like:
[X, context] = compute(X, parameter, context)
t = SOME_VALUE; nf = SOME_VALUE;
X = spec_sub(X, get_sound_rate(context.sound), t, nf)
It should just work ... so you see that the programming interface is
very minimal, and essentially the same as yours.
In XBAT the various parameters used by an algorithm are packed into a
'parameter' struct, this makes adding new ones and renaming them
trivial, and it also makes the related computation code clearer as
every time a parameter is used you will see parameter.(PARAMETER_NAME)
...
Harold
Do you have a 'parameter__create' function? I presume so, but you did
not mention it. Creating an extension that has controllable parameter
consists of at least two possibly more (up to 4: create, compile,
control, callback) related functions.
First of all, to simply separate function declaration from the
computation code, you create a parameter__create function ... by
editing the parameter fields in this function your compute function
should get different parameter values, these are well
'editor-controlled parameters' ...
Now when you add a parameter__control__create function, this function
assists in the creation of controls to display the state of the
parameters. You do not set new parameter values in this function, just
display.
Let me know if this makes sense and I can help more , the other
'methods' to compile parameters and callback on the controls are
frequently not needed so I will not describe these yet.
Harold
The 'name' of the controls should match the parameter fieldname, you
can use the 'alias' property to change the label of the control. I
think this should solve your problem ... if you look closely at the
code now you might recognize that otherwise there is no information
being passed to the control as to which parameter field it represents.
Now as a guideline, I would reccomend using a more descriptive name
for your parameter fields, which of course will be shared with the
matching control ... the name of this field will become the default
control label after title capitalization ... a good parameter name can
prevent you from using the alias ... and writing one less line of
code, it also typically makes the compute code more expressive to a
human.
Harold