ya-webadb/libraries/pcm-player
2025-09-09 16:55:55 +08:00
..
src refactor: code cleanup 2024-06-02 01:55:26 +08:00
worker chore: update dependencies 2025-01-25 04:23:57 +08:00
.npmignore feat(scrcpy): support Scrcpy 2.0 (#495) 2023-04-15 19:50:46 +08:00
CHANGELOG.md chore: version 1.0.0 2024-12-02 10:36:49 +08:00
LICENSE chore: update dependencies, update license year 2025-03-02 18:11:10 +08:00
package.json feat(scrcpy): add client version 3.3.2 (#799) 2025-09-09 16:55:55 +08:00
README.md chore: add changelogs 2023-12-13 13:57:22 +08:00
tsconfig.dom.json feat(pcm): support any channel number 2023-10-19 10:45:01 +08:00
tsconfig.json chore: switch to node test 2024-07-23 18:10:40 +08:00
tsconfig.test.json chore: update dependencies 2024-04-13 23:02:54 +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.

Features

  • Arbitrary channel count
  • Arbitrary sample rate
  • 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