A Hydra extension for handling SuperDirt RMS events (envelope follower)
This repository contains the source code of a Hydra extension that handles RMS messages sent by SuperDirt, and an OSC-WebSocket bridge application that forwards OSC messages to the browser.
Watch demo:
You will need to download and run a program that bridges between SuperCollider and the browser, forwarding OSC messages through WebSockets. This is necessary because browsers don't currently support the OSC protocol.
Download the latest bridge binary file at Releases corresponding to your operating system (Linux, MacOs and Windows supported) and put it somewhere accesible.
Alternatively, if you have Node installed, you can run from a terminal:
npx hydra-superdirt
Start Supercollider and SuperDirt.
On SC, execute this:
(
// Run this to start sending the RMS OSC messages to SC.
~dirt.startSendRMS;
// The bridge will be listening to OSC messages on port UDP 9130.
b = NetAddr.new("127.0.0.1", 9130);
// This is the RMS OSC handler, here we'll forward these messages to our bridge
OSCFunc({ |msg|
// Forward OSC message
b.sendMsg("/rms", *msg);
}, "/rms");
)
By default, the RMS reply rate (frequency of messages) and peak lag (how long it
takes for the peak values to drop to zero) are 20 and 3, but you can adjust them
with startSendRMS
:
~dirt.startSendRMS(60, 0.4);
You can stop sending RMS events with:
~dirt.stopSendRMS;
Then, start the bridge by executing the binary, which will create a WebSockets server at 8080 and open a UDP port on 9130 by default.
On Hydra, execute first:
// Load osc-js script
loadScript("https://unpkg.com/hydra-superdirt")
Then, to connect:
rmsConnect()
Now, go to tidal and test with
d1 $ s "bd sd"
Then on Hydra, try this:
solid(() => rms(0)).out()
You should see a red tint that fades to black every time the samples are played.
On tidal test something like this:
d1 $ s $ "bd*8"
d2 $ s $ "arpy*2"
Then on Hydra:
shape(30,() => rms(0)).scrollX(()=>rms(1)).out()
You will see a circle scaling with the d1 pattern and then shifting to the left with d2.
-
rmsConnect(port)
: Connect to the WS-OSC bridge. By default it will connect to port 8080, but can be changed. If it's different than 8080, make sure to set--port
with the correct port number when running the bridge. -
rmsDisconnect()
: Disconnect from the WS-OSC bridge. -
rms(orbit)
: Returns the latest RMS value received onorbit
. Whenorbit
is not specified, it will default to orbit 0. If no message has been received yet on that orbit, it will return 0. -
rmsOn(orbit, callback)
: Assigns a callback function whenever a new RMS value is received onorbit
. -
rmsReset(orbit)
: Resets the callback function of an orbit. Iforbit
is not specified, it will reset all callback functions.
You need to install Node and
Yarn. Then, clone the repository, and from within the
cloned directory run yarn
to install all dependencies.
You can start the bridge by running yarn start
or bin/hydra-sc-bridge.js
.
index.js
contains the source code of the Hydra extension.
Bug reports and pull requests are welcome on GitHub at the issues page. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
This project is licensed under GPL 3+. Refer to LICENSE.txt