Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TempiFFT fix #7

Open
slmille4 opened this issue Jul 1, 2017 · 5 comments
Open

TempiFFT fix #7

slmille4 opened this issue Jul 1, 2017 · 5 comments

Comments

@slmille4
Copy link

slmille4 commented Jul 1, 2017

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

@jscalo
Copy link
Owner

jscalo commented Jul 6, 2017

Thanks! But I still get an error with that code:

Cannot convert value of type 'UnsafePointer<_>' to expected argument type 'UnsafePointer'

@slmille4
Copy link
Author

slmille4 commented Jul 6, 2017

It looks like the complexBuffer parameter needs to be DSPSplitComplex instead of DSPSplitComplex!

@jscalo
Copy link
Owner

jscalo commented Jul 6, 2017

complexBuffer is a class property that can't be initialized (sensibly) at init time, so it must be either DSPSplitComplex? or DSPSplitComplex!.

@Crittar
Copy link

Crittar commented Aug 3, 2017

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

@javadba
Copy link

javadba commented May 1, 2020

I do not see a historical PR for this - can you create one for the benefit of other users of this project? Thx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants