{"id":13838508,"url":"https://github.com/herrkaefer/AccelerateWatch","last_synced_at":"2025-07-10T23:31:22.407Z","repository":{"id":82588842,"uuid":"67661234","full_name":"herrkaefer/AccelerateWatch","owner":"herrkaefer","description":"Digital signal processing (DSP) such as FFT, FIR, time and frequency domain features calculations, on watchOS ⌚️, Swift APIs 🚀","archived":false,"fork":false,"pushed_at":"2018-04-21T02:41:33.000Z","size":1141,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-21T02:33:27.279Z","etag":null,"topics":["apple-watch","digital-filter","digital-signal-processing","dsp","fft","motion-sensor"],"latest_commit_sha":null,"homepage":"https://herrkaefer.com/AccelerateWatch/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/herrkaefer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-08T02:32:01.000Z","updated_at":"2023-03-21T06:31:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd8641e6-b886-4d66-be21-0e48517daf9c","html_url":"https://github.com/herrkaefer/AccelerateWatch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/herrkaefer/AccelerateWatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herrkaefer%2FAccelerateWatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herrkaefer%2FAccelerateWatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herrkaefer%2FAccelerateWatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herrkaefer%2FAccelerateWatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/herrkaefer","download_url":"https://codeload.github.com/herrkaefer/AccelerateWatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/herrkaefer%2FAccelerateWatch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264687866,"owners_count":23649576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apple-watch","digital-filter","digital-signal-processing","dsp","fft","motion-sensor"],"created_at":"2024-08-04T16:00:19.841Z","updated_at":"2025-07-10T23:31:22.385Z","avatar_url":"https://github.com/herrkaefer.png","language":"C","funding_links":[],"categories":["Library"],"sub_categories":["Utility"],"readme":"# AccelerateWatch\n\n[![CI Status](http://img.shields.io/travis/HerrKaefer/AccelerateWatch.svg?style=flat)](https://travis-ci.org/HerrKaefer/AccelerateWatch)\n[![Version](https://img.shields.io/cocoapods/v/AccelerateWatch.svg?style=flat)](http://cocoapods.org/pods/AccelerateWatch)\n[![License](https://img.shields.io/cocoapods/l/AccelerateWatch.svg?style=flat)](http://cocoapods.org/pods/AccelerateWatch)\n[![Platform](https://img.shields.io/cocoapods/p/AccelerateWatch.svg?style=flat)](http://cocoapods.org/pods/AccelerateWatch)\n\n```AccelerateWatch```: High performance digital signal processing and vector operations implemented in C, and wrapped in Swift, designed especially to be targeted at watchOS.\n\n## Where and why to use AccelerateWatch?\n\nApple 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](https://developer.apple.com/library/ios/documentation/Accelerate/Reference/AccelerateFWRef/), 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.\n\n- Swift APIs. C data structures and methods are wrapped in Swift, so that you can call them using Swift conveniently.\n- Friendly syntax. This is a reason that you even want to use this instead of Accelerate framework on iOS, though other similar libraries like [Surge](https://github.com/mattt/Surge) exists.\n\nCurrently 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!** 😃\n\n## Example\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## Installation\n\nAccelerateWatch is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"AccelerateWatch\", :git =\u003e 'https://github.com/herrkaefer/AccelerateWatch.git'\n```\n\n## Usage\n\nFull documentation [HERE](https://herrkaefer.com/AccelerateWatch/).\n\nThe library currently has two modules:\n\n- `DSBuffer` is a class for windowed time series processing. You can simply push data into the buffer, and extract time-domain features, or perform Fourier transform and freqency analysis on it.\n- `Vector` is a set of functons for accelerating vector manipulations.\n\nBelow is a summary of the APIs.\n\n### DSBuffer\n\nDSBuffer represents a fixed length signal queue (Float type) which is suitable for storing and processing a windowed time series.\n\n##### Normal operations\n\n```swift\n// Create a DSBuffer object\n// *Tips*:\n// - If you do not need to perform FFT on the buffer, set fftIsSupperted to be false could save 50% memory.\n// - If you need to perform FFT, set buffer size to power of 2 could accelerate more.\ninit(size: Int, fftIsSupported: Bool = true)\n\n// Push new data to the end of the buffer (and the foremost will be dropped)\nfunc push(value: Float)\n\n// Get data by index\nfunc dataAt(index: Int)\n\n// Get buffer size\nvar bufferSize: Int\n\n// Dump buffer as array\nvar data: [Float]\n\n// Reset all buffer values to zero\nfunc clear()\n```\n\n##### Vector-like operations\n\n```swift\nfunc add(value: Float) -\u003e [Float]\nfunc multiply(value: Float) -\u003e [Float]\nvar centralized: [Float]\nfunc normalizedToUnitLength(centralized: Bool) -\u003e [Float]\nfunc normalizedToUnitVariance(centralized: Bool) -\u003e [Float]\nfunc dotProduct(with: [Float]) -\u003e Float\n```\n\n##### Time-domain features\n\n```swift\nvar mean: Float\nvar sum: Float\nvar length: Float\nvar energy: Float\nvar max: Float\nvar min: Float\nvar variance: Float\nvar std: Float\n```\n\n##### Fast Fourier Transform and frequency-domain features\n\n**Note for FFT related methods**:\n\n- Set `fftIsSupported` to true when creating the buffer.\n- Buffer `size` should be even. If you pass odd size when creating the buffer, it is automatically increased by 1.\n- Only results in **size/2+1** complex frequency bins from DC to Nyquist are returned.\n\n```swift\n// Perform FFT on buffer\nfunc fft() -\u003e (real: [Float], imaginary: [Float])\n\n// Get FFT sample frequencies\nfunc fftFrequencies(fs: Float) -\u003e [Float]\n\n// Get FFT magnitudes\nfunc fftMagnitudes() -\u003e [Float]\n\n// Square of FFT Magnitude, i.e. (abs(fft()))^2\nfunc squaredPowerSpectrum() -\u003e [Float]\n\n// Mean-squared power spectrum, i.e. (abs(fft()))^2 / N\nfunc meanSquaredPowerSpectrum() -\u003e [Float]\n\n// Power spectral density (PSD), i.e. (abs(fft()))^2 / (fs*N)\nfunc powerSpectralDensity(fs: Float) -\u003e [Float]\n\n// Average power over specified frequency band, i.e. mean(abs(fft(from...to))^2)\nfunc averageBandPower(fromFreq: Float = 0, toFreq: Float, fs: Float) -\u003e Float\n```\n\n##### FIR filter\n\n```swift\n// Setup a FIR filter\nfunc setupFIRFilter(FIRTaps: [Float])\n\n// Get latest FIR filter output\nfunc latestFIROutput() -\u003e Float\n\n// Get FIR filtered signal series in buffer\nfunc FIRFiltered() -\u003e [Float]\n```\n\n\n### Vector\n\nVector module includes operations on regular arrays. All functions have two versions, for float and double type respectively.\n\n- `vMean`\n- `vSum`\n- `vLength`\n- `vPower`\n- `vAdd`\n- `vMultiply`\n- `vRemoveMean`\n- `vNormalizeToUnitLength`\n- `vSqrt`\n- `vDotProduct`\n- `vCorrelationCoefficient`\n\n## Known issues\n\n- Setting any LLVM (v8) optimization level rather than `None [-O0]` would probably cause unexpected behavior of DSBuffer.\n\n## Author\n\nherrkaefer, gloolar@gmail.com\n\n## Acknowledgement\n\n- [kissfft](https://github.com/itdaniher/kissfft)\n\nkissfft is employed for FFT implementation. It is a lightweight and fast FFT library. Only the real-value FFT related part is included here.\n\n- [jazzy](https://github.com/realm/jazzy)\n\nFor documentation generation.\n\n## License\n\nAccelerateWatch is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fherrkaefer%2FAccelerateWatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fherrkaefer%2FAccelerateWatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fherrkaefer%2FAccelerateWatch/lists"}