Analyser BPM in Swift for your music/sounds/records, whatever..

Overview

BPM-Analyser

Analyser BPM in Swift for your music/sounds/records, whatever.. Powered with Superpowered

Preview:

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:

 public func getBpmFrom(_ url: URL, completion: (String?) -> ()) -> String

Example:

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:

import UIKit
import MediaPlayer

class 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

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

Comments
  • Linker error for architecture arm64

    Linker error for architecture arm64

    I'm trying to integrate BPMAnalyser into my project and am running into this roadblock. I'm having a hard time adding the Superpowered library correctly. I've added the Superpowered bridging header to my bridging header, and have added the libSuperpoweredAudioIOS.a to my linked frameworks, but still get the following error: Undefined symbols for architecture arm64: "_OBJC_CLASS_$_Superpowered", referenced from: objc-class-ref in BMPAnalyzer.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    opened by danho322 5
  • On some songs the reported BPM rate is approximately twice as high as in online databases

    On some songs the reported BPM rate is approximately twice as high as in online databases

    Examples:

    IN EXTREMO 'Lebensbeichte' REPORTED BPM: 178 https://songbpm.com/in-extremo-lebensbeichte?q=In%20Extremo%20-%20Lebensbeichte: 89

    DEPECHE MODE 'A question of lust' REPORTED BPM: 187.5 https://songbpm.com/depeche-mode-a-question-of-lust?q=depeche%20mode%20-%20a%20question%20of%20lust: 96

    the other songs however are (almost) identical: Archive - 'You make me feel' REPORTED BPM: 167 https://songbpm.com/archive-you-make-me-feel?q=Archive%20-%20You%20make%20me%20feel: 167

    opened by o1exij 5
  • Apple Music Songs Crash

    Apple Music Songs Crash

    Hi there! Thanks for awesome bridge, but I found some issue: If I pick song that purchased and downloaded from iTunes Store - everything is okay. But if I am picking song that I have downloaded from Apple Music the library crashes: "BPMAnalyser[4409:1894057] open error: iPod library error."

    My Apple Music subscription is active and songs are downloaded and stored in iPhone memory.

    opened by snake302 3
  • please help - fatal error

    please help - fatal error

    Hi, I appreciate you doing this, I've been searching everywhere for something that looks good to me.

    Unfortunately my app crashes when I try to put it to action. I also ran your sample project to check if I was doing something wrong and it still crashes in the same line of code. Could you help?

    Thank you

    file - BMPAnalyzer.swift line 14 - completion!(Superpowered().offlineAnalyze(url))

    log: fatal error: unexpectedly found nil while unwrapping an Optional value

    bug 
    opened by MikaTck 2
  • Not Return Correct BPM

    Not Return Correct BPM

    Hello team, I am little bit confused because BPM-Analyser are not working properly. I am trying to check below songs Bpm through BPM-Analyser and return wrong bpm please check.

    Song Name:- Comfortably Numb by Pink Floyd Song BPM:- 64 BPM

    Reference Link:- https://www.google.com/search?q=Comfortably+Numb+by+Pink+Floyd+bpm&oq=Comfortably+Numb+by+Pink+Floyd+bpm&aqs=chrome..69i57j0l7.3310j0j4&sourceid=chrome&ie=UTF-8

    BPM Analyser = 127 BPM

    Song Name:- The End by The Beatles Song Song BPM:- 123 BPM Reference Link:- https://www.google.com/search?sxsrf=ALeKk02pCM3ZfW3c6TVpOJRCi4zqFCQHbA%3A1589551394007&ei=IqG-Xo0J_pDj4Q_SlY3gDQ&q=The+End+by+The+Beatles+Song+BPM&oq=The+End+by+The+Beatles+Song+BPM&gs_lcp=CgZwc3ktYWIQAzIICCEQFhAdEB46BAgAEEc6BAgjECc6AggAOgYIABAWEB5QxQVY-x9gliJoAHAAeACAAZ0BiAGhDJIBBDAuMTGYAQCgAQGqAQdnd3Mtd2l6&sclient=psy-ab&ved=0ahUKEwiNosSxhLbpAhV-yDgGHdJKA9wQ4dUDCAw&uact=5

    BPM Analyser = 111 BPM

    @Luccifer @drougojrom Please check this and reply me ASAP. Why BPM-Analyser return wrong or incorrect BPM.

    Looking forward to hear from you. Thanks & Regards Sham

    opened by shamdass 1
  • Can't open this file Error Swift

    Can't open this file Error Swift

    Hello Team, When I try to get bpm of the song by BPM Analyzer, they return error give below. Please check me doing correct way to get bpm or not.

    Code Below:

    First UseCase let dummySongURL = Bundle.main.url(forResource: "demo2", withExtension: "mp3")! = BPMAnalyzer.init().getBpmFrom(dummySongURL) { (songBPM) in // error return: open error: Can't open this file. }

    Second UseCase let dummySongURL = "https://geekanddummy.com/wp-content/uploads/2014/02/central-locking-Ford-Mondeo-Mk-3.mp3" = BPMAnalyzer.init().getBpmFrom(URL(string: urlss)!) { (songBPM) in // open error: Use SuperpoweredAdvancedAudioPlayer::setTempFolder first. }

    Can someone please explain to me how to get this. Any help would be greatly appreciated. Thanks in advance.

    opened by shamdass 1
  • file can't open

    file can't open

    Hi, I tried the example app on Xcode 12.1 with

    let url = Bundle.main.url(forResource: "TestMusic", withExtension: "m4a")
    
    

    (Because media selector is not working on simulator) But I receive file can't open error message. I tried different files result the same. Superpowered.mm gives the error

    - (NSString *)offlineAnalyze:(NSURL *)url {
        // Open the input file.
        SuperpoweredDecoder *decoder = new SuperpoweredDecoder();
        const char *openError = decoder->open([[url absoluteString] UTF8String], false, 0, 0);
        if (openError) {
            NSLog(@"open error: %s", openError);
            delete decoder;
            NSString *st = @"";
            return st;
        };
    

    My url is correct I did nil check but maybe something is deprecated? Thank you in advance.

    opened by trevor-sonic 2
  • Cannot access the swift class

    Cannot access the swift class

    Hey, this is probably super simple, but how can I access the class from within my implementation?I have added the src to the project and copied over and set the bridge file to be built as well. Once I try to access BPMAnalyzer class it says there is none. I have tried building and restarting xcode to no avail.

    I am also trying this on a macos app, can that be the issue?

    opened by knobKompressor 2
  • Does not work on iOS 13.x anymore

    Does not work on iOS 13.x anymore

    When selecting a track (Not from Apple music, downloaded to the device) the application returns:

    BPMAnalyser[40046:12132003] open error: Data connection lost.
    
    opened by ThomasHaas15 2
Owner
Gleb Karpushkin
HTB:https://www.hackthebox.eu/profile/179935 ################ Developer married on Swift, bitten by C#, ganged by Haskell
Gleb Karpushkin
A pure Swift Spotify Music App in Apple Music style

HBMusic A pure Swift Spotify Music App in Apple Music style. How to run pod inst

haoboxuxu 6 Dec 29, 2021
The easiest way to prepare, play, and remove sounds in your Swift app!

Chirp The easiest way to prepare, play, and remove sounds in your Swift app! ##Installation ###CocoaPods Installation Chirp is available on CocoaPods.

null 309 Dec 17, 2022
Classical music front-end for Apple Music: iOS app

concertino_ios Concertino is a classical music front-end for Apple Music. It's splitted in several projects. This one provides only the iOS app. (Ther

Open Opus 107 Dec 22, 2022
iOS music player app that downloads music from the internet, even YouTube

About YouTag is an iOS music player app that downloads music from the internet, even YouTube, and manages it in a local library. Music videos can also

null 263 Jan 8, 2023
SoundManager - A simple framework to load and play sounds in your app.

SoundManager - A simple framework to load and play sounds in your app.

Jonathan Chacón 3 Jan 5, 2022
SwiftySound is a simple library that lets you deal with Swift sounds easily

SwiftySound Overview SwiftySound is a simple library that lets you deal with Swift sounds easily. Static methods Sound.play(file: "dog.wav") Sound.pla

Adam Cichy 1.1k Dec 17, 2022
Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way

Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way. You can play

Luis Cárdenas 89 Nov 21, 2022
iOS application for finding formants in spoken sounds

FORMANT PLOTTER Buy on the App Store: https://itunes.apple.com/us/app/formant-analyzer/id799183655?mt=8&uo=4&at=11l6hc&ct=fnd This is an iOS project t

William Entriken 51 Dec 25, 2022
Soundable allows you to play sounds, single and in sequence, in a very easy way

Overview Soundable is a tiny library that uses AVFoundation to manage the playing of sounds in iOS applications in a simple and easy way. You can play

Luis Cárdenas 89 Nov 21, 2022
Background sounds feature from iOS 15 on iOS 11+

Tranquil Background sounds feature from iOS 15 on iOS 11+ Only physically tested on iOS 14.3 and iOS 12.1.2, but it should support iOS 11 - iOS 15.x (

Dana Buehre 4 Dec 15, 2022
🎶 Control Apple Music right from your macOS menu bar.

About Music Bar is macOS application that places music controls right in your menu bar. Installation Download and unzip the latest release. Drag the a

Musa 202 Jan 4, 2023
SleepingBaby - Track your kids activity and allow them sleep soundly with relaxing music in ONE app

Sleeping Baby Скачать в AppStore. Ключевые используемые технологии: UIKit, MVVM,

Egor Kostyukhin 0 Jan 7, 2022
MusicKit is a framework and DSL for creating, analyzing, and transforming music in Swift.

MusicKit MusicKit is a framework and DSL for creating, analyzing, and transforming music in Swift. Examples Functional harmony let C5 = Pitch(midi: 72

Ben Guo 591 Oct 18, 2022
Cool Animated music indicator view written in Swift

Cool Animated music indicator view written in Swift. ESTMusicIndicator is an implementation of NAKPlaybackIndicatorView in Swift for iOS 8. 本人著作的书籍《La

Aufree 465 Nov 28, 2022
🅿️ PandoraPlayer is a lightweight music player for iOS, based on AudioKit and completely written in Swift.

Made by Applikey Solutions Find this project on Dribbble Table of Contents Purpose Features Supported OS & SDK Versions Installation Usage Demo Releas

Applikey Solutions 1.1k Dec 26, 2022
Music Player NBC With Swift

MusicPlayer Xcode command + shift + Y -> Debug 창 띄우기 command + R -> App 실행 command + . -> App 중지 ctrl + option + commadn + return(enter) -> Assistant

davidyoon891122 0 Nov 27, 2021
MusicTheoryKit: a swift module that provides an easy-to-use API for most commonly used music terms

MusicTheoryKit Introduction MusicTheoryKit is a Swift framework that provides an easy-to-use API for most commonly used music terms. Create notes, ass

Jin Zhang 4 Feb 8, 2022
Fully functional music player which is written in swift programming language

Music Player Source Code Fully functional Music Player Application Source code that is written in Swift 4.1, Xcode 9.3 Introduction Music Player for i

bpolat 243 Nov 9, 2022
MusicScore - A music score library with MusicPart, Measure, Note, Pitch and Tempo representations in swift structs

MusicScore A music score library with MusicPart, Measure, Note, Pitch and Tempo

null 7 Sep 19, 2022