| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
AccelerateWatch: High performance digital signal processing and vector operations implemented in C, and wrapped in Swift, designed especially to be targeted at watchOS.
Apple watchOS 3 opens opptunities to developers to access more motion sensor data both in real time and possible background tasks. Unfortunately meanwhile, the Accelerate framework, a powerful tool for high-performance computations, is still unavailable on watchOS. This library is extracted from my other projects, and help those watchOS⌚️ apps which need to process sensor data in real time, just like what Accelerate does for iOS platform.
Currently the functionality set is relatively smaller compared with Accelerate framework because only those I used in my projects are added (mostly focused on time series operations and analysis). So contributions are welcome! 😃
To run the example project, clone the repo, and run pod install from the Example directory first.
AccelerateWatch is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "AccelerateWatch", :git => 'https://github.com/herrkaefer/AccelerateWatch.git'Full documentation HERE.
The library currently has two modules:
Below is a summary of the APIs.
DSBuffer represents a fixed length signal queue (Float type) which is suitable for storing and processing a windowed time series.
// Create a DSBuffer object
// *Tips*:
// - If you do not need to perform FFT on the buffer, set fftIsSupperted to be false could save 50% memory.
// - If you need to perform FFT, set buffer size to power of 2 could accelerate more.
init(size: Int, fftIsSupported: Bool = true)
// Push new data to the end of the buffer (and the foremost will be dropped)
func push(value: Float)
// Get data by index
func dataAt(index: Int)
// Get buffer size
var bufferSize: Int
// Dump buffer as array
var data: [Float]
// Reset all buffer values to zero
func clear()func add(value: Float) -> [Float]
func multiply(value: Float) -> [Float]
var centralized: [Float]
func normalizedToUnitLength(centralized: Bool) -> [Float]
func normalizedToUnitVariance(centralized: Bool) -> [Float]
func dotProduct(with: [Float]) -> Floatvar mean: Float
var sum: Float
var length: Float
var energy: Float
var max: Float
var min: Float
var variance: Float
var std: FloatNote for FFT related methods:
// Perform FFT on buffer
func fft() -> (real: [Float], imaginary: [Float])
// Get FFT sample frequencies
func fftFrequencies(fs: Float) -> [Float]
// Get FFT magnitudes
func fftMagnitudes() -> [Float]
// Square of FFT Magnitude, i.e. (abs(fft()))^2
func squaredPowerSpectrum() -> [Float]
// Mean-squared power spectrum, i.e. (abs(fft()))^2 / N
func meanSquaredPowerSpectrum() -> [Float]
// Power spectral density (PSD), i.e. (abs(fft()))^2 / (fs*N)
func powerSpectralDensity(fs: Float) -> [Float]
// Average power over specified frequency band, i.e. mean(abs(fft(from...to))^2)
func averageBandPower(fromFreq: Float = 0, toFreq: Float, fs: Float) -> Float// Setup a FIR filter
func setupFIRFilter(FIRTaps: [Float])
// Get latest FIR filter output
func latestFIROutput() -> Float
// Get FIR filtered signal series in buffer
func FIRFiltered() -> [Float]Vector module includes operations on regular arrays. All functions have two versions, for float and double type respectively.
herrkaefer, gloolar@gmail.com
kissfft is employed for FFT implementation. It is a lightweight and fast FFT library. Only the real-value FFT related part is included here.
For documentation generation.
AccelerateWatch is available under the MIT license. See the LICENSE file for more info.
| Back | FazBrowse Home | New Git URL |