Monday, August 30, 2010

Generating perfect squares without memorization

Hey, ever had to memorize the perfect squares for a school assignment, to be able to list them all, say, up to like 20 or so, such that you can give them without using a calculator?
I did once, in 8th grade algebra!

Well, I was at least expected to memorize them. But I didn't. Because I didn't need to! I had a generating function for the perfect squares, and for relatively small numbers I could list them without a calculator!

Since the assignment -- a pop quiz -- was just to list the squares of the first 20 counting numbers (so 1^2, 2^2, 3^2, etc.), basically in order, all I needed to do was find some sort of relationship between one square and the next. It's pretty clear that, y'know, the difference between the first two squares (1 and 4) is 3, then the second (4 and 9) is 5, etc. In fact, the difference between any two consecutive perfect squares is consecutive odd numbers!

Now, I bet one or two of you seriously don't believe me on that one. But I'll show you it's for real. Of course, you could just look up a multiplication table, but it'll be a bit more enlightening to do something more like induction to demonstrate.

For a given counting number n, the formula for that value's square is, of course, just n^2.
For the consecutive perfect square, (n+1)^2, that's just (n+1)(n+1).
If we expand that out we have n^2+2n+1, which you might remember as a formula from your high school algebra courses.

Although I don't think memorization is the path to mathematic success, the formula (x+y)^2=x^2+2xy+y^2 comes up often enough that's it's worth recalling. Still, it's not something too hard to figure out either way, if you know what you're doing.

Thus we actually can express the next perfect square in terms of the previous square; note the "n^2" term in it. So we're taking the previous square and adding other terms to it.

What are those other terms? 2n+1, in fact. 2n is an even number, fairly clearly, due to that factor of two you see right there. Adding 1 to it makes it an odd number. Increasing n by one causes 2n+1 to increase by two. Hence, you'll add a consecutively higher odd number to the previous perfect square in order to get the next one; if you list them all starting at 1^2=1, you can get pretty far.

In fact, 0^2=0 and then 1^2=0+2(0)+1=1, so we've demonstrated the initial case. We've also shown it holds for (n+1) too, so let's just try this for (n) then, just to demonstrate that what he have here holds true for all the natural numbers!

n^2=(n-1)^2+2(n-1)+1=2n^2-2n+1+2n-2+1=2n^2 -- hey, we get the initial expression back! It definitely works -- not that this is surprising, since we did in some sense derive it back in high school.

That's basically mathematical induction in a nutshell. Take an expression for (n), demonstrate it works for the initial case (which is generally 1 or 0), and then demonstrate it for (n+1) -- which means it holds for every natural number after the initial case! We've done a few other steps along the way to try to make it a little clearer that the formula works like that, but that's the basic setup.

Lest you stand in awe at undeserved mathematical prowess, at the time I found the pattern, I wasn't interested in formalizing my formula. I just understood that it worked, at least for the numbers I was working with. So don't feel too bad if this is a little bit confusing, especially since I don't have the luxury of LaTeX.

But yeah, you start with 1, add 3 and get 4, add 5 and get 9, add 7 and get 16, add 9 and get 25, add 11 and get 36, add 13 and 49, add 15 and get 64, add 17 and get 81, add 19 and get 100, add 21 and get 121, etc. etc.

This was going to be a blog post on the alcohols I've had recently, but I've still got a few different beer bottles hanging out in the minifridge (and indeed, a couple of them are pretty good), but I didn't want to post it until I'd had all of them, and I didn't want to drink them all at once.

Saturday, August 21, 2010

And another thing!

I was going to maybe blog about the couple of episodes of Project Runway that I've watched, and what I think about the show from what I've gleaned from watching that much of it, but I think the last entry I made says just about all I need to say on the nature of the show.

Well, that and they seem to tend to pick the right 2-3 worst designers, but they always send the wrong one home.

A Rant About Visual Design

Between the two of us, my girlfriend is the one who does the visual design. I'm not much of a visual artist (as one can tell from the couple of times I've posted my own images), which may be the reason that I prefer my visual information to be generally simple and clear.

While browsing through the archives of The Daily WTF, I found a link to a gallery that's clearly tailored for StumbleUpon. It shows a series of "creative resumes" for people in the graphic design field. It's a rather old link -- from 2009 -- but it's new to me, so I figured I'd comment on it

I was surprised that as many people had been defending the designs in the comments as I found. Although they capture visual interest quickly, they almost all feel completely over-designed. The information in them is nearly impossible to glean, and most aren't particularly friendly to black-and-white laserjet printers.

The effect is similar to a person standing on the street with a bullhorn yelling to try to get people to pay attention. Sure, it's loud enough to get attention, but hell if I can ever tell what people using them are saying. It always sounds like a garbled mess.

I would actively reject any such resume if it was put in front of me, if I were in charge of hiring at a decently-sized graphic design firm. That is, I would be turned off by these designs more than a completely plain resume made in 30 minutes in Word. There are a few reasons for this!

  1. It demonstrates that the person making it doesn't understand what the purpose of the resume is for -- to convey specific (written) information about the individual's education and experience. Design that actually obscures the text is counter-productive to that end.
  2. It suggests that the designer's ego cannot be kept in check. "Pffft, I'm not going to tone down my work for the plebes in suits who will be looking over it. If they can't appreciate my genius then maybe they don't deserve it!" Then again, maybe everyone wins if the applicant holds that attitude. Unless, you know, he or she is in need of a job.
  3. The designer probably has a portfolio that can be used to demonstrate situations where more intricate visual designs were appropriately used. The resume does not need to need to speak for itself.
  4. Similar to the first point, what if the applicant, once hired, comes across a design job that requires a relatively minimalistic approach? Can he or she be trusted to do that if the resume implies a lack of restraint?
To put it more succinctly, it's the equivalent of going to a job interview wearing a shirt like this. (I took the courtesy of not embedding it because some people might be concerned about the foul language displayed prominently on it, even if I have no fucking clue how the people who'd give a shit could have found this damn blog.)

Okay, I admit, that was a bit forced and cliche.

In any case, if I had to go through a couple hundred resumes, I would most certainly not try to spend more than a few minutes going through each one. If I had to, in order to get any information out of it, it would go in the pile.

I would not hire most of these applicants to design a website for me, since these resumes suggest that usability principles would go out the window FAST; the site would be cluttered and probably inefficient. ("What do you mean people still use dial-up?")

I might accept this sort of work for a print ad for a growing organization, though, where the main goals are to get visual interest and some level of name recognition. But that's far out of my realm of expertise anyway so I don't feel comfortable making a sweeping statement regarding that.

One comment on that page linked to another one with more modest resume ideas. These are all excellent! They are visually interesting, accessible, and printer-friendly, while also being uncluttered. The focus of the design goes more in choosing the typography and developing a focused layout. I would sooner go with a resume that looked like one of these but only had "lorem ipsum" text over it than the first set of resumes I saw.

I suppose ultimately it's a question of sizzle over steak. Or spending an extra 10 seconds looking at something that takes a full minute more to comprehend.

If there's any good news, it's that most of the entries in the first link seem to be done as non-serious assignments for classes rather than used to seek out actual work. *Phew*

Friday, August 13, 2010

Comments on my recent 8BitCollective uploads

This might be interesting to people who have been working in TFM or are curious about how the heck I make my music. Here's a relatively detailed explanation of the songs that I uploaded, with a bit more emphasis on how they were done in TFM.

Aqueuct of Dragons (from Harmony of Dissonance)

When I first heard the song, I was almost immediately reminded of the boss music from Shadow Dancer for the Genesis. Thus my angle for the song would be to arrange it pretty tightly to the original, but use (steal) the voices from that song. Of course, the main problem in doing so is that Shadow Dancer had sampled drums while TFM does not. I worked with a couple premade drum samples and tried to make them a bit deeper and louder to compensate; both Shadow Dancer and Harmony of Dissonance have rather low-rate sampled drums and as a result sound a bit muffled. Though the low-pass filter on the Genny does a lot to make FM drums less tinny, the drums still have much more treble than Shadow Dancer's rums. It's surprising how much using drums like that and livening up the tempo slightly improve on each song.

It's also slightly inspired by the Bravoo Man boss music from Gunstar Heroes, near the end there. I tried to add echo; doubling up the arpeggios with a delay helps that a lot, while having a second bass voice come in that has slower release and sustain rates helps too.

Iron Blue Intention (from CV: Bloodlines)

Although I did once do a fuller TFM remake of The Sinking Old Sanctuary for this game, the other songs from the game I've remade have all been done using PSGmod2 (which is an emulated tracker for the SN76489 chip that the Genny and Master System, among others, used). I went back to this after a couple experiments with Famitracker, partly as a comparison base. I'm always disappointed that the SN chip doesn't have configurable duty cycles or any sort of PCM playback channel, though, since the bass on the chip is always disappointing; in the bits where it feels like the bass suddenly "cuts out" it's because the chip can't play notes lower than a certain value.

Another thing that always bothers me about the tracker is that it doesn't seem to have a real "release" command; the command that's equivalent always leaves a little bit of noise. For once, though, I was going to try to cut that down by making that command completely silent. It's still a bit frustrating to change the volume for each note release, but can be done.

The tracker (and, of course, the chip itself) have a configurable frequency divider (basically tunes the entire song down an octave) which can be useful for getting those bass notes, but I don't know any easy-to-use replayers for the Genesis that support it! I dunno if that's simply because they got rid of that feature when they cloned the chip for their consoles (doubtful?) or if it's because nobody ever used it so they didn't think to support it. Would love to know if someone knows of a replayer that does support it; it would make my life a lot easier.

You Goddamned Bathead (from Castlevania Chronicles / CV X68000)

An interesting exercise. This is one of those sorts of songs I do that can't easily be converted from TFM into another tracker due to the use of some of the features involved in getting the sound right.

In making this song I decided I wanted to get it to sound at least a little like the version from Chronicles (though I feel that the music from that game tends to sound a bit over-produced at times). Like a lot of -- actually pretty much every -- electronic song out there, the song adjusts the main line's timbre to be higher as the song increases. With a little poking around I found I could get the same effect modifying the frequency multiple and total volume level of the first operator of one of the voices. Since TFM supports changing this every single line, what I ended up doing was modifying the total level every time the note hit and changing frequency basically every measure.

Unfortunately, the tracker doesn't support automatic incrementing and decrementing of these values! I had to input them all by hand (and convert between hexadecimal and decimal numbers). It's not hard so much as a bit laborious, which is why I don't use it much. Incidentally, the maximum volume level is 0 but the maximum frequency is at 15 (starting at 0 for the lowest). This makes it a bit more confusing.

Incidentally the only thing that I did to get a transcription of this one was watch the player output from Hoot in order to get most of the melody lines and then built the song from there. However, what I guess would be considered the "verse" of the song was sped up significantly and added in a reference to Psycho Warrior from one of the GB Castlevanias.

It's not an incredibly complex song. :P

Successor of Fate (Harmony of Dissonance)

I love the volume changes in the original that make the chorus stand out so much. I tried to capture the same feeling of the original in that regard (and the bassy sound that the game had -- hard to do when the percussion's not sampled, as it tends to be more treble than GBA or Genny sampled drums, as I suggeste above!). The main inspiration for the direction of this piece was the overworld music from Shining Force II as it had similar aspects of the original, such as being a bit booming (like in the intro) and having a feeling of more reverb than a lot of Genny songs. It had the advantage of some deep drum samples to getting that sound (which, again also had a lot to do with the GBA game's bassy tone as well). Once again the lack of sample playback in TFM would come to haunt me.

Thus this song actually took a while to get "right" because I kept having to worry about keeping the percussion in balance (I didn't want it to get drowned out, since it needs to be forceful) and to try to get the sort of resonating tone (hey, the Castle is gigantic and the entryway in particular is open; why not have the music for that section be so echoey). Thus I kept a lot of the voices really quiet -- as much as I could, while leaving the percussion super loud.

Some might notice that a lot of the voices sound like they came from Shining Force II. Though I took some stylistic cues from there, I did not actually rip instruments from the game. All were pre-made for TFM and had small modifications done (mainly to increase attack rate and eliminate sharp decays so they don't seem to either "fade in" or "click").

What exactly was taken from that game, then? Most importantly, when notes were released in the song I linked from it above, they didn't use a clean release. Instead the volume was cut significantly (so the note played, though quietly) behind everything else --except the main melody line, which was doubled (much like in Aqueduct above). For the most part the effect is subtle here, but would probably be more noticeable if I'd created a version that didn't have it in it. Separating the individual lines also makes the effect more obvious -- just as it does in the song I patterned it on.

One thing you'll notice is that on the repeat of the chorus the melody comes in a little later; on the transcription I used I'd pushed everything off by a quarter note on one of the lines. I liked the effect here as it was haunting to hear the strings playing on their own with the slightly dissonant note from the melody still resonating; the rhythm of line that then comes in still fits with everything else (it's not like everything's been shifted from downbeats to upbeats or anything), so I think it works.

Incidentally, the slightly distorted "static" tone the organ has at the start of the song comes from the fact that the console produces noise, which is more noticeable when the music playing is quieter. Most of the songs I make are loud enough that this noise isn't really audible, but you can hear it a few places where I cut the volume down on a few other hardware recordings.