volume_guard1 = guard([-20,15])
Tone.Master.volume.value = volume_guard1(Math.round(dials[0]["cell"]() * 30) -20);
intro = [
cellx("p x000 0000 0000 0000 "),
]
main = [
cellx("p x[2;^C2;+0.01]000 0000 x[0.1]0x[1]0 00x[1]0 "),
cellx("p 0000 x000 0000 x000 "),
cellx("p x0x0 x0x0 x0x0 x0x0 "),
cellx("p x000 0000 0000 0000 "),
cellx("p 0000 0000 0000 0000"),
cellx("p 0000 0000 0000 0000"),
]
bass = [
cellx("p x[2;^C2;+0.01]000 0000 x[0.1]0x[1]0 00x[1]0 "),
cellx("p 0000 x000 0000 x000 "),
cellx("p x0x0 x0x0 x0x0 x0x0 "),
cellx("p x000 0000 0000 0000 "),
cellx("p x[^B2]x.00 x[^B2]x.x[^B2]x. x[^B2]x.x[^B2]x.x[^B2]x.0 "),
cellx("p 00x[^D3]0 000x[^A2] 00x[^A2]x[^A2] 0x[^A2]0x[^A2] "),
]
end = [
cellx("p x[2;^C2;+0.01]000 0000 x[0.1]0x[1]0 00x[1]0 "),
cellx("p 0000 x000 0000 x000 "),
cellx("p x0x0 x0x0 x0x0 x0x0 "),
]
solo = [
cellx("p 0000 0000 0000 0000"),
cellx("p 0000 0000 0000 0000"),
cellx("p 0000 0000 0000 0000"),
]
fin = solo;
endgame = [
cellx("p x[2;^C2;+0.01]000 0000 x[0.1]0x[1]0 00x[1]0 "),
cellx("p 0000 x000 0000 x000 "),
cellx("p x0x0 x0x0 x0x0 x0x0 "),
cellx("p x000 0000 0000 0000 "),
cellx("p x[^B2]x.00 x[^B2]x.x[^B2]x. x[^B2]x.x[^B2]x.x[^B2]x.0 "),
]
empty = cellx("p 0000 0000 0000 0000")
function once () {
const setup = ( instance ) => {
var intro = []
var main = []
var bass = main
var solo = bass
var end = []
var count = 0;
var old_scene = "";
let x = 100;
let y = 100;
instance.setup = function() {
var x = instance.createCanvas(700, 410);
x.canvas.style.position = "absolute";
instance.frameRate(2);
intro.push(instance.loadImage('/closed/intro/1.png'));
intro.push(instance.loadImage('/closed/intro/2.png'));
main.push(instance.loadImage('/closed/main/1.png'));
main.push(instance.loadImage('/closed/main/2.png'));
main.push(instance.loadImage('/closed/main/3.png'));
end.push(instance.loadImage('/closed/end/1.png'));
end.push(instance.loadImage('/closed/end/2.png'));
};
instance.draw = function() {
if (old_scene != current_scene) {
old_scene = current_scene;
count = 0;
}
// instance.clear();
var c = eval(`${current_scene}`)
// instance.image(c[count], 0, 0);
count += 1
count = count % c.length;
};
};
let myp5 = new p5(setup, document.getElementById('canvas-container'));
Tone.Master.volume.value = -30
dials[2]["cell"](1)
mem["master_filter"] = new Tone.Filter(10000, 'lowpass', -96);
mem["master_stereo"] = new Tone.StereoWidener({width: 0.50});
dials[2]["cell"].onChange(function (e) {
var val = parseFloat(e["data"].value);
var cutoff_guard = guard([10, 20000]);
mem["master_filter"].frequency.value = cutoff_guard(val * 10000);
})
dials[3]["cell"](0)
dials[3]["cell"].onChange(function (e) {
var val = parseFloat(e["data"].value);
var volume_guard1 = guard([0,1])
audio.master.in.gain.value = volume_guard1(val / 10);
})
mem.master = new Tone.Channel({channelCount: 2, volume: -10}).chain( mem["master_filter"], mem["master_stereo"], Tone.Destination);
Sample("k", 0, null, -5);
Sample("sn1",1, null, 0);
Sample("h",2, 5000, -35);
Sample("m",3, null, -15);
Sample("f",4, null, -15);
name = "s"
filter = 2000
volume = -15
mem[name + "_filter"] = new Tone.Filter(filter, 'lowpass', -96);
mem[name + "_delay"] = new Tone.FeedbackDelay("4n", 0.4);
mem[name + "_channel"] = new Tone.Channel({channelCount: 2, volume: volume, pan: -0.25}).chain(mem[name + "_filter"], mem[name + "_delay"], mem.master)
samples[5].connect(mem[name + "_channel"]);
hit_map[name] = 5;
Sample("manager",6, null, -15);
Sample("order",7, null, -15);
Sample("cr",8, null, -15);
Sample("piano",9, 400, -15);
Sample("sitar",10, 5000, -15);
const audio = Audio();
const three = ThreeOhUnit(audio, "sawtooth", {
"cutoff": 78,
"resonance": 15,
"envMod": 4000,
"decay": 0.5
}
)
audio.master.in.gain.value = 0;
mem["three"] = three
// cutoff [30, 700], 400
// resonance: [1, 30], 15
// envMod: [0, 8000], 4000
// decay: [0.1, 0.9], 0.5
dials[1]["cell"](0.07825)
dials[1]["cell"].onChange(function (e) {
var val = parseFloat(e["data"].value);
cutoff_guard = guard([30, 700]);
three.params.cutoff.value = cutoff_guard(val * 1000);
})
}
function tweak() {
var snare_count = cellx(16);
snare_count.onChange(function (e) {
var val = parseInt(e["data"].value);
if (val == 22) {
current_scene = "fin";
p1(8, null, null, 12.25);
} else {
p(1, null, null, "4n")
}
})
Mousetrap.bind(['f2'], function(e) {
snare_count(snare_count() + 1)
if (snare_count() <= 20) {
setTimeout(function () {
p(0, null, null, "24n", null );
setTimeout(function () {
p(8, null, null, "2n" );
p(10, 0.5, "A2", 1);
}, delta * 2)
}, delta * 1.5)
}
return false;
})
}
transition = once;
if (bars <= 2) {
current_scene = "intro";
} else {
// mem["three"].step("off");
if (bars == 3) {
eval_guard ? cue("Start intro") : "";
current_scene = "intro";
}
if (bars == 5) {
eval_guard ? cue("Start drums") : "";
current_scene = "main";
}
if (bars == 12) {
eval_guard ? cue("Add bass"): "";
current_scene = "bass";
}
if (bars == 32) {
eval_guard ?cue("Reverse "): "";
current_scene = "bass";
}
if (bars == 42) {
eval_guard ? cue("End "): ""
current_scene = "end";
}
if (bars == 46) {
eval_guard ? cue("Solo "): ""
current_scene = "solo";
}
transition = tweak;
}
patterns = eval(`${current_scene}`);
always();
if (track_no == 1) {
if (count == 0) {
cue("Sample")
// p1(8, null, null, 12.25);
}
}
if (isHit) {
if (current_scene == "intro") {
if (track_no == 1) {
p(3, null, null, "1n");
}
} else if (current_scene == "fin") {
} else if (current_scene == "solo") {
} else if (current_scene == "end") {
if (track_no == 1) {
p(0, meta[tick]["volume"], meta[tick]["pitch"], "24n", meta[tick]["delay"] );
}
if (track_no == 2) {
p(1);
}
if (track_no == 3) {
p(2)
}
} else if (current_scene == "main") {
if (track_no == 1) {
p(0, meta[tick]["volume"], meta[tick]["pitch"], "24n", meta[tick]["delay"] );
}
if (track_no == 2) {
p(1);
}
if (track_no == 3) {
p(2)
}
if (track_no == 4) {
p(3, null, null, "1n");
}
if (track_no == 5) {
if (meta[tick]["pitch"]) {
mem["three"].step({"glide": true, "accent": false, "note": meta[tick]["pitch"]});
} else {
mem["three"].step("off");
}
}
if (track_no == 6) {
p(5, null, meta[tick]["pitch"], "1n");
}
} else if (current_scene == "bass") {
if (track_no == 1) {
p(0, meta[tick]["volume"], meta[tick]["pitch"], "24n", meta[tick]["delay"] );
}
if (track_no == 2) {
p(1);
}
if (track_no == 3) {
p(2)
}
if (track_no == 4) {
p(3, null, null, "1n");
}
if (track_no == 5) {
if (meta[tick]["pitch"]) {
mem["three"].step({"glide": true, "accent": false, "note": meta[tick]["pitch"]});
} else {
mem["three"].step("off");
}
}
if (track_no == 6) {
// p(5, 0.15, meta[tick]["pitch"], 1);
// p(9, 1, meta[tick]["pitch"], 1);
}
}
}