|
const std = @import("std"); |
|
const ct = @import("ct"); |
|
const gba = ct.gba; |
|
|
|
const square1_2 = struct { |
|
pub const id: [*:0]const u8 = "S2"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square1_3 = struct { |
|
pub const id: [*:0]const u8 = "S3"; |
|
pub const param_0 = ct.Parameter{ .name = "Ln Length (frames)", .min = 0, .default = 4 }; |
|
|
|
var len: i8 = 4; |
|
pub fn press(freq: u32, _: u8, p0: i8, _: i8) callconv(.C) void { |
|
len = p0; |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 8 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
if (t >= len) { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} else { |
|
if (t >= 2 and (t - 2) % 3 == 0) { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = @truncate(6 - ((t - 2) / 3)) }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
} |
|
} |
|
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void { |
|
// When len is a multiple of frames_per_step the last frame won't be executed, |
|
// so make sure to also silence at the end of the release step. |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
}; |
|
|
|
const square1_9 = struct { |
|
pub const id: [*:0]const u8 = "S9"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 8 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 12)).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square1_10 = struct { |
|
pub const id: [*:0]const u8 = "S10"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square1_16 = struct { |
|
pub const id: [*:0]const u8 = "S16"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square1_26 = struct { |
|
pub const id: [*:0]const u8 = "S26"; |
|
pub const param_0 = ct.Parameter{ .name = "Ln Length (frames)", .min = 0, .default = 4 }; |
|
|
|
var len: i8 = 0; |
|
pub fn press(freq: u32, _: u8, p0: i8, _: i8) callconv(.C) void { |
|
len = p0; |
|
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
if (t >= len) { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} else { |
|
if ((t - 1) % 16 == 0) { |
|
// Reduce the envelope every 16th frame. |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = @truncate(4 - (t - 1) / 16) }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
if (t % 3 == 0) { |
|
// Every 3rd frame, tremolo based on evenness, thus looping every 6 frames. |
|
const base: i12 = gba.encodeSquareFreq(freq); |
|
const adj: i2 = @intCast(t % 2); |
|
(gba.CtrlFreq{}).withFreq(@intCast(base - adj)).writeTo(gba.square1); |
|
} |
|
} |
|
} |
|
pub fn release(freq: u32, _: u8, _: u32) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
}; |
|
|
|
const square1_27 = struct { |
|
pub const id: [*:0]const u8 = "S27"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_3_4, .env_start = 15 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 12 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
/// 2, 6, 8, 5 |
|
const square1_35 = struct { |
|
pub const id: [*:0]const u8 = "S35"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 8 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 1 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
10 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
13 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
16 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
19 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
20 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
22 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
25 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
28 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
34 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
37 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
40 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
43 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
46 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
49 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
52 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
55 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
58 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
60 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
61 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
64 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
67 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
70 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
73 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
76 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
79 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
80 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
82 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
85 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
88 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
91 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
94 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
97 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
100 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
103 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
106 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
109 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
112 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
115 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
118 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
/// 3, 7, 9, 6, ..., 5, 6, 7, 8, 9 |
|
const square1_43 = struct { |
|
pub const id: [*:0]const u8 = "S43"; |
|
// Continues sustaining X frames after the release callback |
|
pub const param_0 = ct.Parameter{ .name = "Sustain after release (frames)", .min = 0, .max = 8, .default = 4 }; |
|
// The frame function ramps down after release over 8 frames, this allows cutting it shorter (without silencing the channel). |
|
pub const param_1 = ct.Parameter{ .name = "Release Length (frames)", .min = 1, .max = 8, .default = 8 }; |
|
pub const frames_after_release: u32 = param_0.max + param_1.max; |
|
|
|
var release_frame: u32 = 0; |
|
var sustain_ext_frames: u32 = 0; |
|
var release_len: u32 = 0; |
|
pub fn press(freq: u32, _: u8, p0: i8, p1: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
release_frame = std.math.maxInt(u32); |
|
sustain_ext_frames = @intCast(p0); |
|
release_len = @intCast(p1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
if (t < release_frame) { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 9 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
10 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
13 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
16 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
19 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
22 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
25 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 8 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
28 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 9 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
34 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
37 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
40 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
43 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
46 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
49 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} else if (t < release_frame + release_len) { |
|
switch (t - release_frame) { |
|
0 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
5 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 1 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
7 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 0 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
} |
|
pub fn release(_: u32, _: u8, t: u32) callconv(.C) void { |
|
release_frame = t + sustain_ext_frames; |
|
} |
|
}; |
|
|
|
/// 3, 7, 9, 6, ..., 5, 6, 5, 6, 7, 8 |
|
const square1_48 = struct { |
|
pub const id: [*:0]const u8 = "S48"; |
|
pub const param_0 = ct.Parameter{ .name = "Ln Length (frames)", .default = @bitCast(@as(u8, 158)) }; |
|
|
|
var len: u8 = 0; |
|
pub fn press(freq: u32, _: u8, p0: i8, _: i8) callconv(.C) void { |
|
len = @bitCast(p0); |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
if (t < len) { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 9 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
10 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
13 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
16 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
19 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
20 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
22 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
25 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
28 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 8 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
34 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
37 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
40 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 7 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
43 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
46 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
49 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
52 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
55 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
58 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
60 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 6 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
61 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
64 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
67 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
70 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
73 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
76 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
79 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
80 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 5 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
82 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
85 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
88 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
91 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
94 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
97 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
100 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 4 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
103 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
106 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
109 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
112 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
115 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
118 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
120 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 3 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
121 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
124 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
127 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
130 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
133 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
136 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
139 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
140 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_4, .env_start = 2 }).writeTo(gba.square1); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
142 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
145 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
148 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
151 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
154 => { |
|
(gba.CtrlFreq{}).withFreq(@intCast(@as(i12, gba.encodeSquareFreq(freq)) + 1)).writeTo(gba.square1); |
|
}, |
|
157 => { |
|
(gba.CtrlFreq{}).withSquareFreq(freq).writeTo(gba.square1); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
} |
|
}; |
|
|
|
const square2_2 = struct { |
|
pub const id: [*:0]const u8 = "T2"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square2_3 = struct { |
|
pub const id: [*:0]const u8 = "T3"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square2_4 = struct { |
|
pub const id: [*:0]const u8 = "T4"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square2_5 = struct { |
|
pub const id: [*:0]const u8 = "T5"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 7 }).writeTo(gba.square2); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square2_9 = struct { |
|
pub const id: [*:0]const u8 = "T9"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 1 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const square2_12 = struct { |
|
pub const id: [*:0]const u8 = "T12"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
} |
|
pub fn frame(freq: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 6 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.square2); |
|
(gba.CtrlFreq{ .trigger = 1 }).withSquareFreq(freq).writeTo(gba.square2); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_2_table = gba.wav(0x2266aaeefffffeeaa6668acffeeca633); |
|
const wave_2 = struct { |
|
pub const id: [*:0]const u8 = "W2"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_2_table); |
|
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
6 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave); |
|
}, |
|
8 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_3 = struct { |
|
pub const id: [*:0]const u8 = "W3"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_2_table); |
|
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave); |
|
}, |
|
5 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave); |
|
}, |
|
7 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_4 = struct { |
|
pub const id: [*:0]const u8 = "W4"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_2_table); |
|
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave); |
|
}, |
|
4 => { |
|
(gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_5 = struct { |
|
pub const id: [*:0]const u8 = "W5"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_2_table); |
|
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave), |
|
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
5 => (gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave), |
|
7 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave), |
|
9 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_6 = struct { |
|
pub const id: [*:0]const u8 = "W6"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_2_table); |
|
(gba.WaveVolLen{ .volume = gba.vol_100 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave), |
|
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
5 => (gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave), |
|
7 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_9 = struct { |
|
pub const id: [*:0]const u8 = "W9"; |
|
const table = gba.wav(0xffffffff00000000ffffffff00000000); |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&table); |
|
(gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_11_table = gba.wav(0x010203040506050a0f141e5009121b24); |
|
const wave_11 = struct { |
|
pub const id: [*:0]const u8 = "W11"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_11_table); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave), |
|
3 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const wave_12 = struct { |
|
pub const id: [*:0]const u8 = "W12"; |
|
|
|
pub fn press(freq: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
gba.WaveRam.setTable(&wave_11_table); |
|
(gba.WaveVolLen{ .volume = gba.vol_50 }).writeTo(gba.wave); |
|
(gba.CtrlFreq{ .trigger = 1 }).withWaveFreq(freq).writeTo(gba.wave); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
2 => (gba.WaveVolLen{ .volume = gba.vol_25 }).writeTo(gba.wave), |
|
4 => (gba.WaveVolLen{ .volume = gba.vol_0 }).writeTo(gba.wave), |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const noise_1 = struct { |
|
pub const id: [*:0]const u8 = "N1"; |
|
pub const param_0 = ct.Parameter{ .name = "Volume", .default = 11, .min = 0, .max = 15 }; |
|
pub const param_1 = ct.Parameter{ .name = "Freq Div", .default = 0, .min = 0, .max = 7 }; |
|
// note: noise freq |
|
|
|
var freq_div: u3 = 0; |
|
var freq: u4 = 0; |
|
var vol: u4 = 0; |
|
pub fn press(_: u32, note: u8, p0: i8, p1: i8) callconv(.C) void { |
|
freq = @intCast(note % 12); |
|
vol = @intCast(p0); |
|
freq_div = @intCast(p1); |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_inc, .env_start = vol }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = vol -| 9 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const noise_4 = struct { |
|
pub const id: [*:0]const u8 = "N4"; |
|
pub const param_0 = ct.Parameter{ .name = "Volume", .default = 11, .min = 0, .max = 15 }; |
|
pub const param_1 = ct.Parameter{ .name = "Freq Div", .default = 0, .min = 0, .max = 7 }; |
|
// note: noise freq |
|
|
|
var freq_div: u3 = 0; |
|
var freq: u4 = 0; |
|
var vol: u4 = 0; |
|
pub fn press(_: u32, note: u8, p0: i8, p1: i8) callconv(.C) void { |
|
freq = @intCast(note % 12); |
|
vol = @intCast(p0); |
|
freq_div = @intCast(p1); |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_interval = 0, .env_dir = gba.env_inc, .env_start = vol }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = vol -| 2 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = vol -| 9 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = freq_div, .width = gba.wid_15, .freq = freq, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 7, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const noise_9 = struct { |
|
pub const id: [*:0]const u8 = "N9"; |
|
|
|
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 6 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
5 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
6 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 1 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
7 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_48, .width = gba.wid_15, .freq = 3, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const noise_15 = struct { |
|
pub const id: [*:0]const u8 = "N15"; |
|
|
|
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 9 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 8 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
2 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 7 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 6 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
4 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 5 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
5 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 4 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
6 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 3 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
7 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 2 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
8 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 1 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
9 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_1_8, .env_start = 0 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
const noise_20 = struct { |
|
pub const id: [*:0]const u8 = "N20"; |
|
|
|
pub fn press(_: u32, _: u8, _: i8, _: i8) callconv(.C) void { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 13 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
} |
|
pub fn frame(_: u32, _: u8, t: u32) callconv(.C) void { |
|
switch (t) { |
|
1 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 11 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
3 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 4 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 1, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
5 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 12 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 0 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
6 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 3 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
8 => { |
|
(gba.EnvDutyLen{ .duty = gba.dut_2_4, .env_start = 0 }).writeTo(gba.noise); |
|
(gba.NoiseCtrlFreq{ .freq_div = gba.div_8, .width = gba.wid_15, .freq = 2, .trigger = 1 }).writeTo(gba.noise); |
|
}, |
|
else => {}, |
|
} |
|
} |
|
}; |
|
|
|
pub fn main() void { |
|
ct.registerInstrument(square1_2, 0); |
|
ct.registerInstrument(square1_3, 0); |
|
ct.registerInstrument(square1_9, 0); |
|
ct.registerInstrument(square1_10, 0); |
|
ct.registerInstrument(square1_16, 0); |
|
ct.registerInstrument(square1_26, 0); |
|
ct.registerInstrument(square1_27, 0); |
|
ct.registerInstrument(square1_35, 0); |
|
ct.registerInstrument(square1_43, 0); |
|
ct.registerInstrument(square1_48, 0); |
|
ct.registerInstrument(square2_2, 1); |
|
ct.registerInstrument(square2_3, 1); |
|
ct.registerInstrument(square2_4, 1); |
|
ct.registerInstrument(square2_5, 1); |
|
ct.registerInstrument(square2_9, 1); |
|
ct.registerInstrument(square2_12, 1); |
|
ct.registerInstrument(wave_2, 2); |
|
ct.registerInstrument(wave_3, 2); |
|
ct.registerInstrument(wave_4, 2); |
|
ct.registerInstrument(wave_5, 2); |
|
ct.registerInstrument(wave_6, 2); |
|
ct.registerInstrument(wave_9, 2); |
|
ct.registerInstrument(wave_11, 2); |
|
ct.registerInstrument(wave_12, 2); |
|
ct.registerInstrument(noise_1, 3); |
|
ct.registerInstrument(noise_4, 3); |
|
ct.registerInstrument(noise_9, 3); |
|
ct.registerInstrument(noise_15, 3); |
|
ct.registerInstrument(noise_20, 3); |
|
} |