Use SoundTouch framework in Swift

833 Views Asked by At

Can you please tell me how to use the SoundTouch framework in a Swift iOS project to detect BPM? I tried all things with Bridging Headers & whatever but I cant get it work... Thanks!

3

There are 3 best solutions below

3
On

If you still need it to use SoundTouch in your iOS project, I have shared a GitHub repository with that libraries compiled for armv7, armv7s, arm64, i386 and x86_64

https://github.com/enrimr/soundtouch-ios-library

To implement that compiled library in your project, you have to add SoundTouch directory (which includes libSoundTouch.a and the directory with headers) in your Xcode project.

In SWIFT you can't import a .h so you will need to create a .h file named <Your-Project-Name>-Bridging-Header-File.h Then reference it in your projects build settings (under "Swift Compiler" look for "Objective C Bridging Header") with:

$(SRCROOT)/<Your-Project-Name>-Bridging-Header.h

And now you must be able to use SoundTouch class.

0
On

The soundtouch library is originally written in C++ which Swift won't compile.

Even with an updated soundtouch library, the lib won't compile in a Swift project without Objective-C wrappers to allow Swift to access the methodology.

Using a bridging header will indeed include the soundtouch library, but the project just won't compile there after.

1
On

If you want to use Swift in your project, so I can suggest to use this lib:

https://github.com/Luccifer/BPM-Analyser

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)