Git Product home page Git Product logo

viwaveformview's People

Contributors

vitoziv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

viwaveformview's Issues

How to make waveform full width?

Hi,
Thanks for this library.
Is there any way to make the waveform full width like VIWaveformView?
Some of my audios looks short in waveform.

Thanks

Wrong widthPerSecond in AssetTrackSampleLoader used to calculate samplesPerPixel

I kept noticing that for short audio 3 seconds or less, the width seemed very off but as the sample became larger it was fine. I finally noticed that the "generateTrackOutput()" in the constructor of AssetTrackSampleLoader() uses the widthPerSecond stored in the AssetTrackSampleLoader class to calculate the samplesPerPixel. But the widthPerSecond is still the default value of 10, so it never changes. It should be the calculated actualWidthPerSecond. So added a parameter to AssetTrackSampleLoader so that it can take the widthPerSecond. Currently, the width is set on the loader only after generateTrackOutput() is called, so it makes no difference.

Update the init/constructor for AssetTrackSampleLoader as follows...

public init(track: AVAssetTrack, actualWidthPerSecond: CGFloat) {
    self.widthPerSecond = actualWidthPerSecond
    self.track = track
    generateTrackOutput()
}

Then pass in the value when creating it in the loadSamples function...

        let loaders = asset.tracks(withMediaType: .audio).map { (track) -> AssetTrackSampleLoader in
            let loader = AssetTrackSampleLoader(track: track, actualWidthPerSecond: widthPerSecond)
            //loader.widthPerSecond = widthPerSecond
            return loader
        }

Also, I'm not sure why but dividing by 5000 instead of 20000 in "updatePoints()" would allow the waveform to show more clearly for me. I'm not sure where 20000 comes from but maybe this should be selectable too. I tried scaling the height of the waveform instead but that didn't seem to help.

        func updatePoints(with audioSamples: [VIAudioSample]) {
            var points: [Float] = []
            if let audioSample = audioSamples.first {
                points = audioSample.samples.map({ (sample) -> Float in
                    return Float(sample / 5000.0)
                })
            }
            strongSelf.viewModel.points = points
        }

Lastly, I don't ever want to truncate samples. I want to see the whole waveform. So I changed the following by commenting the if check block and always setting the actualWidthPerSecond based on the duration. I think this was just here due to the above issue where the minWidthPerSecond was not getting set right.

        // if fill the timeline view don't have enough time, per point respresent less time
        /*
        if CGFloat(duration) * strongSelf.minWidthPerSecond < strongSelf.minWidth {
            strongSelf.actualWidthPerSecond = strongSelf.minWidth / CGFloat(duration)
        } else {
            strongSelf.actualWidthPerSecond = strongSelf.minWidthPerSecond
        }
         */
        
        strongSelf.actualWidthPerSecond = strongSelf.minWidth / CGFloat(duration)

WaveForm shown during sound file playback...

Hi,
First of all I would like to thank you for this wonderful Tool.
I want to ask, is there any way to show step-by-step
the waveform during the sound file playback?

Thank you in advance.

Best Regards
GEORGE GERARDIS

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.