Skip to content

Commit

Permalink
Fix #1 - outdated APIs in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
crucialfelix committed Jan 17, 2017
1 parent fc67bb1 commit 31763fa
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 373 deletions.
8 changes: 4 additions & 4 deletions node/dryads/Synth.js
Expand Up @@ -10,12 +10,12 @@ let app = dryadic();

let s = new SCServer({}, [
new SCLang({debug: true}, [
new Synth(
new SCSynthDef({compileFrom: './synthdefs/lfsaw.scd'}),
{
new Synth({
def: new SCSynthDef({compileFrom: './synthdefs/lfsaw.scd'}),
args: {
freq: 600
}
)
})
])
]);

Expand Down
18 changes: 6 additions & 12 deletions node/lang/run-sclang-emitter.js
@@ -1,24 +1,19 @@


/**
* this shows how to capture output of sclang
* and do anything you like with it.
*
* But default sclang.js echoes everything to the console.
* This demonstrates how to write to the input of sclang
* and to capture the output with a handler.
*
* This is raw, low-level stuff. Normally you would use higher level APIs.
*/

var sc = require('supercolliderjs');
var SCLang = sc.lang;

sc.resolveOptions(null, {
sc.lang.boot({
// no STDIN, all input will be programmatic
stdin: false,
// do not echo to console, that's handled here
// By default sclang.js echoes to the console that is sent to it (sclang.write)
echo: false
}).then(function(options) {

var sclang = new SCLang(options);
}).then((sclang) => {

// sclang will emit the 'stdout' event
sclang.on('stdout', function(d) {
Expand All @@ -36,5 +31,4 @@ sc.resolveOptions(null, {
console.log('writing to STDIN: "1 + 1"');
sclang.write('1 + 1');
});

});
79 changes: 40 additions & 39 deletions node/server/patterns/music-with-list-patterns-classes.js
Expand Up @@ -2,63 +2,64 @@
* Port of Patterns example
* http://doc.sccode.org/Tutorials/Streams-Patterns-Events3.html
*
* This is using Pseq and Prand in ./pattern-classes
* This is using the Pseq and Prand classes defined in ./pattern-classes.js
*
* You still have to use `new Pseq`
* You still have to use `new Pseq([...])`
* This could be made even clearer and tighter using and ES7 decorator
* and avoid having to construct a class that only really has one function.
*/
let _ = require('lodash');
let sc = require('supercolliderjs');
let { msg, map } = require('supercolliderjs');
let { withDefs } = require('../utils');
let { Pseq, Prand } = require('./pattern-classes');

let sound = 'help_SPE3_Allpass6';
let defs = {
help_SPE3_Allpass6: {
path: './help_SPE3_Allpass6.scd'
}
let def = {
name: 'help_SPE3_Allpass6',
path: './help_SPE3_Allpass6.scd'
};

withDefs(defs, (server) => {
sc.server.boot().then(server => {
server.loadSynthDef(def.name, def.path).then(() => {

let notePattern =
new Pseq([
new Prand([
null, // a null item reached in a pattern causes it to end
new Pseq([24, 31, 36, 43, 48, 55])
]),
let notePattern =
new Pseq([
60,
new Prand([63, 65]),
67,
new Prand([70, 72, 74])
], () => _.random(2, 5)),
new Prand([74, 75, 77, 79, 81], () => _.random(3, 9))
], Infinity);

const interval = 130;

let noteStream = notePattern.asStream();

function step() {
let freq = noteStream.next();
if (!freq.done) {
server.send.msg(
msg.synthNew(sound, -1, msg.AddActions.TAIL, 0, {
freq: map.midiToFreq(freq.value)
})
);
setTimeout(step, interval);
}
}
new Prand([
null, // a null item reached in a pattern causes it to end
new Pseq([24, 31, 36, 43, 48, 55])
]),
new Pseq([
60,
new Prand([63, 65]),
67,
new Prand([70, 72, 74])
], () => _.random(2, 5)),
new Prand([74, 75, 77, 79, 81], () => _.random(3, 9))
], Infinity);

const interval = 130;

step();
let noteStream = notePattern.asStream();

function step() {
let freq = noteStream.next();
if (!freq.done) {
server.send.msg(
msg.synthNew(def.name, -1, msg.AddActions.TAIL, 0, {
freq: map.midiToFreq(freq.value)
})
);
setTimeout(step, interval);
}
}

step();
});
});




/**
SynthDef( \help_SPE3_Allpass6, { arg freq;
var out, env;
Expand Down
133 changes: 0 additions & 133 deletions node/server/patterns/music-with-list-patterns-decorators.js

This file was deleted.

0 comments on commit 31763fa

Please sign in to comment.