ios Declare for vDSP

Hi Daniel,
that’s great to read! I think with vDSP_fft_zrip it is really the case this macro does not exist on iOS. Please check in the reference if you can find the method under “legacy macros” (with 5000 methods all having almost exactly the same name, I find it hard to be 100% sure).

Hi Ulrich!

thanks for your advice. vDSP_fft_zrip is currently used in iOS … see the following development examples using Xcode (in OSX)

https://github.com/krafter/DetectingAudioFrequency
http://stackoverflow.com/questions/11686625/get-hz-frequency-from-audio-stream-on-iphone/19966776#19966776
http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework

You’re right, Daniel. Apple’s docs didn’t confuse me for the first time.
Anyway, it was the vDSP_ctoz call where the project crashed first on my Mac. I changed the size of the second memoryblock to match the size of the first, then this method ran again.

But fft_zrip is giving me headaches. I believe C should be passed byref; the content will be changed by the function call. But when I do, excatly like on the ctoz method, I get a Syntax error.
Sometimes I am simply too stupid to see the fundamental error I made, therefore I return this unfinished to you and hope you find what must be a really silly mistake. Currently I cannot see it, but I will have a fresh look at it later.

https://dl.dropboxusercontent.com/u/21200221/Xojo/FFT.xojo_binary_project.zip

Addition (no edit available again): I changed fft_zrip to an external method and removed the additional blanks that suddenly appeared when I copied the parameters. Then it worked. I don’t know if the result is ok or whatever, but it doesn’t crash anymore. Same download link.

a) I think you are right about the following syntax
Declare Sub vDSP_fft_zrip Lib “Accelerate.framework” (Setup As Ptr, byref C As Ptr, IC As Int32, Log2N As Int32, Direction As Integer)
but it raises a syntax error, which is rather strange!

b) I’ve noticed a strange value of the pointer dataptr (pointer to the sourcemb datablock): &h00000000
so I checked the previous code …

c) On my enviroment … OSX 10.9.5, Xojo 2015 release 1, Xcode 6.2 (6C131e) … the call
vDSP_fft_zrip iniFTT, dataptr, 1, bufferlog2, 1
crashes …

It does not crash only if I have the following

dim outmb as new xojo.Core.MutableMemoryBlock (bufferFrames*4)
instead of

dim outmb as new xojo.Core.MutableMemoryBlock (sourcemb.Size)

The outmb block size should be (bufferFrames*8)/2 and integer: the output block size is 50% of the input block size <<<

d) Now I’ll check the output data and let ypu know

After struggling a little bit I’ve come to the following results:

a) After vDSP_fft_zrip I can read the data in the outmb memory block: the REAL ARRAY is CORRECT, but I cannot find the immaginary array!
b) In order to get all the real data I had to increase the vDSP_fft_zrip/Log2N value of +1
c) In order to get the interleaved data I had to moltiply vDSP_ctoz/ N value x2

Conclusion: some mistakes where made in interpreting the vDSP requirements and I do not have a pointer to the immaginary array!

Further analisys in progress…

Hi Ulrich!
Good news: I was able to make FORWARD FFT and REVERSE FFT (and rescaling the results by a known factor, they are right!)

Bad news:
0) I was not able to see the FFT immaginary part (I could not find it, but it is stored somewhere!)

Things that I had to fix :

  1. In order to get all the real data I had to increase the vDSP_fft_zrip/Log2N value of +1
  2. In order to get the interleaved data I had to moltiply vDSP_ctoz/ N value x2
  3. the FFT REAL data is 2x greater than expected (most likely also the FFT IMMAGINARY data is 2x, but I cannot see it)
  4. the REVERSE FFT data is 2x greater than expected

I think that all the above issues/fixes are generated by the same reason (wrong structures? wrong pointers?)

Copy of the test Project at the same link
http://www.gaiacons.com/download/FFT.zip

Excellent, Daniel! Ich will be busy for at least the next two days with other things but then will have a look at it. I have to read a lot about FFT stuff to get a clue on what we are up to, but it’s great you came up with this. Lately I added a few vector computations to rectangle structures for triangulation stuff needed in games and it would be very interesting to see if Accelerate could speed that up even more.

Hi Ulrich!
You can find some info about FFT using vDSP on the following links:

https://developer.apple.com/library/ios/documentation/Performance/Conceptual/vDSP_Programming_Guide/UsingFourierTransforms/UsingFourierTransforms.html

https://developer.apple.com/library/mac/samplecode/vDSPExamples/Listings/DemonstrateFFT_c.html#//apple_ref/doc/uid/DTS10004300-DemonstrateFFT_c-DontLinkElementID_8

https://github.com/phracker/MacOSX-SDKs/blob/master/MacOSX10.9.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/vecLib/vDSP.h

http://stackoverflow.com/questions/3398753/using-the-apple-fft-and-accelerate-framework