Archive for June 17, 2011
Our publisher has asked Barb and me to explore making a 3rd edition of our Python Media Computation book, and in particular, they would like us to talk about and use Python 3.0 features. Our book isn’t a generic Python book — we can only use a language with our Media Computation approach if we can manipulate the pixels in the images and the samples in the recorded sounds. Can I do that in Python 3.0?
The trick of our Java and Python books is that we can manipulate pixels and samples in Java. I wrote the original libraries, which did work — but then Barbara saw my code, eventually stopped laughing, and re-wrote them as a professional programmer would. Our Python Media Computation book doesn’t use normal C-based Python. We use Jython, a Python interpreter written in Java, so that we could use those same classes. We solved the problem of accessing pixels and samples only once, but used it with two languages. We can’t use that approach for the Python 3.0 request, because Jython is several versions behind in compatibility with CPython — Jython is only at Python 2.5 right now, and there won’t be Jython 3.0 for some time yet.
We used our Java-only media solution because it was just so hard to access pixels and samples in Python, especially in a cross-platform manner. Very few multimedia libraries support lower levels of access — even in other languages. Sure, we can play sounds and show pictures, but changing sounds and pictures is much more rare. I know how to do it in Squeak (where it’s easy and fast), and I’ve seen it done in C (particularly in Jennifer Burg’s work).
I have so-far struck out in finding any way to manipulate pixels and samples in CPython. (I don’t have the cycles to build my own cross-platform C libraries and link them into CPython.) My biggest disappointment is Pygame, which I tried to use last summer. The API documentation suggests that everything is there! It just doesn’t work. Pixels work fine in Pygame. Every sound I opened with Pygame reported a sampling rate of 44100, even if I knew it wasn’t. The exact same code manipulating sounds worked differently on Mac and Windows. I just checked, and Pygame hasn’t come out with a new version since 2009, so the bugs I found last summer are probably still there.
What I don’t get is why libraries don’t support this level of manipulation as a given, simply obvious. Manipulating pixels and samples is fun and easy — we’ve shown that it’s a CS1-level activity. If the facilities are available to play sounds and show pictures, then the pixel and samples are already there – in memory, somewhere. Just provide access! Why is computing with media so rarely supported in programming languages? Why don’t computer scientists argue for more than just playing and showing from our libraries? Are there other languages where it’s better? I have a book on multimedia in Haskell, but it doesn’t do pixels and samples either. I heard Donald Knuth once say that the hallmark of a computer scientist is that we shift our work across levels of abstractions, all the way down to bytes when necessary. Don’t we want that for media, too?
So, no, I still have no idea how to do media computation with Python 3.0. If anyone has a suggestion of where to look, I’d appreciate it!
I find intriguing the various claims about brain “calisthenics” or “exercises” that have learning benefits. I’m dubious, but curious about the claims. This one is interesting, not because it showed a positive effect, but because it lasted for “up to three months.”
Three months? That’s a lot longer than working memory, and long-term memory isn’t supposed to have an expiration date. Roger Schank has argued that there must be more than two just levels in the memory hierarchy. (A great example: Why is it that, on a multi-day trip, you can remember your hotel room number or rental car description, but can’t remember it the next week?) This result seems to be influencing one of those middle levels, but isn’t changing long-term memory permanently.
In an award address on May 28 at the annual meeting of the Association for Psychological Science in Washington, D.C., University of Michigan psychologist John Jonides presented new findings showing that practicing this kind of task for about 20 minutes each day for 20 days significantly improves performance on a standard test of fluid intelligence—the ability to reason and solve new problems, which is a crucial element of general intelligence. And this improvement lasted for up to three months.