MatrixMixer AudioUnit をクエリするには、次のようにします。
// code from MatrixMixerTest sample project in c++
UInt32 dims[2];
UInt32 theSize = sizeof(UInt32) * 2;
Float32 *theVols = NULL;
OSStatus result;
ca_require_noerr (result = AudioUnitGetProperty (au, kAudioUnitProperty_MatrixDimensions,
kAudioUnitScope_Global, 0, dims, &theSize), home);
theSize = ((dims[0] + 1) * (dims[1] + 1)) * sizeof(Float32);
theVols = static_cast<Float32*> (malloc (theSize));
ca_require_noerr (result = AudioUnitGetProperty (au, kAudioUnitProperty_MatrixLevels,
kAudioUnitScope_Global, 0, theVols, &theSize), home);
の戻り値AudioUnitGetProperty
はkAudioUnitProperty_MatrixLevels
(ドキュメントとサンプル コードで定義されています) Float32 です。
私は迅速に行列レベルを見つけようとしていますが、行列の次元を問題なく取得できます。しかし、. である Float32 要素の空の配列を作成する方法がわかりませんUnsafeMutablePointer<Void>
。これが私が成功せずに試したことです:
var size = ((dims[0] + 1) * (dims[1] + 1)) * UInt32(sizeof(Float32))
var vols = UnsafeMutablePointer<Float32>.alloc(Int(size))
MatrixMixerTest では、配列は次のように使用されます。theVols[0]