Open slmille4 opened 7 years ago
Thanks! But I still get an error with that code:
Cannot convert value of type 'UnsafePointer<_>' to expected argument type 'UnsafePointer
'
It looks like the complexBuffer parameter needs to be DSPSplitComplex instead of DSPSplitComplex!
complexBuffer is a class property that can't be initialized (sensibly) at init time, so it must be either DSPSplitComplex? or DSPSplitComplex!.
Cannot convert value of type 'UnsafePointer<_>' to expected argument type 'UnsafePointer'
The error goes away if you put the reference to 'complexBuffer' in parenthesis.
analysisBuffer.withUnsafeBufferPointer { $0.baseAddress!.withMemoryRebound(to: DSPComplex.self, capacity: analysisBuffer.count) { vDSP_ctoz($0, 2, &(complexBuffer!), 1, UInt(halfSize)) } }
Unfortunately, after trying that, I was getting runtime crashes after a few cycles through audio rendering.
Through a bit of trial and error, I found out the runtime errors were occurring from instantiating DSPSplitComplex with locally instantiated Float arrays at the init call. I was able to make it work by declaring the empty real and imaginary Float arrays as private variables in the class instance. Since that all happens at the init call, I also changed to the 'complexBuffer' from 'DSPSplitComplex!' to 'DSPSplitComplex'.
Tested on Swift 4.0, XCode 9.0 beta 4
I do not see a historical PR for this - can you create one for the benefit of other users of this project? Thx!
On line 166 in TempiFFT.swift, the call should be
analysisBuffer.withUnsafeBufferPointer { $0.baseAddress!.withMemoryRebound(to: DSPComplex.self, capacity: analysisBuffer.count) { vDSP_ctoz($0, 2, &complexBuffer, 1, UInt(halfSize)) } }
that should help get vDSP_ctoz working again