Skip to content

Latest commit

 

History

History

dryads

@supercollider/dryads

NPM downloads MIT License

Dryadic components for SuperCollider

A dryad (/ˈdraɪ.æd/; Greek: Δρυάδες, sing.: Δρυάς) is a tree nymph, or female tree spirit, in Greek mythology

Dryadic is a framework for writing components that encapsulate all the complexities of loading, state management, dependencies and execution order.

https://github.com/crucialfelix/dryadic

Just as SuperCollider synths have a call graph or UGens, Dryadic has a call graph of higher level components. In Dryadic this is referred to as a tree.

Dryadic is declarative: you specify the resources you want and how they are connected. The framework does the rest. Because it is declarative, you can update your tree while performing and the resources (servers, sounds, synth defs, settings) update live.

Examples

More extensive examples will come with dryadic 1.0

/**
 * This example generates a random sequence and plays the first
 * 4 seconds in a loop.
 *
 * SynthEventList has other tricks not yet shown here yet.
 * You can reschedule or alter the event list while playing.
 *
 * The scheduler can be given different scheduling functions,
 * one of which is this sequential event list.
 *
 * Other versions could use tempo, mathematical formula,
 * non-deterministic, event-by-event scheduling.
 */
const { play, SCSynthDef, SynthEventList, SCServer } = require("supercolliderjs").dryads;

function randomEvent(totalDuration) {
  return {
    time: Math.random() * totalDuration,
    defName: "saw",
    args: {
      freq: Math.random() * 500 + 100,
    },
  };
}

function randomEvents(totalDuration = 60, density = 2) {
  const n = Math.floor(totalDuration * density);
  const events = [];
  for (let index = 0; index < n; index++) {
    events.push(randomEvent(totalDuration));
  }
  return events;
}

// Currently this has to be expressed as a tree of nested dependencies.
// dryadic 2 will make it much cleaner and simpler.
const out = new SCServer({ numInputBusChannels: 0 }, [
  new SCSynthDef(
    {
      source: `
    SynthDef("saw", { arg freq;
      Out.ar(0, EnvGen.kr(Env.perc, doneAction: 2) * Saw.ar(freq))
    });
  `,
    },
    [
      new SynthEventList({
        events: randomEvents(60, 4),
        loopTime: 65,
      }),
    ],
  ),
]);

play(out);

source

Documentation

Documentation

Compatibility

Works on Node 10+

Source code is written in TypeScript and is usable in JavaScript es2018 or TypeScript projects.

Contribute

License

MIT license