Code Monkey home page Code Monkey logo

Comments (3)

dmrschmidt avatar dmrschmidt commented on May 13, 2024

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.

AliMunchkin avatar AliMunchkin commented on May 13, 2024

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.

dmrschmidt avatar dmrschmidt commented on May 13, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.