# beat-emitter

> WebAudio scheduler with an event emitter

Latest version **1.7.0** (published 2018-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install beat-emitter
pnpm add beat-emitter
yarn add beat-emitter
bun add beat-emitter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2018-11-06 |
| First published | 2018-01-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | joshwnj |
| Maintainers | joshwnj |
| Keywords | webaudio |

## Links

- npm: https://www.npmjs.com/package/beat-emitter
- Repository: https://github.com/joshwnj/beat-emitter
- Homepage: https://github.com/joshwnj/beat-emitter#readme
- Issues: https://github.com/joshwnj/beat-emitter/issues
- npm.io page: https://npm.io/package/beat-emitter

## Recent versions

- 1.7.0 (latest) — 2018-11-06
- 1.6.0 — 2018-11-06
- 1.5.0 — 2018-09-27
- 1.4.0 — 2018-09-27
- 1.3.0 — 2018-08-23
- 1.2.0 — 2018-03-23
- 1.1.0 — 2018-02-12
- 1.0.0 — 2018-01-30

## README

# beat-emitter

_WebAudio scheduler with an event emitter_

## Features

- runs as a web worker (so that `setInterval` fires more reliably)
- schedules audio events with a slight look-ahead, for precise timing

## Usage

```
const beatEmitter = require('beat-emitter')

const ac = new AudioContext()
const beats = beatEmitter(ac)

beats.setBpm(110)

// optional: shuffle factor (best results between .02 and .09)
beats.setShuffle(.07)

beats.start()
beats.schedule((beat, time) => {
  // play a note every 2nd beat
  if (beat % 2 === 0) {
    const osc = ac.createOscillator()
    osc.frequency.value = 440
    osc.start(time)
    osc.stop(time + 0.1)
    osc.connect(ac.destination)
  }
})
```



## Acknowledgements

I learned a lot from reading https://github.com/cwilso/metronome and based the code on this.

---
_Source: https://npm.io/package/beat-emitter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
