Wait-based sequencing proof-of-concept test

Wait-based sequencing proof-of-concept test

First step towards a time-signature based sequencer

I quickly created a SuperCollider code to test my idea. It's still in its very basic form, but working correctly.

I am currently not taking measures/bars/beats into account. That will be addressed in future tests.

I will keep this code in this gist

Here is the code:

var index = 0;
var totalPatternTime = 0;
var testSynth;

var events=[
    ( value: 0, time: 0 ),
    ( value: 1, time: 1/4 ),
    ( value: 2, time: 1/2 ),
    ( value: 3, time: 1/8 ),
    ( value: 4, time: 1 ),
    ( value: 5, time: 2 ),
    ( value: 6, time: 1/4 ),
];



Tdef(\seqTest, {

    inf.do {

        var current;
        var next;
        var nextIndex;
        var currentValue;

        index = index + 1;
        index = index % events.size;

        ("current event index: "++index).postln;

        nextIndex = index + 1;
        nextIndex = nextIndex % events.size;

        next = events[nextIndex];


        current = events[index];

        currentValue = current['value'];


        if( testSynth.isKindOf(Synth) ) {
            testSynth.free;
        };

        testSynth = Synth('default', [
            \freq, (60 + currentValue).midicps
        ]);

        totalPatternTime = totalPatternTime + next.time;

        if( index == 0 ) {
            totalPatternTime = 0;
        };

        ("totalPatternTime: "++(totalPatternTime)).postln;

        next.time.wait;

    }

}).play;