Re: Creating a Discrete Parameter
Re: Creating a Discrete Parameter
- Subject: Re: Creating a Discrete Parameter
- From: William Stewart <email@hidden>
- Date: Mon, 18 Aug 2008 11:12:24 -0700
You need to look at SetParameter in AUBase I think..
The menu is created because you are implementing the method:
GetParameterValueStrings( AudioUnitScope inScope,
AudioUnitParameterID inParameterID,
CFArrayRef
* outStrings)
This method (have a look for its calling sequence in AUBase) is used
to indicate that the indexed parameter should be drawn as a menu.
If you don't want that you can use the properties:
kAudioUnitProperty_ParameterStringFromValue
kAudioUnitProperty_ParameterValueFromString
These are used to just provide a string for a value - but won't draw a
menu.
In the SampleEffectUnit in /Developer/Examples/CoreAudio you can see
both of these being used:
Parameter 3 for the menu
Parameter 4 for the values-strings (in your case this would/could be
an indexed parameter as well)
Thanks
Bill
On Aug 15, 2008, at 2:20 AM, Adam Stark wrote:
Hi Bill,
Many thanks for your reply. I have tried both of the things you
suggested.
- I implemented the SetParameter method and it makes sense to me and
it compiles but when I move the slider, it is not the method that I
implemented that is being called so that parameter does not update
itself the way I want it to. Am I doing something wrong? I
implemented the method as follows:
void MyClassName::SetParameter(UInt32 paramID,Float32 value)
{
Float32 myval;
myval = round(value*4)/4;
Globals->SetParameter(paramID, myval);
}
- I tried the indexed parameter option. This works and gives me a
drop down menu of my values. This is an option for me but it seems a
shame as a drop down menu is not the best interface to control a
number. Is there no way to have it as a slider?
Many thanks again,
Adam
On 14 Aug 2008, at 23:57, William Stewart wrote:
Why can't you implement this in the SetParameter method... All that
you need to do I think is:
(1) Overide SetParameter, truncating the value
(2) Call SuperClass::SetParameter with the truncated value
Then, anytime someone tries to get the parameter it will be the
truncated one..
However, we also have a notion of indexed parameters which are
probably more suitable for what you are trying to do - as in this
case you are telling hosts (including generic views) that your
parameter is a set of fairly course discrete steps (rather than a
continuous value range)
So, in the example you give below, you could declare your parameter
as:
0 < x <= 16
and indexed
Then you'd have a slider drawn for you that would range from
Min - - - - - Max
with the slider values knotched to integer values
You can also provide names for the different parameter values - so
you'd either get a menu for your discrete values, or using the
ParameterValueNames stuff we'd just draw a different value for each
parameter value...
Bill
On Aug 14, 2008, at 8:48 AM, Adam Stark wrote:
Hi,
I am trying to create a parameter that takes 'discrete' values. I
want it to take values between 0 and 4 at intervals of 0.25 so
that the values would be...
0, 0.25, 0.5, 0.75, 1, 1.25, ..... , 3.5, 3.75, 4
I want the slider to snap to these values when I change it. I have
done this before for a VST plug-in and I did something like...
newparamvalue = round(paramvalue*4)/4
where paramvalue ranges from 0 to 4. I implemented this in the
SetParameter method.
The problem I have with the audio units is I don't know where to
put this code. I have tried overloading the SetParameter method
but that does not work. Can anyone tell me either:
a) how can I implement this in an audio unit?
or
b) is there an existing parameter profile that will let me do this?
Many Thanks in advance,
Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden