要查询你做下面的一个MatrixMixer AudioUnit:kAudioUnitProperty_MatrixLevels斯威夫特
// 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);
为kAudioUnitProperty_MatrixLevels
上AudioUnitGetProperty
返回值(在文档和示例代码中定义),一个浮点32。
我试图在swift中查找矩阵级别,并且可以在没有问题的情况下获得矩阵维度。但我不知道如何创建一个空的Float32元素数组,它是一个UnsafeMutablePointer<Void>
。这是我曾尝试没有成功:
var size = ((dims[0] + 1) * (dims[1] + 1)) * UInt32(sizeof(Float32))
var vols = UnsafeMutablePointer<Float32>.alloc(Int(size))
在MatrixMixerTest阵列使用,如:theVols[0]
“没有成功”的意思是什么? – Alexander
我无法使用'vols'作为数组,它使用'EXC_BAD_ACCESS'崩溃 – GWRodriguez
您试图在数组边界内访问的索引是什么? – Alexander