npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reactive-sequencer

v0.1.9

Published

A powerful sequencer that can be used to sequence anything in the browser or node although it has a strong focus on musical sequencing. Streams allow controlling any parameter efficiently in real time, as well as reacting to any sequencer events. The API

Downloads

15

Readme

reactive-sequencer 🧪

A powerful sequencer that can be used to sequence anything in the browser or node although it has a strong focus on musical sequencing. Streams allow controlling any parameter efficiently in real time, as well as reacting to any sequencer events. The API is modular and designed to be used with external instruments and effects (WebAudio libraries, DAWs, hardware). Basic audio support is included in order to play simple sounds right out of the box.

Get started

Install

yarn add reactive-sequencer
# or
npm install --save reactive-sequencer

Use

import { sequencer } from 'reactive-sequencer'
import { pipe, map, forEach, interval } from 'reactive-fns'
import { randomInteger } from 'random-fns'
import { playSound } from './synth'

const { play, tempo$, setTempo, output$ } = sequencer() // create the sequencer

play() // emit a 'play' event

pipe(
  output$,
  forEach(playSound)
)

pipe(
  tempo$, // streams are always named with a $
  map(tempo => `bpm: ${tempo}`)
  forEach(console.log) // perform side effects when tempo$ updates
)

pipe(
  interval(1000), // emits every second
  forEach(() => {
    setTempo(randomInteger(110, 130)) // randomize tempo
  })
)

Here we see a use of the sequencer function. It is the most high level function exported from this library. It is composed of other functions with a similar shape to it: they receive (optional) input streams, and output streams along with useful handlers. The sequencer wires them up once and starts reacting to incoming data. This gives full control for altering parameters any time after initialization. The object that is returned by sequencer contains streams that send note and events data that can be reacted to. It's also possible to use the output streams of data, manipulate and wire back to control the input parameters.

🤯

This approach is very similar to how modular synthesizers work. The user plugs the cables and controls parameters while the machine does the rest. With that in mind, there's 2 things to consider:

  1. You're working with data streams rather than high frequency audio signal streams.
  2. The lack of precision in javascript timers requires scheduling instead of directly using the data as it arrives. This library abstracts that so you can focus on other things.

API

Sequencer

Initializing a new sequencer. Use the output streams to react to events, and input streams to change parameters.

You can learn more about the internal workings of the sequencer and the rest of the API here.

☞ functions:

  • sequencer

☞ types:

  • SequencerProps
  • SequencerInputStreams
    • run$ - tells the sequencer to play or resume when it emits.
    • stop$ - tells the sequencer to stop when it emits.
    • pause$ - tells the sequencer to pause when it emits.
  • SequencerOutputstreams
    • run$ - tells the player to play or resume when it emits.
    • stop$ - tells the player to stop when it emits.
    • pause$ - tells the player to pause when it emits.
  • PlaybackOutputstreams
    • playbackStatus$ - emits 'playing' | 'stopped' | 'paused' | 'resumed' representing its playback status.
    • isRunning$ - emits true when its status is 'playing' | 'resumed', false when it's not.
    • isPlaying$ - emits true when its status is 'playing', false when it's not.
    • isStopped$ - emits true when its status is 'stopped', false when it's not.
    • isPaused$ - emits true when its status is 'paused', false when it's not.
    • isResumed$ - emits true when its status is 'resumed', false when it's not.
    • onRun$ - emits null when the sequencer either plays or resumes.
    • onPlay$ - emits null when the sequencer plays.
    • onStop$ - emits null when the sequencer stops.
    • onPause$ - emits null when the sequencer pauses.
    • onResume$ - emits null when the sequencer resumes.