Comments (3)
Hey, sorry for the late reply. I haven't been paying a lot of attention to github recently.
It's a very good point you're bringing up. I'll look into it more closely when I find some free time and integrate / document this better.
After heaving read up on the some Apple docs, it looks like the drawing should actually be thread safe and you can call it from a background thread.
So slightly modifying the examples from DSWaveFormImageExample/ViewController.swift, you can do this:
let bounds = middleWaveformView.bounds
DispatchQueue.global(qos: .userInteractive).async {
let bottomWaveformImage = waveformImageDrawer.waveformImage(fromAudioAt: audioURL,
size: bounds.size,
color: UIColor.blue,
backgroundColor: UIColor.lightGray,
style: .filled,
position: .custom(0.9),
paddingFactor: 5.0)
DispatchQueue.main.async {
self.bottomWaveformView.image = bottomWaveformImage
}
}
or
let waveform = Waveform(audioAssetURL: audioURL)!
let configuration = WaveformConfiguration(size: lastWaveformView.bounds.size,
color: UIColor.blue,
style: .striped,
position: .bottom)
DispatchQueue.global(qos: .userInteractive).async {
let image = UIImage(waveform: waveform, configuration: configuration)
DispatchQueue.main.async {
self.lastWaveformView.image = image
}
}
respectively. Using DSWaveformImage
directly however would require actual code changes to the library itself. Sounds like in your example though you'd actually want to use the UIImage
category or the WaveformImageDrawer
directly anyway due to the increased amount of control.
from dswaveformimage.
Thanks so much for picking this up and providing some example code, I really appreciate it :)
I hope to consider this for an upcoming project and let you know how I get on.
from dswaveformimage.
Sure thing! If you end up using it - or simply exploring it a bit - I appreciate every bit of feedback :) As the core of your original issue can be addressed and the README is now explaining it too, I’ll consider this closed for now. Will still get back to supporting this more out of the box at some
later point.
from dswaveformimage.
Related Issues (20)
- Wavefrom form Data in SwiftUI HOT 7
- WaveformLiveView for Local Path HOT 13
- There's many different ways this could be achieved. HOT 3
- Fatal error HOT 3
- Current amplitude HOT 1
- Empty audio not displayed even with Should Draw Silence HOT 6
- Compile error in Xcode 15 beta. HOT 2
- Missing Pause Functionality HOT 1
- -11800 Error code when generation samples on iOS 17 beta HOT 10
- mp3 File not support HOT 8
- xcode 15 not support. Stored properties cannot be marked unavailable with '@available' HOT 1
- Striped style with gradient HOT 2
- Stored properties cannot be marked unavailable with '@available' HOT 3
- Stored properties cannot be marked unavailable with '@available' HOT 1
- Thread 1: EXC_BAD_ACCESS (code=2, address=0x2829857c4) HOT 1
- WaveForm Flickering HOT 2
- Extra argument position in call error in MacOS HOT 1
- I need to show loader till complete image generating from audio URL. HOT 2
- Update version in cocoapod HOT 2
- crash in iOS 17 HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dswaveformimage.