vdsp

Objective-C: Cross correlation of two audio files

大兔子大兔子 提交于 2021-01-28 12:03:27
问题 I want to perform a cross-correlation of two audio files (which are actually NSData objects). I found a vDSP_convD function in accelerate framework . NSData has a property bytes which returns a pointer to an array of voids - that is the parameter of the filter and signal vector. I struggled with other parameters. What is the length of these vectors or the length of the result vectors? I guess: it's the sum of the filter and signal vector. Could anyone give me an example of using the vDSP

Fast Fourier transforms on GPU on iOS

本秂侑毒 提交于 2020-01-02 02:53:11
问题 I am implementing compute intensive applications for iOS (i.e., iPhone or iPad) that heavily use fast Fourier transforms (and some signal processing operations such as interpolations and resampling). What are the best libraries and API that allows for running FFTs on iOS? I have briefly looked into Apple Metal as well as Apple vDSP. I wasn't sure that vDSP utilizes GPUs although it seems to be highly parallelized and utilizes SIMD. Metal seems to allow to access GPU for compute intensive apps

vDSP_zrvmul not returning any results (or all zeros)

血红的双手。 提交于 2019-12-24 07:58:41
问题 I have tidied my code up and condensed it to make it readable, as per another users comments. I have a complexFloatArray class, to store arrays of Complex vectors class complexFloatArray { var reals: [Float] var imaginaries: [Float] init(reals: [Float], imaginaries: [Float]){ self.reals = reals self.imaginaries = imaginaries } } I then have some functions defined in extensions to this class. One being: func useAsDSPSplitComplex<R>(_ closure: (inout DSPSplitComplex) -> R) -> R { return reals

DFT result in Swift is different than that of MATLAB

巧了我就是萌 提交于 2019-12-20 02:34:40
问题 import Cocoa import Accelerate let filePath = Bundle.main.path(forResource: "sinusoid", ofType: "txt") let contentData = FileManager.default.contents(atPath: filePath!) var content = NSString(data: contentData!, encoding: String.Encoding.utf8.rawValue) as? String var idx = content?.characters.index(of: "\n") idx = content?.index(after: idx!) repeat { //let fromIndex = index(from: ) content = content?.substring(from: idx!) idx = content?.characters.index(of: "\n") idx = content?.index(after:

how to check if vDSP function runs scalar or SIMD on neon

夙愿已清 提交于 2019-12-14 03:55:53
问题 Im currently using some functions from the vDSP framework, especially the vDSP_conv and I'm wondering if there is any way to check if the function invokes scalar mode or is processed SIMD on the neon processor. The documentation of the function mentions some criteria for power-pc-architecture which have to be fulfilled or scalar mode is invoked. Now i neither know if these criteria apply for the iphone as well nor how to check if my function invokes scalar mode or runs properly on neon. is

Using std::complex with iPhone's vDSP functions

六眼飞鱼酱① 提交于 2019-12-13 01:53:28
问题 I've been working on some vDSP code and I have come up against an annoying problem. My code is cross platform and hence uses std::complex to store its complex values. Now I assumed that I would be able to set up an FFT as follows: DSPSplitComplex dspsc; dspsc.realp = &complexVector.front().real(); dspsc.imagp = &complexVector.front().imag(); And then use a stride of 2 in the appropriate vDSP_fft_* call. However this just doesn't seem to work. I can solve the issue by doing a vDSP_ztoc but

Matlab FFT (Fast Fourier Transform) function of non log-base2 numbers

点点圈 提交于 2019-12-11 11:55:51
问题 I have an app that I am developing that utalizes Apple's Accelerate Framework FFT function and I am trying to make it mimic the functionality of Matlab's FFT function. I have my current code set up to output exactly the same way as I am doing so in matlab. The only time that it doesn't output identically is when the number of elements in the data array are != a logarithm of base 2 (technically necessary for an FFT). I was wondering if anyone knew how the Matlab Function handled this case. If

Converting an array of Floats to an array of UnsafePointer<DSPComplex>

走远了吗. 提交于 2019-12-11 07:19:03
问题 I have this array of floats created like this var myArray : [Float] = [] This array has 256 elements, the real part. All imaginary parts are zero. I need to do a vDSP_ctoz(anArray, 2, &output, 1, vDSP_Length(n/2)) but this API requires anArray to be UnsafePointer<DSPComplex> How I convert myArray to this format? 回答1: normal arrays can pass as UnsafePointer So this snippet should work, var myArr = [Float]() var arr = [DSPComplex]() for number in myArr { var dsp = DSPComplex(real: number, imag:

Accelerate framework vDSP, FFT framing

懵懂的女人 提交于 2019-12-11 07:15:52
问题 I'm trying to implement FFT calculation, using Apple's vDSP, on a recorded audio file (let's assume it's a mono PCM). I've did a research here and I've found following topics quite useful: Using the apple FFT and accelerate Framework Extracting precise frequencies from FFT Bins using phase change between frames Reading audio with Extended Audio File Services (ExtAudioFileRead) For example, we configured FFT with frame_size N = 1024 samples, log2n=10: m_setupReal = vDSP_create_fftsetup(LOG_2N,

C versus vDSP versus NEON - How could NEON be as slow as C?

会有一股神秘感。 提交于 2019-12-10 10:15:48
问题 How could NEON be as slow as C? I have been trying to build a fast Histogram function that would bucket incoming values into ranges by assigning them a value - which is the range threshold they are closest to. This is something that would be applied to images so it would have to be fast (assume an image array of 640x480 so 300,000 elements) . The histogram range numbers are multiples (0,25,50,75,100) . Inputs would be float and final outputs would obviously be integers I tested the following