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

v1.0.0-alpha.3

Published

State synchronization between a replica SuperCollider state store and a primary Redux state store.

Downloads

38

Readme

supercollider-redux

Build Status Coverage Status

A library for state synchronization between SuperCollider and Node.js using the Flux design pattern. State flows from a primary state store in Node.js to a replica in SuperCollider which can dispatch actions back to the Node.js store.

How it works

Intended for use with a primary state store in Node.js implemented with Redux. Provides StateStore, a replica state store in SuperCollider which leverages supercolliderjs and the API quark to receive state changes.

The Node.js class SCStoreController forwards state updates to a replica running in sclang and receives actions dispatched from it using a separate OSC channel.

Basic state flow

When actions are dispatched from sclang to the replica StateStore instance, they are passed up to the primary Node.js store via OSC, any reducers written in Node.js can update the state which will then be forwarded back to the replica. The primary / replica design promotes all state changes written as reducers in Redux, centralizing the state in the Node.js process.

SuperCollider API

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

SCReduxStore

Implements the state store replica in SuperCollider. Usage:

var store = SCReduxStore.getInstance();

// Subscribing to state changes
store.subscribe({
    var state = store.getState();

    // This method is called whenever state changes.
});


// Dispatching a message to the Node.js store
store.dispatch((
    type: MyActionTypes['HELLO_WORLD'],
    payload: (
        hello: "world"
    )
));

Other classes:

  • SCRedux: Used as a namespace for storing constants like actionTypes.
  • SCReduxTempoClockController: A wrapper for TempoClock which will take a tempo from the Redux store.

Node.js API

reducer

A reducer is provided to store the ready states of the SCReduxStore, sclang, and scsynth:

import SCRedux from 'supercollider-redux';

const rootReducer = combineReducers({
  [SCRedux.DEFAULT_MOUNT_POINT]: SCRedux.reducer,
  ...
});

SCReduxController

A controller class that starts sclang and initializes the SCReduxStore.

import SCRedux from 'supercollider-redux';

const scReduxController = new SCRedux.SCReduxController(store);

scReduxController.boot().then(() => {
    ...
}).catch((err) => {
    ...
});

Parameters may be passed:

  • scStateSelector: An optional selector (intended use with reselect) to control which portion of the state tree is passed to SCReduxStore in SuperCollider. This will be an important performance consideration in any application.
  • interpretOnLangBoot: A string containing SuperCollider code for sclang to interpret immediately on boot. This is important to, for example, indicate which audio device to use.
const controller = new SCReduxController(store, {
    interpretOnLangBoot: `
s.options.inDevice = "JackRouter";
s.options.outDevice = "JackRouter";
    `,
    scStateSelector: mySCStateSelector
});

Constants

READY_STATES

An enum with the possible values for the ready states of scStoreReadyState, scLangReadyState, scSynthReadyState.

Browser API

The browser API exposes the subset of the functionality of supercollider-redux that may be relevant to a browser UI, the actions, reducers, and constants. As a browser cannot spawn a SuperCollider process, the controller class is not exposed.

Example Projects