Valkyrie Dev Blog #14 – Colors

We’re back again with more progress! A lot of work has still been mostly behind-the-scenes, cleaning and adding some more rigorous validation for simfiles before everything gets passed on to the song controller.

However, one new feature I finally added is note coloring. Anyone who’s played similar games knows that there are different types of notes depending on their beat values. Specifically in StepMania’s format, you have 4th, 8th, 12th, 16th, 24th, 32nd, 48th, 64th, and 192nd notes as the available types. I actually had the logic for this figured out a long time ago, back during I think my first attempt at getting the arrows to scroll correctly, but I just never got around to actually implementing it until now.

So for anyone who cares, I’ll just go into detail on how it works. First, let’s address the thing that might seem weird: why is 192 the last note value? The increases up to that point are significantly smaller, so it probably seems pretty bizarre to have such a massive jump at the end. Referring all the way back to the first dev blog on here, you can see that measure length is variable. I touched upon this a little back then, but here’s a bit more detail:

Let’s note that all of the note types (4, 8, 12, 16, 24, 32, 48, 64, and 192) are factors of 192. That’s the secret – 192 is simply the Least Common Multiple of all of the other note types. That means that if we have 192 lines in a measure, every other note type can be represented using 192nd notes. The 49th line of a 192-line-long measure has a beat value (within the measure) equal to 48/192, or 1/4 i.e., a quarter note! (Beat values actually all get multiplied by 4 at the end, but it’s easier to think about the math without that step, in my opinion.)

So with all that established, the process is: take the beat offset of a given note, then divide it by 1/4. If it goes in evenly, it’s a quarter note. If not, move on to the next note type, 8. Divide by 1/8 and see if that goes in evenly. This will continue until we reach our last valid type, 192. By nature of all of the other note types being factors of 192 (or we could say 1/192 is a factor of all of the other valid types), the division by 1/192 will always go in evenly.

So there’s one to satisfy anyone who’s interested in a bit of math. And just maybe anyone’s who’s interested in learning a bit more about how simfiles work. In other news, this has led to me having to implement a number of new checks during note data validation, such as making sure each measure isn’t a “weird” number of lines (i.e., not 4, 8, 12, 16, etc.). Next feature I’m working on is getting holds (and rolls) implemented. It requires even more validation, so it’s been a bit of work (can’t make any assumptions when dealing with user-modifiable data), but ideally I’ll be able to showcase it in a week. See you then!

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *