Giter VIP home page Giter VIP logo

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,

	//if undefined, new canvas will be created
	canvas: null,

	//existing webgl-context and some context options
	context: null,
	alpha: false,

	//enable render on every frame, disable for manual rendering
	autostart: true,

	//visible range
	maxDb: 0,
	minDb: -100,
	maxFrequency: 20000,
	minFrequency: 20,
	sampleRate: 44100,

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

	//display grid, can be an object with plot-grid settings
	grid: true,

	//place frequencies logarithmically
	log: true,

	//smooth series of data
	smoothing: 0.75,

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

	//peak highlight balance
	balance: .5,

	//display max value trail
	trail: true,

	//style of rendering: line, bar or fill
	type: 'line',

	//width of the bar, applicable only in bar mode
	barWidth: 2,

	//colormap for the levels of magnitude. Can be a single color for flat fill.
	palette: ['black', 'white'],

	//by default transparent, to draw waveform
	background: null,

	//pan and zoom to show detailed view
	interactions: false
});

//pass values in decibels (-100...0 range)
spectrum.set(magnitudes);

//update style/options
spectrum.update(options);

//hook up every data set
spectrum.on('data', (magnitudes, trail) => {});

//for manual mode of rendering you may want to call this whenever you feel right
spectrum.render();
spectrum.draw();

Related

gl-spectrum's People

Contributors

dy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gl-spectrum's Issues

2.0.0 list

  • Render by constructing 3d shape. That way there is natural antialiasing, avoided align calculation, avoided overcalc of empty pixels, simplified mask blending.
    • To avoid buffer churning, we could preset verteces and modify them in vertex shader by frequencies uniform. Grouping/averaging is also possible there, so we define proper level of magnitude, and all is done in parallel.
  • Make levels curve be acute at the end of magnitude, but flatter at the center of symmetry
  • Draw ghost frequencies
  • Add line-only draw
    • Bar-style, line-style, fill-style
  • [-] Add x-gradient fill to demo, including amount of rotation (CANCELLED - not very cool)
  • [-] Smooth interpolation (CANCELLED - useless)
  • Fix grid for various alignment
  • Add mask customizing to demo
  • Fix demo for iPhone (do audio-demo)

Make lines mode really simple

Recently mattdesl introduced spectrum, a tiny and pretty version.
Lines mode there makes more sense than here.
For now lines are kind of contradictory - I followed bad example of android screen. Gotta be a bit more opinionated in that.

Get rid of setFrequencyData

  • - now it keeps redundant state
  • - spectrum.render(data) would be more natural and simple
  • - that would easily allow for rendering multichanneled data
  • - naturally render trail: pick style, color, render with the data

Light version

canvas 2d-based, for really fast/simple/compact rendering.
Definitely should be a separate file (at least). Or maybe even a separate package.
Though, package is too much of repeating the API.
Why not the same file?

  • decreased bundle size
  • easier API methods
  • no extra mode of rendering, unresolvable on a single component
    Though single file is simple.

3.0.0 list

  • polar view
  • spiral view
  • vertical orientation
  • use stencil buffer for maskno need anymore with flat version
  • antialising with 60 fps
  • canvas2d
  • node painting
  • text mode
  • svg mode overcomplication
  • make it work in iphone
  • photorealistic images demo
  • demo with track selector, play/pause, forkme, codegenerator and url a separate project, in progress
  • fill and trail switches
  • on-bar info: db and frequency
  • min version: only actual frequencies, one-color, no-bg
  • multichannel rendering
  • line-only mode
  • piano keyboard with frequencies
  • axes checkbox with responsive plot-grid values

Styles

  • milky way
  • Would be super-awesome for reflection bg’s use logical component: birds for hi, volcano for low, animals for mid, insects for very high, etc.
  • pines
  • mountains
  • smeared sky
  • autumn

Rename snap/group

Very unarticulated.
They are indeed frequency/magnitude discretization, or snapping, or rounding, or grouping... Gotta search for proper term.

Light version fixes

  • line mode for webgl
  • trail for 2d
  • channels for 2d and gl
  • test viewports
  • display axes in responsive mode
  • add even bars param. Log bars are bad-looking really.
  • decrease intensity of line-mode fill. It should not be a data, it is transparency. Or make it almost fade.

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.