GithubHelp home page GithubHelp logo

happy-ferret / gl-spectrum Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dy/gl-spectrum

0.0 1.0 0.0 35.29 MB

:chart_with_downwards_trend: Spectrum renderer component

Home Page: https://audio-lab.github.io/gl-spectrum

JavaScript 100.00%

gl-spectrum's Introduction

gl-spectrum unstable

Spectrum rendering component with webgl or context2d.

Spectrum

Usage

npm install gl-spectrum

var Spectrum = require('gl-spectrum');

var spectrum = new Spectrum({
	container: document.body,
	canvas: canvas,
	context: 'webgl',

	//initial decibels data, -100...0
	magnitudes: frequenciesData,

	//audio settings
	maxDecibels: -30,
	minDecibels: -100,
	maxFrequency: 20000,
	minFrequency: 20,
	sampleRate: 44100,

	//perceptual loudness weighting, 'a', 'b', 'c', 'd', 'itu' or 'z' (see a-weighting)
	weighting: 'itu',

	//draw frequency/decibels grid
	grid: true,
	axes: false,
	logarithmic: true,

	//rendering settings
	smoothing: 0.5,
	antialias: false,

	//0 - place at the bottom, .5 - place symmetrically, 1. - place at the top
	align: 0,

	//Display max within the last N snapshots. 0 - no trail.
	trail: 0,

	//line, bar or fill, or any combination of them.
	type: 'line',

	//width of line or bar
	width: 1,

	//The levels of magnitude/frequency - a colormap name, colormap, pixels array, imageData, imageElement or canvas. Null disables fill.
	fill: 'greys',

	//A color tuple, imageData, imageElement, canvas or url. Default is 0-level of the fill
	background: null
});

//pass db frequencies in -100...0 range
spectrum.setFrequencyData(magnitudes);

//update style/options
spectrum.setFill(colors, inverse?);
spectrum.setBackground(image);
spectrum.update(options);

Lightweight 2d version is available as require('gl-spectrum/2d').

Related

gl-spectrum's People

Contributors

dy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.