• 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: Private *properties* for AUs? (not parameters)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Private *properties* for AUs? (not parameters)


  • Subject: Re: Private *properties* for AUs? (not parameters)
  • From: Urs Heckmann <email@hidden>
  • Date: Sun, 30 Nov 2003 11:24:08 +0100

Am Sonntag, 30.11.03 um 09:39 Uhr schrieb Michael Ashton:
Properties seem like the right mechanism for this sort of thing, but I can't figure out whether I'm allowed to invent my own properties. The docs I've read so far seem silent on this point. Can I make my own properties, or should I use some other mechanism to communicate with the UI? Suggestions (obviously) welcome ...


Hi Michael,

here's a little micro tutorial:

say you got a c struct of arbitrary content, that you want to pass back and forth between AU and AUView:

typedef struct someData { char name[ 73 ]; int anything; selfdefinedtype whatever } someData;

now, to make it a property, just define a unique property id above 63999:

#define someDataProperty 66654 // whatever


Setting the property (from UI, from RestoreState, wherever):

// if you do this from within your view:
// const AudioUnit theComponentInstanceOfTheAU = yourViewClass::GetEditAudioUnit();

someData mySomeData; // this should be filled with your stuff that you want to pass over

ComponentResult err = AudioUnitSetProperty (
theComponentInstanceOfTheAU,
someDataProperty,
kAudioUnitScope_Global,
0,
& mySomeData,
sizeof(someData));

this in turn lands here:

// yourAUClass should inherit from AUBase, so derive MusicDeviceBase whatever

ComponentResult yourAUClass::SetProperty (
AudioUnitPropertyID inID,
AudioUnitScope inScope,
AudioUnitElement inElement,
const void * inData,
UInt32 inDataSize)
{

if ( inID == someDataProperty && inScope == kAudioUnitScope_Global && inElement == 0 )
{
const someData* myNewSomeData;
myNewSomeData = static_cast<const someData *>(inData);

if ( inDataSize != sizeof( someData ))
return kAudioUnitErr_InvalidPropertyValue;

// we assume you have a someData myStoredSomeData anywhere defined
memcpy( myStoredSomeData, & myNewSomeData, sizeof( someData ) );

// you want anyone to listen?
// this fires a property change notification:
PropertyChanged( someDataProperty, 0, 0 );

return noErr;
}

// or which base ever you derive from
return MusicDeviceBase::SetProperty (inID, inScope, inElement, inData, inDataSize);
}


Now, to make this work properly, you also have to give soime info about that property:

ComponentResult yourAUClass::GetPropertyInfo(
AudioUnitPropertyID inID,
AudioUnitScope inScope,
AudioUnitElement inElement,
UInt32 & outDataSize,
Boolean & outWritable)
{
if ( inID == someDataProperty && inScope == kAudioUnitScope_Global && inElement == 0 )
{
outDataSize = sizeof( someData );
outWritable = true;
return noErr;
}

// or which base ever you derive from
return MusicDeviceBase::GetPropertyInfo(inID, inScope, inElement, outDataSize, outWritable);
}



Next would be retrieving a property:

UInt32 sizeSomeData = sizeof( someData );
someData mySomeData; // this will be filled with the stuff

ComponentResult err = AudioUnitGetProperty(
theComponentInstanceOfTheAU,
someDataProperty,
kAudioUnitScope_Global,
0,
&mySomeData,
& sizeSomeData );

Now you can check for size, dump err and all...

read here for more info and the use of PropertyListeners:

http://www.mat.ucsb.edu:8000/CoreAudio/54

Hope this helps (and I hope there are not too many typos and bugs);

Cheers,

;) Urs


urs heckmann
email@hidden
www.u-he.com <- Zebra Audio Unit comming soon
_______________________________________________
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: Private *properties* for AUs? (not parameters)
      • From: Urs Heckmann <email@hidden>
References: 
 >Private *properties* for AUs? (not parameters) (From: Michael Ashton <email@hidden>)

  • Prev by Date: Re: Private *properties* for AUs? (not parameters)
  • Next by Date: Re: Private *properties* for AUs? (not parameters)
  • Previous by thread: Re: Private *properties* for AUs? (not parameters)
  • Next by thread: Re: Private *properties* for AUs? (not parameters)
  • Index(es):
    • Date
    • Thread