Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oscilloscope

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oscilloscope - npm Package Compare versions

Comparing version 0.2.1 to 1.0.0

lib/oscilloscope.js

40

package.json
{
"name": "oscilloscope",
"version": "0.2.1",
"description": "",
"main": "lib/index.js",
"dependencies": {
"debug": "^2.1.1"
},
"version": "1.0.0",
"description": "Waveform audio visualizer for the HTML5 canvas",
"main": "lib/oscilloscope.js",
"module": "src/main.js",
"dependencies": {},
"devDependencies": {
"coffee-script": "^1.9.1",
"uglifyify": "^3.0.1"
"rollup": "^0.45.2",
"rollup-plugin-uglify": "^2.0.1",
"rollup-plugin-buble": "^0.15.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build-ex": "browserify -g [uglifyify --no-sourcemap] example/main.js -o example/bundle.js",
"watch-ex": "watchify example/main.js -o example/bundle.js --debug --verbose",
"build-min": "browserify -s oscilloscope -g [uglifyify --no-sourcemap] . -o oscilloscope.min.js",
"build": "coffee -o lib -c src",
"prepublish": "npm run build && npm run build-min"
"test": "standard src/*.js && standard --global Oscilloscope examples/*.js",
"build": "rollup -c",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
"url": "https://github.com/mathiasvr/audio-oscilloscope.git"
"url": "git+https://github.com/mathiasvr/audio-oscilloscope.git"
},

@@ -34,3 +31,14 @@ "keywords": [

"author": "Mathias Rasmussen",
"license": "MIT"
"license": "MIT",
"bugs": {
"url": "https://github.com/mathiasvr/audio-oscilloscope/issues"
},
"homepage": "https://github.com/mathiasvr/audio-oscilloscope#readme",
"directories": {
"example": "examples",
"lib": "lib"
},
"files": [
"lib"
]
}

66

README.md

@@ -1,42 +0,46 @@

# audio-oscilloscope
Waveform audio visualizer using html5 canvas.
# oscilloscope
[![npm](https://img.shields.io/npm/v/oscilloscope.svg)](https://www.npmjs.com/package/oscilloscope)
![downloads](https://img.shields.io/npm/dt/oscilloscope.svg)
![dependencies](http://img.shields.io/:dependencies-none-green.svg)
[![license](http://img.shields.io/:license-MIT-blue.svg)](http://mvr.mit-license.org)
Require the module with browserify, or simply include oscilloscope.min.js
Waveform audio visualizer for the HTML5 canvas.
## Methods
## install
Add the `oscilloscope.min.js` script to your HTML, or import the module and bundle it for the browser with your favorite module bundler.
```bash
$ npm install oscilloscope
```
* addSignal(source:AudioNode, color)
* start()
* stop()
## example
```javascript
var Oscilloscope = require('oscilloscope')
## Example
var audioContext = new window.AudioContext()
```javascript
oscilloscope = require('..')
// create source from html5 audio element
var source = audioContext.createMediaElementSource(audioElement)
var context = new window.AudioContext()
// attach oscilloscope
var scope = new Oscilloscope(source)
// setup canvas
var canvas = document.querySelector('.visualizer')
canvas.width = window.innerWidth
canvas.height = window.innerHeight
// start default animation loop
scope.animate(canvas.getContext("2d"))
```
var options = {
stroke: 3, // size of the wave
glow: 0.1, // glowing effect
buffer: 1024 // buffer size ranging from 32 to 2048
}
> See the _examples_ folder for more details, and how to customize the animation.
// attach oscilloscope
var scope = new Oscilloscope(canvas, options)
## usage
### `scope = new Oscilloscope(source [, { fftSize: 2048 }])`
Supply an [AudioNode](https://developer.mozilla.org/en-US/docs/Web/API/AudioNode) as `source`.
// get user microphone
var constraints = { video: false, audio: true };
navigator.getUserMedia(constraints, function(stream) {
var source = context.createMediaStreamSource(stream)
scope.addSignal(source, '#00ffff')
}, function (error) {
console.error("getUserMedia error:", error);
});
Optionally set the `fftSize` property of the internal [AnalyzerNode](https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/fftSize). For more control supply an AnalyzerNode as `source`.
```
#### `scope.draw(context [, x, y, width, height])`
Draw oscilloscope to a canvas `context`, and optionally set position and dimensions.
#### `scope.animate(context [, x, y, width, height])`
Start a basic animation loop that redraws the oscilloscope using the `.draw()` method.
#### `scope.stop()`
Stop the animation loop started by the `.start()` method.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc