4Chan
Hello everyone! Welcome back to the Daily Devlog, where we go over the new developments in RustyGameGirl!! Let’s get started with today’s broadcast!
White Noise, Brown Noise, Black Noise, Grey Noise, What’s the Difference?
After finishing the two pulse channels, 1 and 2, it was time to start a new one. I went with channel 4 since it is the closest to 1 and 2 in terms of structure and simplicity.
Channel 4 is a randomised noise channel thingy, for stuff, like gunfire maybe? Here’s the summary from Pan Docs:
This channel is used to output white noise, which is done by randomly switching the amplitude between two levels fairly fast. The frequency can be adjusted in order to make the noise appear “harder” (lower frequency) or “softer” (higher frequency). The random function that switches the output level can also be manipulated. Certain settings can cause the wave to be more regular, sounding closer to a pulse than noise.
A lot of channel 4’s machinery is the same as 1 and 2’s, like envelope and length, which brings us to our next section.
Adaptive Water Body
Until today, I have never written a trait in Rust. I’ve used them, of course, especially Default and Drop, but also the num-traits crate from when I was making my fast-factor crate, but I’ve never written one before. I figured now was as good a time as any, especially since all four channels share many similar methods, like the nrxy reads and writes, output (to u8 only), clock_length, tick_period, etc., so I added the three following traits:
trait Channel {
fn output(&self) -> u8;
fn tick_period(&mut self, ticks: u32);
fn clock_length(&mut self);
fn nrx1_read(&self) -> u8;
fn nrx2_read(&self) -> u8;
fn nrx3_read(&self) -> u8;
fn nrx4_read(&self) -> u8;
fn nrx1_write(&mut self, byte: u8);
fn nrx2_write(&mut self, byte: u8);
fn nrx3_write(&mut self, byte: u8);
fn nrx4_write(&mut self, byte: u8);
}
trait ChannelWithEnvelope {
fn clock_envelope(&mut self);
}
trait ChannelSpecificFeature {
fn nrx0_read(&self) -> u8;
fn nrx0_write(&mut self, byte: u8);
}
Having all the separate impl blocks forced and ordered the same makes the code far more readable, and it’s not like this will slow the code, and it sped up the creation of channel 4 and will likely speed up channel 3’s creation.
Notes
Rather unfortunately, since I was coding piecemeal today and I was to lazy (probably b/c of the gudetama shirt I’m wearing), I didn’t start listening to music until ater I was done coding, while I was working on homework (English I think? It was the only real homework I had today since I did most of the rest in class), but a Polyphia song just popped up in my shuffle (Reverie), and I locked in so much harder.
Also, once I started working on the APU, I cracked 4000 SLoC!!! That’s more than my last two projects doubled and combined. It’s also likely the majority of code I’ve written in the 7 years I’ve been programming. I am currently at 4509 SLoC, which is over triple my last two projects combined!
See y’all tomorrow, if not later tonight!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.