State synchronization between a replica SuperCollider state store and a primary Redux state store.
npm install supercollider-redux

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.
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.
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.
quarks/supercollider-redux directory.``supercollider
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.
`javascript
import SCRedux from 'supercollider-redux';
const rootReducer = combineReducers({
[SCRedux.DEFAULT_MOUNT_POINT]: SCRedux.reducer,
...
});
`
`javascript
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.
`javascript
const controller = new SCReduxController(store, {
interpretOnLangBoot:
s.options.inDevice = "JackRouter";
s.options.outDevice = "JackRouter";
,`
scStateSelector: mySCStateSelector
});
An enum with the possible values for the ready states of scStoreReadyState, scLangReadyState, scSynthReadyState`.