Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kyome22/audiovisualizerkit
Provides the computational assistance for drawing the audio visualizer.
https://github.com/kyome22/audiovisualizerkit
audio-visualizer fft swift swift-package-manager
Last synced: about 2 months ago
JSON representation
Provides the computational assistance for drawing the audio visualizer.
- Host: GitHub
- URL: https://github.com/kyome22/audiovisualizerkit
- Owner: Kyome22
- License: mit
- Created: 2024-06-22T07:17:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-24T08:55:10.000Z (4 months ago)
- Last Synced: 2024-10-31T22:51:57.250Z (about 2 months ago)
- Topics: audio-visualizer, fft, swift, swift-package-manager
- Language: Swift
- Homepage:
- Size: 1.35 MB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AudioVisualizerKit
Provides the computational assistance for drawing the audio visualizer.
## Requirements
- Development with Xcode 15.4+
- Written in Swift 5.10
- Compatible with iOS 17.0+, macOS 14.0+## Privacy Manifest
This library does not collect or track user information, so it does not include a PrivacyInfo.xcprivacy file.
## Installation
AudioVisualizerKit is available through [Swift Package Manager](https://github.com/apple/swift-package-manager/).
**Xcode**
1. File > Add Package Dependencies…
2. Search `https://github.com/Kyome22/AudioVisualizerKit.git`.
3. Add package and link `AudioVisualizerKit` to your application target.**CLI**
1. Create `Package.swift` that describes dependencies.
```swift
// swift-tools-version: 5.10
import PackageDescriptionlet package = Package(
name: "SomeProduct",
products: [
.library(name: "SomeProduct", targets: ["SomeProduct"])
],
dependencies: [
.package(url: "https://github.com/Kyome22/AudioVisualizerKit.git", exact: "1.0.0")
],
targets: [
.target(
name: "SomeProduct",
dependencies: [
.product(name: "AudioVisualizerKit", package: "AudioVisualizerKit")
]
)
]
)
```2. Run the following command in Terminal.
## Usage
1. Get the URL of the music file.
2. Use `AudioAnalyzer` to play music and get magnitudes and RMS.
- You can specify the FFT size.
- You can specify a window function (hann or hamming or blackman).
3. Use `AmplitudeSpectrumView` to draw the audio visualizer.
- You can select the shape type (straight or ring).
- You can specify the drawing range.
- Pass RMS to enable color linked to sound intensity.```swift
import AudioVisualizerKit
import SwiftUIstruct ContentView: View {
let audioAnalyzer = AudioAnalyzer(fftSize: 2048, windowType: .hannWindow)var body: some View {
AmplitudeSpectrumView(
shapeType: .straight,
magnitudes: audioAnalyzer.magnitudes,
range: 0 ..< 128,
rms: audioAnalyzer.rms
)
.padding()
.onAppear {
let url = Bundle.main.url(forResource: "example", withExtension: "mp3")!
try? audioAnalyzer.prepare(url: url)
try? audioAnalyzer.play()
}
.onDisappear {
audioAnalyzer.stop()
}
}
}
```