-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build metering levels array from audio file? #11
Comments
Need that feature, too! Found any solution? |
Hi @borisyurkevich and @beekeweerts, thank you for your interest 👍 1/ So I am assuming that the following is not what you want? Generated by: self.audioVisualizationView.audioVisualizationMode = .read
self.audioVisualizationView.meteringLevels = [0.1, 0.67, 0.13, 0.78, 0.31]
self.audioVisualizationView.play(for: 5.0) 2/ The type of animation you wish to produce might be the "recording mode" one. That is, the metering level bars are appearing as the song is played, instead of being all displayed from the start and animating gradient only: In this case indeed there is nothing in the Framework allowing you to do that out of the box. However and if you don't wish to modify it, you could think of a solution as such: let existingDataSource = [0.1, 0.8, 0.5, ..., 0.4]
let duration: TimeInterval = 10.0
let timeBetweenFrames: TimeInterval = self.existingDataSource / self.duration
var meteringLevelsLeft = existingDataSource.count
self.audioVisualizationView.audioVisualizationMode = .write
self.timer = Timer.scheduledTimer(timeInterval: self.timeBetweenFrames, target: self, selector: #selector(addMeteringLevel), userInfo: nil, repeats: true) With: private func addMeteringLevel() {
if self.meteringLevelsLeft == 0 {
timer.invalidate()
}
let meteringLevelValue = self.existingDataSource[self.meteringLevelsLeft]
self.audioVisualizationView.addMeteringLevel(meteringLevelValue)
self.meteringLevelsLeft -= 1
} That type of solution could definitely be implemented in the Framework directly 👌Let me know if you get a chance! @borisyurkevich may have come up with another solution as well. |
I think what the person is asking for here is how to create the meteringLevels array from an asset. For example, I looked to use this project with songs from the users iTunes library so I have a MPMediaItem. I need to know how to read that file and generate the meteringLevels. |
Ha I see yes, makes sense. This is not covered by the library at the moment indeed. The library is not able to generate the |
Need that feature, too! |
hey |
Same here. Would love to have this feature. |
Same here |
Hi, thanks for your library. I assumed that's it is possible to read sound file in this library and produce graphic representation from it. However it looks like I need to get level numbers (from 0 to 1.0) by some other mean. Just wanted to confirm, does this library supports this feature?
If it doesn't maybe I can try to build it and make a pull request. Can't guarantee anything. In this case please mark this as Enhancement request.
The text was updated successfully, but these errors were encountered: