⌈⌋ ⎇ branch:  Bitrhythm


Artifact Content

Artifact c8dabf9d1d621a77ae0e19fd627b3349d89f13d9aa6c11e56eae3608aa5626d9:

  • File source/early-attempts.md — part of check-in [12a9bb700d] at 2021-08-11 18:56:04 on branch trunk — Import from git Added a changelog (user: dev size: 2288)

Early Attempts

My first attempt at this project was called bang256 ~ 2016, meant to mess with Renoise's OSC. Its still usable.

The music loop for OSC sequencing. You need to install osc and nanotimer. Alternatively you can use portmidi

var fs = require("fs");
var osc = require("osc");
var NanoTimer = require('nanotimer');
var timer = new NanoTimer();

function bang256(host, port, tempo, lines_per_beat, measure, tracks, title) {

    var udpPort = new osc.UDPPort({
        remoteAddress: host,
        remotePort: port
    });

    udpPort.open();

    var beat = 60.0 / tempo;
    var lines_per_measure = lines_per_beat * measure;
    var tick = beat / lines_per_beat;
    var bangs = 0;
    var count = 0;

    timer.setInterval(function() {
        var bang = (bangs % lines_per_measure);
        if (bang == 0) {
            count++;
        }
        for (var t = 1; t <= tracks; t++) {
            var path = title + "/" + t;
            if (fs.existsSync(path)) {
                var code = fs.readFileSync(path, {encoding: 'utf-8'});
                var f = eval(code);
                f(udpPort, bang, count, bangs);
            }
        }

        bangs++;

    }, '', tick + "s");

}

var argv = require('minimist')(process.argv.slice(2));
var bang256 = require("bang256").bang256;

var host = argv["host"] || "127.0.0.1";
var port = argv["port"] || 8000;
var tempo = argv["tempo"];
var lines_per_beat = argv["lpb"] || 4;
var measure = argv["measure"] || 4;
var tracks = argv["tracks"] || 4;
var title = argv["title"];

bang256(host, port, tempo, lines_per_beat, measure, tracks, title);

To run,

node ./bang256 -host "127.0.0.1" --tempo=120 --lpb=4 --measure=4 --tracks=4 --title=foo

Edit files in foo/1 and foo/2 and foo/3 and foo/4 to create live music with an OSC compatible synthesizer.

Inside the file foo/1

(function (osc, bang, count, bangs, thread) {

    if ([4, 12].indexOf(bang) != -1) {
        var msg = {
            address: "/renoise/trigger/note_on",
            args: [ 1, 1, 38, 127],
        };
        osc.send(msg);
    }

})

https://www.perl.com/pub/2004/08/31/livecode.html/ also uses the ticks approach but uses a message bus for events.
https://github.com/psenough/teach_yourself_demoscene_in_14_days