Tuesday, March 23, 2010

DJ Zero

Well I wasted an hour yesterday. I had but a simple goal, to install a crossfader into the sound code for Thief. Instead I got to bang my head bone on the wall for 60+ minutes and have nothing to show for it but a headache and the evaporation of a couple of brain cells.
The idea was basic enough. I was thinking about how to make the music work really well in The Cliff level (see the last post), and I remembered playing DJ Hero, a game I suck at by the way. In it, the player uses a little switch to set the volume of the right and left records into the speaker. So move the little knob to the left and you hear more of the left record and less of the right. So if the musics line up, you can combine them into a different thing altogether. A "Mix" if you would.
So I thought, "Hey, let's play 2 music tracks at the same time and let's make the volume of each a function (used in the mathematical term here) of some other variable. So let's have one be that, and the other be the inverse." The thinking was, if that number was between 1 and 0, then having the variable be set to 0 would be all of one track and none of the other, like pushing the little knob all the way to the left on a DJ Board. The 1, would be all the way to the right and anything in between would be a mix of the two.
Having done some tests on it, it worked out pretty well. At least in theory. I don't have musics that match, but I could get 2 things to play at once.

Then the whole thing was shit.

You see, I then tried to make the twice damned thing controllable. So I installed a little bit into my control code that would allow me to modify that Crossfader variable, and...nothing. It didn't work. So I told the computer to tell me when it was running the code I had just installed. The conversation went like this:

"Hey, computer, are you running that code?"
"What code?"
"The code I just wrote. It's right next to that other code you just ran."
"No it's not."
"No, really, it is. Could you look again?"
"Why?"
"Because I asked?"
"Wait, what are we talking about?"
"The code. Remember?"
"I like kittys."

That's exactly how I remember it anyway. So, like a good little code monkey I copied the whole thing over to a new program. Thief has like, 12000 lines of code, so maybe, just maybe, something else was screwing the pooch. I hit the "Go" button and:

"Hey, no problem now right? I'll push the key for you."
"..."
"Computer, did you see that key?"
"No?"
"Are you asking me?"
"Nooo?"
"So you don't think a key is being pressed?"
"No."
"Really? You're doing this to me? Now?"
"MMmmm...panda cookies."

So I cut the sound code out of the code I was writing. Now we were reduced to just loops - the basic building blocks of almost everything in a computer system. The Bread and Butter that keeps a coder coding, although less oily. So with that done, I mashed the keys, hoping for any sign of intelligence or life. Instead the loop just ran, oblivious to the outside world until I gave opened my razor and gave it the Sweeny.
I'm not sure yet exactly what happened, but I managed to swear a whole lot before I went to bed in a hazy anger, a kind of half hearted digital blood lust.
I'll try again later. Although now I have a crazy jones for those chocolate panda cookies, you know, the ones with the little pandas (or koalas, if you're into that) doing different jobs. I wonder if there is a Code Panda, they'd be the ones with the laptop and the furious eyes.

No comments: