Swiftpack.co - Package - fulldecent/FDWaveformView

FDWaveformView

Build Status Version License Platform Carthage compatible

FDWaveformView is an easy way to display an audio waveform in your app. It is a nice visualization to show a playing audio file or to select a position in a file.

:hatching_chick: Virtual tip jar: https://amazon.com/hz/wishlist/ls/EE78A23EEGQB

Usage

To use it, add an FDWaveformView using Interface Builder or programmatically and then just load your audio as per this example. Note: if your audio file does not have file extension, see this SO question.

let thisBundle = Bundle(for: type(of: self))
let url = thisBundle.url(forResource: "Submarine", withExtension: "aiff")
self.waveform.audioURL = url

Features

Set play progress to highlight part of the waveform:

self.waveform.progressSamples = self.waveform.totalSamples / 2

Zoom in to show only part of the waveform, of course, zooming in will smoothly re-render to show progressively more detail:

self.waveform.zoomStartSamples = 0
self.waveform.zoomEndSamples = self.waveform.totalSamples / 4

Enable gestures for zooming in, panning around or scrubbing:

self.waveform.doesAllowScrubbing = true
self.waveform.doesAllowStretch = true
self.waveform.doesAllowScroll = true

Supports animation for changing properties:

UIView.animate(withDuration: 0.3) {
    let randomNumber = arc4random() % self.waveform.totalSamples
    self.waveform.progressSamples = randomNumber
}

Creates antialiased waveforms by drawing more pixels than are seen on screen. Also, if you resize me (autolayout) I will render more detail if necessary to avoid pixelation.

Supports iOS8+ and Swift 3.

Includes unit tests which run successfully using Travis CI.

Installation

Add this to your project using Swift Package Manager. In Xcode that is simply: File > Swift Packages > Add Package Dependency... and you're done. Alternative installations options are shown below for legacy projects.

Contributing

This project's layout is based on https://github.com/fulldecent/swift4-module-template If you would like to change the layout, please change that project FIRST. Also you may appreciate that project has "recipes" -- you don't just change code, you also explain why you are doing things. As a maintainer this makes my job MUCH simpler. In a similar respect, if you are introducing non-minor changes, it will be VERY helpful if you could please reference to another project (like AlamoFire) that has seen and discussed the types of design challenges you are touching.) Thanks again and we all really do appreciate your contributions.

Github

link
Stars: 917

Dependencies

Used By

Total: 0

Releases

Correct Timescale in Video - 2020-02-12 18:25:54

Changed

Full Swift Package Manager Support - 2019-12-02 19:01:43

To keep using FDWaveformView and get updates, please use Swift Package Manager to install.

If this is your first time, just use File > Swift Packages > Add Package Dependency... and you're done.

Support Swift 5 - 2019-04-09 03:30:11

Changed

  • Converted to Swift 4.2 and Xcode 10
  • Prevent to handle panning gesture while pinching
  • Improve rendering of zooming and scrolling with highlight
  • Updated to Swift 5

Fix highlighted samples - 2018-02-07 01:14:52

Fixed

  • Fixed Highlight Samples not aligned to base waveform #101.

Support Swift 4.0 - 2017-10-27 19:09:43

Changed

  • Now supporting Swift 4.0

Ranges and Fixes - 2017-05-31 17:40:56

Changed

  • Now using ranges in the API where appropriate

Fixed

  • Fixed a retain cycle in completion handler of waveform render operation
  • Cancel waveform render operation when view is released

Rendering Enhancements - 2017-05-03 18:03:20

2.2.0

Released on 2017-05-03.

Added

  • Improved accuracy of waveform rendering
  • Added support for rendering waveform images outside of a view (See FDWaveformRenderOperation)
  • Added support for rendering linear waveforms
  • Added support for changing wavesColor and progressColor after waveform was rendered
  • Added support for updating waveform type and color to iOS Example app.

Fixed

  • Fixed waveform rendering for large audio files
  • Fixed bug which could prevent waveform from fitting new view size if rendering was in progress during a view resize
  • Fixed bug which caused waveformViewDidLoad() to not be called after the audio file was loaded
  • Fixed bug which caused subsequent waveform renderings for new audioURLs to never complete if there was an error with a previous render
  • Fixed bug which could cause a crash (divide by zero error) if the view's width was 0

Fix performance and add animation support - 2017-04-14 19:51:44

Added

Fixed

  • Improved accuracy of waveform rendering
  • Fixed waveform rendering for large audio files
  • Fixed crash with quick load time

Fix LayoutSubviews - 2017-02-16 21:54:46

Added

  • Allow scrubbing independantly of scrolling
  • Tidy up Swift 3.0 conversion, remove some forced unwraps & generally make more Swifty

Swift 3.0 version - 2016-09-27 23:41:24

Added

Fix rendering - 2016-09-02 15:01:50

Fixed

Fix CocoaPods spec - 2016-08-03 23:32:48

First stable API release - 2016-06-28 04:43:45

Added

Version 0.3.2 - 2016-04-10 23:03:26

Adds Carthage support

Version 0.3.0 - 2015-03-29 22:56:05

This has a few API breaking changes (we aren't yet at 1.0, so these can happen without a version bump!)

  • Uses the recommended CocoPods project format, see https://github.com/CocoaPods/pod-template/
  • Separate scrolling and pinching options, thanks @rmutter
  • Fix that warning everyone was seeing, thanks @msching

v0.2.2 - 2014-09-14 19:15:16

Adds profiling tests so users can submit performance metrics on live devices.

Please see https://github.com/fulldecent/FDWaveformView/wiki/Performance-profiling

v0.1.2 - 2014-01-06 21:11:28

v0.1.0 - 2013-11-05 14:47:31

Creating the first release. This is generally stable and works well for clips under 30 seconds. CocoaPods, here we come!