@yume-chan/pcm-player
TypeScript icon, indicating that this package has built-in type declarations

0.0.24 • Public • Published

@yume-chan/pcm-player

Play raw audio sample stream using Web Audio API.

Features

  • [x] Arbitrary channel count
  • [x] Arbitrary sample rate
  • [x] Basic OLA (overlap-add) resampler
  • [ ] Adjustable buffer size

Usage

Depends on the sample format, there are multiple player classes:

  • Int16PcmPlayer (little endian)
  • Float32PcmPlayer
  • Float32PlanerPcmPlayer

No Planer: audio samples are interleaved (left channel first).

With Planer: audio samples are in a two-dimensional array (left channel first).

The constructors require user activation (must be invoked in a user event handler, e.g. onclick), because they create AudioContexts.

var player = Int16PcmPlayer(44100);
player.start();
player.feed(new Int16Array([0, 0, 0, 0, 0, 0, 0, 0]));
player.stop(); // `AudioContext` will be closed, so can't be restarted

Readme

Keywords

Package Sidebar

Install

npm i @yume-chan/pcm-player

Weekly Downloads

114

Version

0.0.24

License

MIT

Unpacked Size

79.2 kB

Total Files

19

Last publish

Collaborators

  • yume-chan