Skip to content

Instantly share code, notes, and snippets.

@furenku
Created July 31, 2021 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save furenku/c3f7043d1af82fbd281d29f60358ca46 to your computer and use it in GitHub Desktop.
Save furenku/c3f7043d1af82fbd281d29f60358ca46 to your computer and use it in GitHub Desktop.
Wait based sequencing
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment