项目作者: cristovao-trevisan

项目描述 :
Generates Sine, Triangle, Sawtooth and Square waveforms
高级语言: JavaScript
项目地址: git://github.com/cristovao-trevisan/wave-generator.git
创建时间: 2017-08-20T18:16:40Z
项目社区:https://github.com/cristovao-trevisan/wave-generator

开源协议:MIT License

下载


Installation

npm install wave-generator --save

API

All

Parameters

  • size: Generated array size
  • f: wave frequency
  • fs: sample frequency
  • [amplitude = 1]
  • [useCounter = true]: If false all calls will start from the beginning of the array,
    true (default) will give continuous data

Sawtoothwave

Extra Parameters

  • [inverted = false]: Sawtooth direction |\|\ or /|/|

Usage

  1. // import constructors
  2. const { Sinewave, Squarewave, Trianglewave, Sawtoothwave } = require('wave-generator')
  3. const sine440 = Sinewave(2048, 440, 44100, 30)
  4. console.log(sine440(100)) // Array with 100 points
  5. console.log(sine440(100)) // Array with the next 100 points
  6. const square220 = Sinewave(2048, 220, 44100, 20, false)
  7. console.log(square220(100)) // Array with 100 points
  8. console.log(square220(100)) // Array with the same 100 points

TODO

  • Tests