Git Product home page Git Product logo

waveform's Introduction

Waveform

A SwiftUI Package to display an interactive waveform of an audio file.

Zooming Waveform

The project is currently in a very early stage having been created as part of SwiftUI Jam 2021. Code from the end of the Jam will be in the swiftuijam branch.

Installation

To include it in your Xcode project click File | Swift Packages | Add Package Dependency… and enter the following url:

https://github.com/pixlwave/Waveform

For now, you'll need to select Branch and ensure it's set to main until v0.1.0 is released.

Usage

Waveform Selection

To use Waveform create a WaveformGenerator object with your audio file:

let audioFile = try! AVAudioFile(forReading: URL))!
let generator = WaveformGenerator(audioFile: audioFile)   // this generator object is observable

And then pass this to a Waveform along with a selection range if you need this:

var body: some View {
    Waveform(generator: generator, selectedSamples: $selection, selectionEnabled: .constant(true))
}

The colour scheme can be customised via the standard colour modifiers:

Waveform(generator: generator, selectedSamples: $selection, selectionEnabled: .constant(true))
    .foregroundColor(waveformColor)
    .background(backgroundColor)
    .accentColor(selectionColor)

Caveats

  • More work is required on optimisation for acceptable performance on older devices.
  • Any audio file you use is loaded into memory in the WaveformGenerator. For now it would be worth watching your app's memory usage until this is addressed.

waveform's People

Contributors

pixlwave avatar

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.