robertweis
robertweis

Reputation: 95

MonoTouch: Help converting a couple lines of Objective C to C#

Since coming from a pure C# background I am having a little bit of trouble with some of the Objective C syntax. I am playing around with the Audio Queue and I am trying to set the InputAudioQueue property EnableLevelMetering and get the CurrentLevelMeterDB property. I found a couple examples in Objective C.

Setting the property:

UInt32 enabledLevelMeter = true;
AudioQueueSetProperty(queue,kAudioQueueProperty_EnableLevelMetering,&enabledLevelMeter,sizeof(UInt32));

Getting the value:

AudioQueueLevelMeterState levelMeter;
UInt32 levelMeterSize = sizeof(AudioQueueLevelMeterState);
AudioQueueGetProperty(queue,kAudioQueueProperty_CurrentLevelMeterDB,&levelMeter,&levelMeterSize);

Float32 peakDB = levelMeter.mPeakPower;
Float32 averageDB = levelMeter.mAveragePower;

The API reference for AudioQueue is very minimal. I am not sure what to use for the following values in C#.

public bool SetProperty (AudioQueueProperty property, int dataSize, IntPtr propertyData)
public IntPtr GetProperty (AudioQueueProperty property, out int size)

Could somebody help a me out? Thanks.

Upvotes: 1

Views: 365

Answers (1)

miguel.de.icaza
miguel.de.icaza

Reputation: 32694

Once you have your AudioQueue created (input or output), you can call:

int enabled = queue.GetProperty<int> (AudioQueueProperty.EnableLevelMetering);

Setting it is a little bit more annoying, you have to use:

queue.SetProperty (AudioQueueProperty.EnableLevelMetering, 4, (IntPtr) &enabled);

Upvotes: 1

Related Questions