Possibility and Probability

Python, AI, and other fun stuff

5/20/2004

How to make life easier

Tip 28: Learn a Text Manipulation Lagnuage from "The Pragmatic Programmer" by Andrew Hunt and David Thomas

That's a good bit of advice. When working with Tomcat, I find it helpful to look at the log files when something is going wrong. Tomcat has two places it likes to write output to, the screen window and the log file. And Murphy's law dictates it will always write to the one you are not looking at.

The log files are a pain under Windows, there isn't a tail utility built into the system so if you want to see what's changed you have to reload the file constantly. Which is a pain. I decided to check google to see if anyone has written a tail util for python. There was one and in the comments Kirk Reeves had an improved version of it. I took it and slapped some more code on it and now it is working just fine on the logfiles. Check it out if you are interested.

Its a pretty short little program, yet it does just what I want and its completely readable. To me that's the power of python.

Comment on this post [ so far] ... more like this: [python]

Generated Music

Have you every had an idea and then a little while later you see someone else had the same idea and actually acted on it? That happens to me every now and then, and yesterday it happened again. There's the article on the IBM DeveloperWorks site that talks about using Cellular Automata to create music. About a year or so ago I was brainstorming trying to think of that one elusive "cool" program that I could write. One of the ideas I thought of was a program that could generate techno style music.

To me, techno music sounds pretty mechanical sometimes. (Yes, there are cool song and groups, but I'm talking about overall.) And since a lot of music is programmed into synthesizers, I thought there had to be a way to make a program that could "generate" MIDI's. The only problem is what would make a good source of data?

Simply feeding in strings of random numbers would certainly do the trick, but that probably would make for some pretty interesting (in a bad way) music. I certainly don't think it would be anything one could dance to. :) The only thought I could come up with would be if you could somehow get related data like the grabbing the last 1000 queries into Google and then doing a frequency count on the terms. The most frequent term searched for could be translated into the underlying "beat" for the song (translating meaning somehow turning the word into an MIDI instrument and its' pitch, etc.) and then adding the less frequent terms on top of it as other instruments. (sort of like a guitar that comes in and out of a mix on a song that features a drum and a piano.)

I never implemented it, mostly because I thought there would be a problem with getting a steady stream going. The web is so turbulent I was afraid that the beat/melody of the song wouldn't last for more than a few seconds before degenerating into noise only for a new song to rise up. I guess I could have it loop on that good part, but how do I tell the computer what a good part is?

The article on the IBM website has a really interesting approach. By using cellular automata the program will get a fairly steady stream of data so the underlying beat of the program is more steady (listen to the sound samples).

I'm not real knowledgeable about music theory, but I know what I like. And I think this is an interesting topic. I've heard people in the past comment on how video games could really be more immersive if the music could swell at the appropriate moments in the game (i.e. right before you get attacked by a monster). Perhaps a system like this could "read" the action in the game and then drive the sounds and music. Who knows, the Cellular Automata derived music (and the rules to convert it into MIDI) could be the wave of the future for games.

Comment on this post [ so far] ... more like this: [ai, java]