FDWaveformView
Reads an audio file and displays the waveform
Install / Use
/learn @fulldecent/FDWaveformViewREADME
FDWaveformView
FDWaveformView displays audio waveforms in Swift apps so users can preview audio, scrub, and pick positions with ease.
Usage
Add an FDWaveformView programmatically, then load audio. If your file is missing an extension, see the Stack Overflow answer on AVURLAsset without extensions.
let thisBundle = Bundle(for: type(of: self))
let url = thisBundle.url(forResource: "Submarine", withExtension: "aiff")
self.waveform.audioURL = url

Features
Highlight playback
Highlight a portion of the waveform to show progress.
self.waveform.highlightedSamples = 0..<(self.waveform.totalSamples / 2)

Zoom for detail
Render only the visible portion while progressively adding detail as you zoom.
self.waveform.zoomSamples = 0..<(self.waveform.totalSamples / 4)

Gesture control
Allow scrubbing, stretching, and scrolling with built-in gestures.
self.waveform.doesAllowScrubbing = true
self.waveform.doesAllowStretch = true
self.waveform.doesAllowScroll = true

Animated updates
Animate property changes for smoother UI feedback.
UIView.animate(withDuration: 0.3) {
let randomNumber = arc4random() % self.waveform.totalSamples
self.waveform.highlightedSamples = 0 ..< randomNumber
}

Rendering quality
- Antialiased waveforms draw extra pixels to avoid jagged edges.
- Autolayout-driven size changes trigger re-rendering to prevent pixelation.
- Supports iOS 15+ and visionOS 1.0+.
- Includes unit tests running on GitHub Actions.
Installation
Use Swift Package Manager: in Xcode choose File > Swift Packages > Add Package Dependency and point to this repository. Legacy installation options are available if needed.
API
Following is the complete API for this module:
-
FDWaveformView(open class, subclass ofUIView)init()(public init) default initializerdelegate: FDWaveformViewDelegate?(open var, get/set) delegate for loading and rendering callbacksaudioURL: URL?(open var, get/set) audio file to render asynchronouslytotalSamples: Int(open var, get) sample count of the loaded assethighlightedSamples: CountableRange<Int>?(open var, get/set) range tinted withprogressColorzoomSamples: CountableRange<Int>(open var, get/set) range currently displayeddoesAllowScrubbing: Bool(open var, get/set) enable tap and pan scrubbingdoesAllowStretch: Bool(open var, get/set) enable pinch-to-zoomdoesAllowScroll: Bool(open var, get/set) enable panning across the waveformwavesColor: UIColor(open var, get/set) tint for the base waveform imageprogressColor: UIColor(open var, get/set) tint for the highlighted waveformloadingInProgress: Bool(open var, get) indicates async load in progress
-
FDWaveformViewDelegate(@objc public protocol)waveformViewWillRender(_ waveformView: FDWaveformView)(optional)waveformViewDidRender(_ waveformView: FDWaveformView)(optional)waveformViewWillLoad(_ waveformView: FDWaveformView)(optional)waveformViewDidLoad(_ waveformView: FDWaveformView)(optional)waveformDidBeginPanning(_ waveformView: FDWaveformView)(optional)waveformDidEndPanning(_ waveformView: FDWaveformView)(optional)waveformDidEndScrubbing(_ waveformView: FDWaveformView)(optional)
A couple other things are exposed that we do not consider public API:
FDWaveformView(implementsUIGestureRecognizerDelegate)gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:) -> Bool
Testing
Find an available simulator:
xcrun simctl list devices available | grep iPhone
Build and test using a simulator ID from the output:
# Build the library
xcodebuild build -scheme FDWaveformView -destination 'id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
# Run unit tests
xcodebuild test -scheme FDWaveformView -destination 'id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
# Build the Example app (requires a newer iOS simulator)
cd Example
xcodebuild build -scheme Example -destination 'id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
Contributing
- This project's layout is based on https://github.com/fulldecent/swift6-module-template
Related Skills
qqbot-channel
350.8kQQ 频道管理技能。查询频道列表、子频道、成员、发帖、公告、日程等操作。使用 qqbot_channel_api 工具代理 QQ 开放平台 HTTP 接口,自动处理 Token 鉴权。当用户需要查看频道、管理子频道、查询成员、发布帖子/公告/日程时使用。
docs-writer
100.5k`docs-writer` skill instructions As an expert technical writer and editor for the Gemini CLI project, you produce accurate, clear, and consistent documentation. When asked to write, edit, or revie
model-usage
350.8kUse CodexBar CLI local cost usage to summarize per-model usage for Codex or Claude, including the current (most recent) model or a full model breakdown. Trigger when asked for model-level usage/cost data from codexbar, or when you need a scriptable per-model summary from codexbar cost JSON.
ddd
Guía de Principios DDD para el Proyecto > 📚 Documento Complementario : Este documento define los principios y reglas de DDD. Para ver templates de código, ejemplos detallados y guías paso
