Skip to content
プロジェクト

lincollincol/compose-audiowaveform

GitHubで見る

概要

Audio waveform library for Jetpack Compose

デザイン・メディア

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
-1
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Compose AudioWaveform

GitHub release (latest by date) GitHub

GitHub followers GitHub stars GitHub forks

Description

AudioWaveform is a lightweight Jetpack Compose library which draws waveform of audio.
Library uses compose Canvas API under the hood. It helps us to create customizable and flexible waveforms. This library was inspired by the WaveformSeekBar library (xml implementation).
AudioWaveform is fully compatible with Amplituda library.

Waveforms created with AudioWaveform

Download

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.lincollincol:compose-audiowaveform:x.y.z'
}

Usage

Common way

var waveformProgress by remember { mutableStateOf(0F) }
AudioWaveform(
  amplitudes = amplitudes,
  progress = waveformProgress,
  onProgressChange = { waveformProgress = it }
)

Custom color

  • SolidColor() - single color Brush.
  • Brush.horizontalGradient(), Brush.verticalGradient() (and more) - default Brush static gradient implementations.
  • Brush.infinite*Gradient() (where * is one of linear, horizontal or vertical) - infinite animated gradient. This is AudioWaveform library extension functions created with this article.
var waveformProgress by remember { mutableStateOf(0F) }

val colorBrush = SolidColor(Color.Magenta)

val staticGradientBrush = Brush.linearGradient(colors = listOf(Color(0xff22c1c3), Color(0xfffdbb2d)))

val animatedGradientBrush = Brush.infiniteLinearGradient(
  colors = listOf(Color(0xff22c1c3), Color(0xfffdbb2d)),
  animation = tween(durationMillis = 6000, easing = LinearEasing),
  width = 128F
)

AudioWaveform(
  progress = waveformProgress,
  progressBrush = brush,
  amplitudes = amplitudes,
  onProgressChange = { waveformProgress = it }
)

All parameters

var waveformProgress by remember { mutableStateOf(0F) }
AudioWaveform(
  modifier = Modifier.fillMaxWidth(),
  // Spike DrawStyle: Fill or Stroke 
  style = Fill,
  waveformAlignment = WaveformAlignment.Center, 
  amplitudeType = AmplitudeType.Avg,
  // Colors could be updated with Brush API
  progressBrush = SolidColor(Color.Magenta),
  waveformBrush = SolidColor(Color.LightGray),
  spikeWidth = 4.dp,
  spikePadding = 2.dp,
  spikeRadius = 4.dp,
  progress = waveformProgress,
  amplitudes = amplitudes,
  onProgressChange = { waveformProgress = it },
  onProgressChangeFinished = {}
)

Sample app

You could also try sample app, which demonstrates all AudioWaveform library features. Waveform from sample app is also synchronized with Media3.
Download sample app apk here.

Amplituda compatibility

AudioWaveform requires amplitudes to draw waveform. This parameter is a list of integers, which represents audio data. You can process the audio file by yourself or use already existing library Amplituda.
Amplituda is a fast audio processing library, which provides you data for drawing waveforms. Library has caching and compressing processed data features out of the box.
Here is Amplituda library usage in a sample app.

License

   Copyright 2022-present lincollincol

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

関連プロジェクトを探す

読み込み中…