npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ng-audio-visualizer

v1.1.0

Published

A circle shaped audio visualizer

Downloads

4

Readme

NgAudioVisualizer

NgAudioVisualizer is an angular package visualizes audio files

Installation

npm i ng-audio-visualizer
yarn add ng-audio-visualizer

Images

Image 1 Image 2

Usage

1. Use the component directly

  1. Add NgAudioVisualizerModule to your module
import { NgAudioViisualizerModule } from 'ng-audio-visualizer';

@NgModule({
  ...
  imports: [
    ....
    NgAudioVisualizerModule,
    ....
  ],
  ....
})
export class YourModule { }
  1. Then you can use the component in your template
<ng-audio-visualizer [title]="title" [url]="url"></ng-audio-visualizer>
  1. you can pause and play the audio
<ng-audio-visualizer [title]="title" [url]="url" #player></ng-audio-visualizer>
@Component({
    ....
 })
export class WrapperComponent implements OnInit {
    ...
    @ViewChild("player") player!: NgAudioVisualizer;
    ...
    
    playAudio(){
        this.player.play();
    }
    
    pauseAudio(){
        this.player.pause();
    }
  
}

2. Use the Circular Visulaizer Class

  1. First in your component initilize the player
  2. Add <canvas> in your template
  3. create visulaizer object
  4. You're good to go

Component Template:

...
<canvas #visualCanavas></canvas>
...
Inputs For Component

| Input | Type | Required | Description | default | | :-------------: | :-------------: |:-----:| ----- | :----: | | url | string | Yes | The url of the audio to visualize | | title | string | No | the title to be rendered in the center of the circular visulaizer | empty | autoPlay | boolean | No | | False | playColor | string | No | | Red | stopColor | string | No | | Black

Typescript:

...
import { Player, CircularVisualizer } from 'ng-audio-visualizer';
...

@Component({
    ....
 })
export class CoolComponent implements OnInit, AfterViewInit {
    ...
    @ViewChild("visualCanavas") visualCanvasRef!: HTMLCanvasElement;
    player: Player;
    visulaizer: CircularVisualizer;
    ...
    
  ngOnInit() {
    const inputs = {....}
    this.player = new Player(inputs);
    this.player.init();
  }
  
  ngAfterViewInit(){
    const params = {
      player: this.player,
      canvas: this.visualCanvasRef.nativeElement,
      ....
    };
    
    this.visulaizer = new CircularVisualizer(params);
  }
}
Player Parmas

| Input | Type | Required | Description | default | | :-------------: | :-------------: |:-----:| ----- | :----: | | url | string | Yes | The url of the audio to visualize | | fftSize | number | No | https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize | 512

Visulaizer Config

| Input | Type | Required | Description | default | | :-------------: | :-------------: |:-----:| ----- | :----: | | playColor | string | No | | Red | stopColor | string | No | | Black | maxRadius | number | No | | 100px | minRadius | number | No | | 80px | barWidth | number | No | | 3px | barSpace | number | No | | 1px | maxBarHeight | number | No | | 40px | minBarHeight | number | No | | 1px | fontSize | number | No | | 16px | fontFamily | string | No | | Roboto | title | string | No | the title to be rendered in the center of the circular visulaizer | empty

Methods

those methods are both exposed by the player class and the component | Method | Description | | :-------------: | :-------------: | | play() | play the audio | | pause() | pause the audio |

those are exposed only by the player class | Method | Description | | :-------------: | :-------------: | | changeUrl(url: string) | | | seek(seconds: number) | | | getFrequencyData$() | returns an observable emits the frequency data each animation frame | | toggle() | toggles between play and pause | | isPlaying$() | returns an observable emits each time the state of the playing changes | | isPlaying() | same as the one above but sync | | getDuration() | returns the track duration | | getTime$() | returns an observable emits the current time of the audio | | getTime() | same as the one above but sync | | destroy() | clean the object, should be called before destroying the component |

Author

Mouhand Alkadri Linkedin Github Twitter Facebook

Credits

some code pieces was inspired by DavidLazic in this repo AudioVisulaizer

License

MIT