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!
Use SoundTouch framework in Swift
833 Views Asked by DeerMichel At
3
There are 3 best solutions below
0

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

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)
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
andx86_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:And now you must be able to use SoundTouch class.