Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Luccifer/BPM-Analyser
Analyser BPM in Swift for your music/sounds/records, whatever..
https://github.com/Luccifer/BPM-Analyser
analyser analyzer bpm ios media music songs swift swift4
Last synced: about 1 month ago
JSON representation
Analyser BPM in Swift for your music/sounds/records, whatever..
- Host: GitHub
- URL: https://github.com/Luccifer/BPM-Analyser
- Owner: Luccifer
- License: mit
- Archived: true
- Created: 2017-03-29T11:53:03.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-26T10:57:25.000Z (about 7 years ago)
- Last Synced: 2024-08-15T17:57:59.122Z (5 months ago)
- Topics: analyser, analyzer, bpm, ios, media, music, songs, swift, swift4
- Language: C
- Size: 19.4 MB
- Stars: 79
- Watchers: 5
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - BPMAnalyser - Fast and simple instrument to get the BPM rate from your audio-files. (Media / Audio)
- awesome-ios-star - BPMAnalyser - Fast and simple instrument to get the BPM rate from your audio-files. (Media / Audio)
README
# BPM-Analyser
![](https://img.shields.io/badge/swift-4.0-green.svg)
![](https://img.shields.io/badge/platform-ios-gray.svg)Analyser BPM in Swift for your music/sounds/records, whatever..
Powered with [Superpowered](http://superpowered.com)# Preview:
![](https://github.com/Luccifer/BPM-Analyser/blob/master/preview.gif)# How To:
## Copy theese files to your project:
- BMPAnalyzer.swift
- Superpower directory## Also add theese frameworks to your Linked Frameworks and Libraries
- Add AudioToolbox.framework
- CoreMedia.framework
- AVFoundation
- libSuperpoweredAudioIOS.a (From repo: /src/Superpowered, you added it to project in the previous step## In your code implementation you can call Singleton method by:
```swift
public func getBpmFrom(_ url: URL, completion: (String?) -> ()) -> String
```
Example:
```swift
guard let filePath = Bundle.main.path(forResource: "TestMusic", ofType: "m4a"),
let url = URL(string: filePath) else {return "error occured, check fileURL"}
BPMAnalyzer.core.getBpmFrom(url, completion: nil)```
You can stuck it with MPMediaPicker in delegate like this:
```swift
import UIKit
import MediaPlayerclass YourClassViewController: UIViewController {
let mediaPicker: MPMediaPickerController = MPMediaPickerController(mediaTypes: .music)
lazy var bpmLabel: UILabel = {
let label = UILabel()
label.frame.size.height = 300
label.frame.size.width = UIScreen.main.bounds.width - 32
label.numberOfLines = 2
return label
}()
override func viewDidLoad() {
super.viewDidLoad()
mediaPicker.allowsPickingMultipleItems = false
mediaPicker.delegate = self
present(mediaPicker, animated: true, completion: nil)
// Do any additional setup after loading the view, typically from a nib.
}
}extension YourClassViewController: MPMediaPickerControllerDelegate {
func mediaPicker(_ mediaPicker: MPMediaPickerController, didPickMediaItems
mediaItemCollection: MPMediaItemCollection) {
guard let asset = mediaItemCollection.items.first,
let url = asset.assetURL else {return}
_ = BPMAnalyzer.core.getBpmFrom(url, completion: {[weak self] (bpm) in
self?.addLabelWith(bpm)
self?.mediaPicker.dismiss(animated: true, completion: nil)
})
}
func addLabelWith(_ bpm: String) {
bpmLabel.text = String(describing:bpm)
view.addSubview(bpmLabel)
bpmLabel.center = view.center
view.layoutIfNeeded()
}
}```
### Look Example project in case of misunderstanding! :)## WHY?
Cause I can :D But in fact, I did't find any libs/frameworks to get BPM from media files...# WHY Superpowered?
Cause it is the [fastest lib I have found](http://superpowered.com)# Feel FREE to PR or contribuctions/issues/remarks
## BUGS/Fixes Contributors:
@o1exij - for the advice and reseraching the bug in BPM counting@MikaTck - for alerting fatal error + Swift4 migration