RepositoryTypeScriptCACanada
ST

staskobzar/vue-audio-visual

VueJS audio visualization components

804stars
111forks
29issues
0views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: waveform

#1 Repository of the week

1
TINIX TRENDING·Topic: http5-audio-api

#1 Repository of the week

1
TINIX TRENDING·Topic: http5-audio-visualizer

#1 Repository of the week

vue-audio-visual

Node.js CI codecov Codacy Badge MIT npm

Vue HTML5 audio visualization components

UPDATE NOTES

[!WARNING] The current plugin version is compatible only with Vue v3. For Vue 2, use plugin version 2.5.1. See the install section for details.

Overview

An audio spectrum visualizer plugin for VueJS framework. It is built with HTML5 Web Audio API and compatible with all browsers that support the HTML5 audio API. It provides several Vue components that let you draw lightweight, attractive visualizations for audio HTML elements.

[!NOTE] Visit DEMO page for working examples.

Usage examples:

Component AvLine. Vue template name <av-line>

<av-line :line-width="2" line-color="lime" src="/static/music.mp3"></av-line>

This will create the following element:

AvLine Intro

Component AvBars. Vue template name <av-bars>

<av-bars
  caps-color="#FFF"
  :bar-color="['#f00', '#ff0', '#0f0']"
  canv-fill-color="#000"
  :caps-height="2"
  src="/static/bach.mp3"
></av-bars>

This will create the following element:

AvBars Intro

Component AvCircle. Vue template name <av-circle>

<av-circle
  :outline-width="0"
  :progress-width="5"
  :outline-meter-space="5"
  :playtime="true"
  playtime-font="18px Monaco"
  src="/static/bach.mp3"
></av-circle>

This will create the following element:

AvCircle Intro

Component AvWaveform. Vue template name <av-waveform>

<av-waveform src="/static/bar.mp3"></av-waveform>

This will create the following waveform element:

AvWaveform Intro

The component will pre-load audio content and generate a clickable waveform.

Component AvMedia. Vue component <AvMedia>

<AvMedia :media="mediaObject" type="vbar"></AvMedia>

This will create the following media element:

AvMedia Intro

There are more media types. See details below.

:gear: Get started

Install

Install using npm

npm install --save vue-audio-visual

For Vue 2, install version 2.5.1

npm i -S vue-audio-visual@2.5.1

Use plugin

Install the plugin in main.js:

import { createApp } from "vue";
import App from "./App.vue";
import { AVPlugin } from "vue-audio-visual";

const app = createApp(App);
app.use(AVPlugin);

app.mount("#app");

Then anywhere in your app you can use it like this:

<av-bars src="/static/bach.mp3" bar-color="#CCC"> </av-bars>

Use component

A single component can be imported and used:



<template>
  <AVWaveform src="http://foo.com/music.ogg" />
</template>

Composable functions

The plugin provides composable "use" functions for each component. Each component uses a composable function internally. See, for example, line component.

Composable functions use audio and canvas element refs. They are handy when you need full access to audio or canvas elements. At the same time they are easy to use:



<template>
  <div>
    <audio ref="player" :src="mySource" controls />
    <canvas ref="canvas" />
  </div>
</template>

:gear: API

There are several components that come with the plugin. Here is the list of available components:

NameComponent nameComposable function
av-barsAVBarsuseAVBars
av-circleAvCircleuseAVCircle
av-lineAVLineuseAVLine
av-mediaAVMediauseAVMedia
av-waveformAVWaveformuseAVWaveform

There are props that are common to all components and special props for each component. Component prop names follow Vue conventions when used with composable functions: when a prop's name is "foo-bar", the corresponding composable function parameter is expected to be "fooBar".

Common props

NameTypeDefaultDescription
srcStringnull URL for the audio element's src attribute. When provided, creates an audio element wrapped in a "div".
audio-controlsBooleantrue Audio element controls attribute. When provided, displays the audio element with controls.
canv-fill-colorStringnullCanvas fill background RGB color. Default is null, which makes the background transparent. Examples:
canv-fill-color="#00AAFF"

AVLine props

NameTypeDefaultDescription
canv-widthNumber300Canvas element width. Default 300. Example: :canv-width="600"
canv-heightNumber80Canvas element height. Default 80. Example: :canv-height="120"
line-widthNumber2Graph line width in px. Integer or float number. Example: :line-width="0.5"
line-colorString, Array#9F9Graph line color. Can be string RGB color or Array of RGB color. When an Array is given, the plugin creates a linear gradient and sets it as the background. The Array value should be bound. Examples:
line-color="#00AAFF"
:line-color="['#FFF', 'rgb(0,255,127)', '#00f']"
fft-sizeNumber128Represents the window size in samples that is used when performing a Fast Fourier Transform (FFT) to get frequency domain data.
Must be power of 2 between 25 and 215. Example: :fft-size="512"

Composable function:

function useAVLine<T extends object>(
  player: Ref,
  canvas: Ref,
  props: T,
);

AVBars props

NameTypeDefaultDescription
canv-widthNumber300Canvas element width. Default 300. Example: :canv-width="600"
canv-heightNumber80Canvas element height. Default 80. Example: :canv-height="120"
bar-widthNumber5Width of bars in pixels. Example: :bar-width="12"
bar-spaceNumber1Space between bars. Example: :bar-space="1.6"
bar-colorString, Array#0A0AFFBar fill color. Can be string RGB color or canvas gradients array.
Examples:
bar-color="#00AAFF"
:bar-color="['#FFF', 'rgb(0,255,127)', 'green']"
caps-heightNumber0Create caps on bars with given height in pixels. When zero no caps created. Example: :caps-height="2"
caps-drop-speedNumber0.9Caps drop down animation speed. The higher the number, the faster the caps go down. Example: :caps-drop-speed="0.5"
caps-colorString#A0A0FFCaps rectangles RGB color. Example: caps-color="lime"
brick-heightNumber0Draw bar as bricks when height is set and not zero.
Example: :brick-height="6"
brick-spaceNumber1Space between bricks. Example: :brick-space="2"
symmetricBooleanfalseDraw bars symmetric to canvas vertical center. Example: :symmetric="true"
fft-sizeNumber1024Represents the window size in samples that is used when performing a Fast Fourier Transform (FFT) to get frequency domain data.
Must be power of 2 between 25 and 215. Example: :fft-size="2048"

Composable function

function useAVBars<T extends object>(
  player: Ref,
  canvas: Ref,
  props: T,
);

AVCircle props

NameTypeDefaultDescription
canv-widthNumber100Canvas element width. Example: :canv-width="600"
canv-heightNumber100Canvas element height. Example: :canv-height="120"
radiusNumber0Base circle radius. If zero, then will be calculated from canvas width: (canv-width / 2) * 0.7 Example: :radius="20"
line-widthNumber1Frequency bit line width to draw. Example: :line-width="0.4"
line-spaceNumber1Space between lines to draw. Example: :line-space="2"
outline-colorString#0000FFOutline (contour) style RGB color. Example: outline-color="rgb(0,255,0)"
outline-widthNumber0.3Outline (contour) line width. Float value. Example: :outline-width="1"
bar-widthNumber1Frequency graph bar width. Example: :bar-width="1"
bar-lengthNumber0Frequency graph bar length/height. Default is a difference between radius and canvas width. Example: :bar-length="27"
bar-colorString, Array[#FFF,#00F]Bar style RGB color or radial gradient when an array. Example: :bar-color="#12AA55"
progressBooleantrueDraw playtime progress meter. Example: :progress="false"
progress-widthNumber1Playtime progress meter width. Example: :progress-width="2.4"
progress-colorString#0000FFPlaytime progress meter color. Example: :progress-color="green"
progress-clockwiseBooleanfalsePlaytime progress meter arc draw direction. Example: :progress-clockwise="true"
outline-meter-spaceNumber3Space between outline and progress meter. The bigger the value, the closer to the circle centre. Example: :outline-meter-space="1"
playtimeBooleanfalseDraw played time as text in the center of the circle. Example: :playtime="true"
playtime-fontString14px MonacoPlayed time print font. Example: playtime-font="18px monospace"
playtime-colorString#00fPlayed time font color. Example: playtime-color="green"
rotate-graphBooleanfalseEnable clockwise graph rotation. Example: :rotate-graph="true"
rotate-speedNumber0.001Rotate graph speed. Example: :rotate-speed="0.2"
fft-sizeNumber1024Represents the window size in samples that is used when performing a Fast Fourier Transform (FFT) to get frequency domain data.
Must be power of 2 between 25 and 215. Example: :fft-size="2048"

Composable function

function useAVCircle<T extends object>(
  player: Ref,
  canvas: Ref,
  props: T,
);

AVWaveform props

NameTypeDefaultDescription
canv-widthNumber500Canvas element width. Example: :canv-width="600"
canv-heightNumber80Canvas element height. Example: :canv-height="120"
played-line-widthNumber0.5Waveform line width for played segment of audio. Example: :played-line-width="0.8"
played-line-colorStringnavyWaveform line color for played segment of audio. Example: :played-line-color="#ABC123"
noplayed-line-widthNumber0.5Waveform line width for the not-yet-played segment of audio. Example: :noplayed-line-width="1"
noplayed-line-colorStringlimeWaveform line color for the not-yet-played segment of audio. Example: :noplayed-line-color="grey"
playtimeBooleantrueDisplay played time next to progress slider. Example: :playtime="false"
playtime-with-msBooleantrueDisplay milliseconds in the played time when true. For example: 02:55.054. Example: :playtime-with-ms="false"
playtime-font-sizeNumber12Played time print font size in pixels. Example: :playtime-font-size="14"
playtime-font-familyStringmonospacePlayed time print font family. Example: :playtime-font-family="monaco"
playtime-font-colorStringgreyPlayed time print font RGB color string. Example: :playtime-font-color="#00f"
playtime-text-bottomBooleanfalsePosition the playtime text at the bottom. Default is on top. Example: playtime-text-bottom
playtime-sliderBooleantrueDraw played time slider on the waveform. Example: :playtime-slider="false"
playtime-slider-colorStringredPlayed slider color. Example: :playtime-slider-color="#fafafa"
playtime-slider-widthNumber1Played slider width. Example: :playtime-slider-width="2.5"
playtime-clickableBooleantrueAllow click on waveform to change playtime. Example: :playtime-clickable="false"

The composable function uses useFetch from @vueuse/core package. The last argument of useAVWaveform is options for the "createFetch" function from the "useFetch" module.

export function useAVWaveform<T extends object>(
  player: Ref,
  canvas: Ref,
  props: T,
  fetchOpts: CreateFetchOptions = {},
);

AVMedia props

The component expects a MediaStream object. You can get it directly from navigator.mediaDevices or from the @vueuse/core library function useUserMedia. A live example can be found in App.vue.



<template>
...
<AVMedia :media="stream" type="circle" />
...
</template>
NameTypeDefaultDescription
mediaMediaStreamnoneRequired property. See example above.
typeStringwformType of media visualization. Available types: 'wform', 'circle', 'frequ' and 'vbar'. If not set or not recognized then 'wform' is set. See examples in the demo.
Example: type="frequ"
canv-widthNumbernull Canvas element width. Default value depends on plugin type:
  • circle: 80
  • frequ: 300
  • vbar: 50
  • wform: 200
Example: :canv-width="600"
canv-heightNumbernullCanvas element height. Default value depends on plugin type:
  • circle: 80
  • frequ: 80
  • vbar: 20
  • wform: 40
Example: :canv-height="120"
canv-classStringnullCanvas element css class name.
fft-sizeNumber1024/8192Represents the window size in samples that is used when performing a Fast Fourier Transform (FFT) to get frequency domain data. Default 8192 for the type 'wform' or 1024 for 'frequ'
Example: :fft-size="512"
frequ-lnumNumber60Number of vertical lines for 'frequ' type. Example: :frequ-lnum="30"
frequ-line-capBooleanfalseDraw lines of 'frequ' type with rounded caps. Example: :frequ-line-cap="true"
frequ-directionStringlrDirection to draw the frequency. Available values: 'lr' or 'mo' (left to right or middle out). If not set or not recognized then 'lr' is set.
Example: frequ-direction="mo"
line-colorString#9F9Graph line RGB color. Examples:
line-color="#00AAFF"
line-widthNumber0.5 / 3Graph line width in px. Integer or float number. If not set then 0.5 for 'wform' type and 3 for 'frequ' Example: :line-width="0.8"
radiusNumber0Base 'circle' radius. Example: :radius="4"
connect-destinationBooleanfalseAnalyser to connect to audio context's destination. Avoid echo during playback. Example: :connect-destination="true"
vbar-bg-colorString#e1e1e1 Background canvas color for 'vbar' type
vbar-capsBooleantrue Rounded bars for 'vbar' types
vbar-spaceNumber1 Space between bars in 'vbar' type
vbar-widthNumber4 Width of bars in 'vbar' type
vbar-fill-colorStringlime Color of bars in 'vbar' type
vbar-right-colorString#c0c0c0 Color of bars on right side in 'vbar' type

Composable function:

function useAVMedia<T extends object>(
  canvas: Ref,
  props: T,
);

License

MIT Copyright (c) 2018-present, Stas Kobzar

Similar Projects

Discover other similar projects and AI models.

RepositoryTypeScript
vuejs/vue

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

212.6k
Oct 10, 2024
RepositoryTypeScript
hoppscotch/hoppscotch

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

81.0k
Nov 30, 2026
RepositoryTypeScript
vuetifyjs/vuetify

🐉 Vue Component Framework

41.0k
Dec 3, 2026
RepositoryTypeScript
element-plus/element-plus

🎉 A Vue.js 3 UI Library made by Element team

27.9k
Dec 2, 2026
RepositoryTypeScript
katspaugh/wavesurfer.js

Audio waveform player

10.5k
Nov 24, 2026
RepositoryVue
ElemeFE/element

A Vue.js 2.0 UI Toolkit for Web

54.0k
Aug 20, 2024
RepositoryJavaScript
quasarframework/quasar

Quasar Framework - Build high-performance VueJS user interfaces in record time

27.2k
Nov 26, 2026
RepositoryPHP
krayin/laravel-crm

Krayin CRM is Free & Open Source CRM Built with Laravel for Customer, Lead, and Sales Management.

24.2k
Nov 30, 2026
RepositoryVue
zxwk1998/vue-admin-better

🎉 vue admin,vue3 admin,vue3.0 admin,vue后台管理,vue-admin,vue3.0-admin,admin,vue-admin,vue-element-admin,ant-design,vab admin pro,vab admin plus,vue admin plus,vue admin pro

18.9k
Nov 8, 2026