神刀安全网

web-audio-engine: Pure JS implementation of the Web Audio API

web-audio-engine

web-audio-engine: Pure JS implementation of the Web Audio API web-audio-engine: Pure JS implementation of the Web Audio API web-audio-engine: Pure JS implementation of the Web Audio API

This library implements the Web Audio API specification on Pure JavaScript.

Implemented API

  • OscillatorNode (wavetable synthesis)
  • GainNode
  • BiquadFilterNode
  • StereoPannerNode
  • ChannelMergerNode
  • ChannelSplitterNode
  • WaveShaperNode
  • DelayNode (noisy..)

Installation

npm install --save web-audio-engine 

API

StreamAudioContext

StreamAudioContext writes raw PCM audio to the node stream. It can be used to play back sound using unix piping like as ALSA aplay or SoX play command.

Constructor

  • StreamAudioContext(opts: object)
    • opts.sampleRate: number ( default: 44100 )
    • opts.numberOfChannels: number ( default: 2 )
    • opts.blockSize: number ( default: 1024 )
    • opts.bitDepth: number ( default: 16 )
    • opts.float: boolean ( default: false )

Instance methods

  • pipe(stream: WritableStream): WritableStream
  • resume(): Promise<void>
  • suspend(): Promise<void>

Example

const AudioContext = require("web-audio-engine").StreamAudioContext;  const context = new AudioContext({ sampleRate: 48000 });  context.pipe(process.stdout);  // .. make sounds ..  // start rendering context.resume();

Demo

$ git clone git@github.com:mohayonao/web-audio-engine.git $ cd web-audio-engine $ npm install . $ cd demo $ npm install . $ node . --help 

Play simple demo with SoX play command.

$ node . sines | play -t s16 -r 44100 -c 2 -q - 

License

MIT

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » web-audio-engine: Pure JS implementation of the Web Audio API

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮