开发者

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开发者_JS百科 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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜