The game is trodding along. Did more playtesting and the game part is kinda done for now. Better progression, more strategic depth and the UI also got a big improvement. Even has a little AI (that does nothing more than colonize & attack) to test stuff out. But the whole HTML/account/game queue/… stuff is lacking, which I successfully procrastinate. After my girlfriend provided her voice to get some strongly modulated roboty advisor lines “ENEMY … DESTROYED”, I thought some self-made music would be cool, too. What a nice opportunity to learn about digitial synths.
And it’s so easy to get something running! Spit out 440hz sine wave with 48khz f32 samples, and you can get the sound just with zig build run | pw-play --raw --format=f32 --rate=48000 --channels=1 -. Using zig instead of a GUI is also viable, with the incremental compilation you can get quick feedback on change, too. Looks like this:
const drum = drum: {
const mel = &melody6_player;
var note_freq: EventFrequency = .init(&mel.mod);
var vol_adsr: ADSR = .init(.{ .events = &mel.mod, .attack = 0.001, .decay = 0.5, .sustain = 0.0, .release = 0.5 });
var freq_adsr: ADSR = .init(.{ .events = &mel.mod, .attack = 0.001, .decay = 0.01, .sustain = 0, .release = 0.1 });
var noise: WhiteNoise = .init(.{});
var f1: MultiplyAdd = .init(&freq_adsr.mod, .{ .fixed = 2 }, .{ .fixed = 0 });
var lpf: LowPassFilter = .init(.{ .input = &noise.mod, .cutoffs_base = ¬e_freq.mod, .cutoffs_extra = &f1.mod });
var lpf2: LowPassFilter = .init(.{ .input = &lpf.mod, .cutoffs_base = ¬e_freq.mod, .cutoffs_extra = &f1.mod });
var volume: MultiplyAdd = .init(&lpf2.mod, .{ .mod = &vol_adsr.mod }, .neutral);
var gain: MultiplyAdd = .init(&volume.mod, .{ .fixed = 8.0 }, .neutral);
var reverber: Reverber = try .init(&gain.mod, gpa, rnd, .{
.delay = .{ .time = 0.5 },
.min = 0.01,
.feedback = 0.9,
.lines = 32,
.sample_rate = rate,
.wet = 0.25,
.gain = 0.6,
.low_pass_freq = 110,
.high_pass_freq = 110,
.feedback_pitch_shift = -4.0,
});
break :drum &reverber.mod;
};
And with a melody DLS copied from strudel (copied from TidalCycles)
\\4 _ 0 [_ 2] 4 _ [_ 2] 0
\\4 _ 0 [_ _ 2 2] 4 [0 0] 2 _
It sounds like this: https://λ.land/drums.mp3
Also tried some spacy star sparkle sound: https://λ.land/sparkle.mp3
And ambient space wobbles: https://λ.land/space.mp3
Most time was spent on implementing a nice sounding reverb with a pitch shift (and even more time to even find details on how to do it).
