ya-webadb/libraries/pcm-player
2023-07-11 21:05:39 +08:00
..
src refactor: migrate to ES private fields 2023-07-11 21:05:39 +08:00
worker refactor: migrate to ES private fields 2023-07-11 21:05:39 +08:00
.eslintrc.cjs feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
.npmignore feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
CHANGELOG.json chore: v0.0.20 2023-06-05 11:02:37 +08:00
CHANGELOG.md chore: v0.0.20 2023-06-05 11:02:37 +08:00
jest.config.js chore: update dependencies 2023-07-07 18:30:13 +08:00
LICENSE feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
package.json chore: update dependencies 2023-07-07 18:30:13 +08:00
README.md feat(demo): use tabby as terminal emulator (#541) 2023-04-23 23:24:29 +08:00
tsconfig.dom.json feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
tsconfig.json feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
tsconfig.test.json feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
tsconfig.worker.json feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00

@yume-chan/pcm-player

Play raw audio sample stream using Web Audio API.

Only support stereo audio.

TODO:

  • resample audio to compensate for audio buffer underrun

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