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

supercollider-redux-sequencers

v0.9.14

Published

Components for building generative music systems using JavaScript and SuperCollider.

Downloads

11

Readme

supercollider-redux-sequencers

A Node.js and SuperCollider framework for generative musical sequencers based on supercollider-redux. Provides the ability to start and stop SuperCollider patterns from Node.js and state updates to the Node.js process at each event played.

The SuperCollider pattern generators are intended to be written using the Pbind library, a prominent way to build generative event generators in SuperCollider.

The Node.js interface to SuperCollider is a Redux state store, all starting and stopping of sequencers occurs via actions dispatched to the store, and all note events received from the sequencers are actions dispatched from the SuperCollider state store.

State Overview

State of all sequencers is stored by id in sequencers. Each sequencer has the following attributes:

  • sequencerId: A unique identifier for this sequencer, also used as the key to lookup in sequencers
  • classString: A string representing the class to instantiate, expected to be a subclass of SCReduxSequencer. In SuperCollider this is interpreted as a class and instantiated.
  • beat: A count of the events that have passed.
  • nextBeat: The SuperCollider clock beat on which the next event will occur.
  • nextTime: The time in seconds when the next event will occur (measured from the previous event).
  • numBeats: The duration of the sequence in clock beats. If the sequence loops, this is the duration of one loop.
  • playingState: One of PLAYING_STATES indicating if the sequence is stopped, queued, playing, etc.
  • isReady: True if the sequencer's resources have initialized and it is ready to play.
  • playQuant, stopQuant, and propQuant: These are the Quant values to determine when the sequencer should quantize play, stop, or property changes.
  • lastPropChangeQueuedAt: A timestamp indicating when a PROP_CHANGE_QUEUED was dispatched.
  • lastPropChangeAt: A timestamp indicating when properties last changed in response to a PROP_CHANGE_QUEUED action.
  • event: The details of the most recently played event from the stream.
  • midiOutDeviceName, midiOutPortName: If the stream is to send events to a midi socket instead of a SuperCollider synth, this is the device name and port.

Sequence Example

docs/queue_sequence_diagram.png

SuperCollider API

All SuperCollider code is included in a quark inside the quarks/supercollider-redux-sequencers directory.

SCReduxSequencer

Plays a stream to a specific clock and with a ReduxEventStreamPlayer. Responds to state changes in the store, scheduling starting and stopping of the event stream player appropriately. To use, create a subclass and implement initStream. Everything else is optional.

MetronomeSequencer : SCReduxSequencer {
  var pat,
    patStream,
    patchSynth;

  initPatch {
    // define a simple synth
    patch = Patch({
      arg freq, amp = 0.0;
      var out;
      out = SinOsc.ar(freq, 0, amp) * EnvGen.kr(Env.linen(0.001, 0.05, 0.3), doneAction: 2);
      [out, out];
    });
    patchSynth = patch.asSynthDef().add();
    ^patch
  }

  initStream {

    pat = Pbind(
      // the name of the SynthDef to use for each note
      \instrument, patchSynth.name,
      \midinote, Pseq([96, 84, 84, 84], inf),
      // rhythmic values
      \dur, 1
    );

    ^pat.asStream();
  }
}

SCReduxSequencerFactory

Watches the sequencers dictionary at the root level of the state tree and instantiates sequencers. Expects a store from which to look for state changes:

var store, sequencerFactory;

store = SCReduxStore.getInstance();
sequencerFactory = SCReduxSequencerFactory.getInstance();
sequencerFactory.setStore(store);

Internal classes:

  • ReduxEventStreamPlayer: This is a subclass of EventStreamPlayer which will dispatch actions each time an event from the stream is played. Very useful for modifying other state based on the playback of a Pattern, for example.
  • SCReduxSequencers: A class providing a static object for action types.

Examples

To run the examples:

npm install

For each example, there is a Node.js script and a SuperCollider script that must be run simultaneously.

Basic Example

This example plays a metronome implemented in MetronomeSequencer.sc. It is now in testMetroExample.js as well.

$ npm run start_example

Parameterized

This example demonstrates one way a SuperCollider pattern can be parameterized through the state store. See ParamExampleSequencer in the quark.

$ npm run start_parameter_example

Sampler

This example demonstrates a sampler that requires samples are loaded. NOTE: This example depends on cs-supercollider-lib. Perhaps best useful for reference.

$ npm run start_sampler_example

Unit Tests

$ npm run test