• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Parameter scope quandry
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Parameter scope quandry


  • Subject: Re: Parameter scope quandry
  • From: AJ <email@hidden>
  • Date: Tue, 29 Jul 2003 17:12:13 -0700

Thanks for the rapid response....

I'll try and be more clear by first explaining what would work but I am trying to avoid. After that I will try and explain why I am trying to avoid the approach.

I could (and may end up) have(ing) three different parameters in global scope as in kMyAU_Osc1HzParam, kMyAU_Osc2HzParam, and kMyAU_Osc3HzParam and then set frequencies:

// set three oscillators to A
AudioUnitSetParameter(au_osc_bank, kMyAU_Osc1Hz, kAudioUnitScope_Input, 0, 220, 0);
AudioUnitSetParameter(au_osc_bank, kMyAU_Osc2Hz, kAudioUnitScope_Input, 0, 440, 0);
AudioUnitSetParameter(au_osc_bank, kMyAU_Osc3Hz, kAudioUnitScope_Input, 0, 880, 0);

I believe this is the solution you are suggesting? Then in a parameter listener I can trap the parameter id and do the right thing:

switch(param->mParameterID) {
case kMyAU_Osc1HzParam:
osc1.setHz(inValue);
break;

case kMyAU_Osc2HzParam:
osc2.setHz(inValue);
break;

case kMyAU_Osc3HzParam:
osc3.setHz(inValue);
break;
}

... or I could try and be fancy

switch(param->mParameterID) {
case kMyAU_Osc1HzParam:
index = 0;
break;

case kMyAU_Osc2HzParam:
index = 1;
break;

case kMyAU_Osc3HzParam:
index = 1;
break;
}
osc_vector[index]->setHz(inValue);

So taking the long route to get back to what I mean when I say "Same settings for different instances" I mean that each oscillator is actually a different instance of the same class and having to write seperate lines of code using seperate parameter IDs to change seperate oscillators feels a bit tedious. Especially since I really just need to map the parameter value to an index.

If I go back to to having only a single kMyAU_HzParam I would ultimately (if possible within the API of course) like to not have 3 parameters but only 1. I feel as if I need only 1 since at a modeling level changing the frequency on multiple oscillator instances is much like your changing volume on multiple mixing channels. In short I was hoping to have a parameter listener do something like:

switch(param->mParameterId) {
case kMyAU_HzParam:
osc_vector[param->inElement]->setHz(value);
break;

// other stuff
}

This code is much simpler and would seem to allow for the number of oscillators to be changeable during runtime! Because of this simplicity of code, I was attempting to see if AU scope and elements could be molded to behave in this manner. Do you think they could?

Would attempting to do this with properties fare any better.... or am I still being confusing?

Thanks again!

--aj

First off, lets try to clarify what it is you are doing.

On Tuesday, July 29, 2003, at 01:42 PM, AJ wrote:

Greetings,

I am trying to implement an oscillator bank for basic additive synthesis as an AU plug-in and I want to determine what scope to put oscillator parameters under. After almost two days of off and on research I've decided I've studied enough to ask for some assistance. ;)

I appreciate the way AU scopes in combination with elements provide a nice way of having the same settings for different instances of something inside an AU. Using that concept...my hope is that I will be able to eventually do something like...


The idea of scopes and elements can probably be best understood by thinking about a mixer...

A Mixer can have say up to 8 inputs.
Each input can have its own volume
A Mixer can have say 2 outputs, each output can have its own volume
You want a "global" volume that determines the entire volume of the whole mixer...

So, in this case you'd set volumes on either:
Input Scope - where element ID is the input that you want to set the volume on
Output Scope - where element ID is the output
Global Scope - where element ID is always zero.

OK?

So, now your point confuses me:
"Same settings for different instances of something inside an AU"

If you *aren't* doing a multi-timbral synth, then I am confused by your question and you need to restate it - I could hazard a guess, but I'd rather have a clearer idea of what it is you are trying to do (because to my mind, the confusion is that you really have 3 parameters, not 1, but I maybe being too simplistic?)

You cannot use group scope as you described - it is indeed intended to be used as a "control" scope with "NON"-persistent state.

Bill


int i = 0;
int hz = 220;

// set three oscillators to A each an octave above the previous
while( i++ < 3) {
AudioUnitSetParameter(au_osc_bank, kMyAUHzParam, scope_TBD, i, hz, 0);
hz *= 2;
}

So as the name scope_TBD implies, I'm undecided on what the approriate scope would be.

1. Global is obviously out as there can only be a single element in global scope.

2. Output seems the wrong choice since this will cause rendering on multiple outupt buses when I only need one bus. I specifically want to mix the oscillators onto a single output bus.

3. Input scope seems like it would work but that would involve an AUIOElement getting allocated and I don't need/want a buffer for each oscillator as I stated in 2.

4. Group scope seems dedicated to representing MIDI channels so... that's right out. Allthough, I do find it interesting that both Global and Group scope are both implemented using the AUElement class which acts as a container for parameters without the buffer that appears in AUIOElement. I wish I had a scope that would support multiple elements without requiring buffers but wasn't dedicated to MIDI, etc. After poring through the recent discussions on group scope and MIDI, I debated going ahead and using Group scope and just having the element IDs for my oscillators be greater than the maximum number of MIDI channels I would support.

AudioUnitSetParameter(au_osc_bank, kMyAUHzParam, scope_TBD, i + OSC_ELEM_OFFSET, hz, 0);

This feels a bit klunky to me. ;(

If anyone out there could provide any insight it would be greatly appreciated.


cheers
--aj
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


-- mailto:email@hidden
tel: +1 408 974 4056

________________________________________________________________________ __
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________ __
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Parameter scope quandry
      • From: AJ <email@hidden>
References: 
 >Re: Parameter scope quandry (From: Bill Stewart <email@hidden>)

  • Prev by Date: Re: Parameter scope quandry
  • Next by Date: HAL: canonical format always interleaved?
  • Previous by thread: Re: Parameter scope quandry
  • Next by thread: Re: Parameter scope quandry
  • Index(es):
    • Date
    • Thread