Tuesday, October 24, 2006

For the color blue

--AZ-Sen: Jon Kyl

--AZ-01: Rick Renzi

--AZ-05: J.D. Hayworth

--CA-04: John Doolittle

--CA-11: Richard Pombo

--CA-50: Brian Bilbray

--CO-04: Marilyn Musgrave

--CO-05: Doug Lamborn

--CO-07: Rick O'Donnell

--CT-04: Christopher Shays

--FL-13: Vernon Buchanan

--FL-16: Joe Negron

--FL-22: Clay Shaw

--ID-01: Bill Sali

--IL-06: Peter Roskam

--IL-10: Mark Kirk

--IL-14: Dennis Hastert

--IN-02: Chris Chocola

--IN-08: John Hostettler

--IA-01: Mike Whalen

--KS-02: Jim Ryun

--KY-03: Anne Northup

--KY-04: Geoff Davis

--MD-Sen: Michael Steele

--MN-01: Gil Gutknecht

--MN-06: Michele Bachmann

--MO-Sen: Jim Talent

--MT-Sen: Conrad Burns

--NV-03: Jon Porter

--NH-02: Charlie Bass

--NJ-07: Mike Ferguson

--NM-01: Heather Wilson

--NY-03: Peter King

--NY-20: John Sweeney

--NY-26: Tom Reynolds

--NY-29: Randy Kuhl

--NC-08: Robin Hayes

--NC-11: Charles Taylor

--OH-01: Steve Chabot

--OH-02: Jean Schmidt

--OH-15: Deborah Pryce

--OH-18: Joy Padgett

--PA-04: Melissa Hart

--PA-07: Curt Weldon

--PA-08: Mike Fitzpatrick

--PA-10: Don Sherwood

--RI-Sen: Lincoln Chafee

--TN-Sen: Bob Corker

--VA-Sen: George Allen

--VA-10: Frank Wolf

--WA-Sen: Mike McGavick

--WA-08: Dave Reichert

Sunday, December 04, 2005

1.0d5

New catnip:

Catnip 1.0d5

New since last post:
- now reads G-Forse wave shapes, not all work properly
- now reads G-Force flow fields
- FFT experiments
- added new tri-band wave, draws hi, mid, and lo band waveforms
- wave lines now two-tone
- displacement maps now fade in and out
- feedbacks now set a small random dissipation factor
- fixed full screen mode

Lex and yacc are neat... and cryptic. The Accelerate framework is also neat, and not very cryptic at all.

Friday, November 25, 2005

It's alive

Catnip breathes psychedelic life: Download 1.0d2. A GPU that supports ARB_fragment_program (programmable fragment shaders) is required. ATI Radeon 9600 or Nvidia FX5200 or better. Mac OS X is required, but I'm not sure how new it has to be. I'm working on 10.4.3.

Some bumps along the way:

I burned almost an entire day learning that the texturing wrap feature GL_REPEAT doesn't work for GL_TEXTURE_RECTANGLE_EXT, only the power of 2 texture targets. If you use GL_REPEAT on a rectangle texture, the results are undefined, and on my ATI Radeon 9800 Pro, it behaves rather random and quite frustrating without throwing any errors.

For color processing, I tried using 3D texture maps as 3D color lookup tables so I could do RGB -> HSV, transform in HSV space, then HSV -> RGB all inside a shader program, but the dual 3D lookups proved painful when there appeared to be lots of thrashing going on. I even tried precomputing the RGB->HSV->RGB transform in one 3D lookup table, but that too was still painful. So, I abandoned that idea. It had some pretty cool edge case effects, but performance was unacceptable. I've opted for doing a final rendering pass that uses a 1D texture as a CLUT that simply indexes off the red channel of the pre-rendered frame, making the color effects basically just like MaCthugha, only smoother.

Displacement maps have brought a fun challenge. In order to make them nice and smooth, subpixel resolution is needed, and GPUs will happily interpolate for you. The challenge is in encoding all of that into an RGBA texture with 8 bits per color channel. Since I only need X & Y displacement values, I have 2 additional color channels unused. Combine 2 8 bit color channels and you get 16 bits. Use the 16 bits as a fixed point value and I've got higher precision without any extra space consumed. As it is, a 1024x768 RGBA 8bit texture is 3mb in size. If I went with float pixels, that would be 12mb each. I haven't experimented with any of the other sizes of pixels yet, but this works pretty well. At 12.4 fix point, I get 1/16 sub pixel resolution and a max dimension of 4096x4096. 11.5: 1/32 subpixel, 2048x2048 max dimension. I've opted for 11.5 since some flow maps showed the subpixel quantization.

Friday, November 18, 2005

iTunes visualizers

Apple did a neat thing when they created iTunes and then put the visualizer into it. I mean, it wasn't an original idea, but I thought Apple did it well. At least then they did.

Now, Apple has almost entirely dropped interest in the visualizer end of iTunes. George Warner at Apple Tech Support has said as much. No more support. No more SDK updates. Another fun wrench in the works is that ever since iTunes 4.0, which brought the iTunes Music Store, iTunes won't run with a debugger attached. Screw you plug-in developers. Use printf instead!

Bah! So, here comes the first nugget of info I couldn't find on the internet that I had to go figure out for myself that I now give back to anyone else who happens to be trying to do the same thing. Wanna debug your iTunes visualizer plug-ins in a debugger on the Mac? Go find iTunes 3.0.1. Try here. I don't recommend running the installer to get the contents out. Open the installer package, find another iTunes3 installer package buried in the resources folder, open that one up, find an iTunes3.pax.gz or the like, unpack it, and pull the iTunes.app package out of the Applications folder that popped out of the pax archive. Put the app whereever you like. It will run just fine, even on 10.4.3. It won't be able to grok new iTunes library files, but it won't clobber them either, so you'll have to import some mp3's into the old iTunes library. At this point you can launch this iTunes with gdb or Xcode and debug away.

Update: a friend pointed me at this: How To Debug iTunes with Gdb

Another juicy iTunes visualizer bit is VizKit by Heiko Wichmann. This is an excellently written cross platform C++ iTunes visualizer toolkit based in OpenGL. Well thought out and nicely doxygened. One little caveat with it is that the iTunes visualizer SDK is based on the Windows version, which is newer than the Mac one on Apple's web site, and as such, it won't work with iTunes 3.0.1. I've made some changes to it to allow a compile time switch to be flipped to enable it to work in iTunes 3.0.1, but some of the unicode track information and album art features stop working. I figure this is fine as it still allows you to source level debug the rest of your visualizer code. I'll eventually integrate this back into the VizKit sources.

Thursday, November 17, 2005

OS X Font Smoothing

Love the font smoothing in OS X. I use flat panel displays at work and always enable the 'Medium' font smoothing `cause it looks nicer on the LCD. I have noticed, though, that sometimes fonts aren't smoothed in Medium style, but rather 'Standard' style, like my preference is ignored and the system default is used instead. Examples are system dialogs like Logout, Restart, Shutdown, the Dock, and Dashboard widgets. I'm told this is also true of all PowerPC apps emulated under Rosetta on the MacIntels.

I figured this is because these dialogs were either shown by a system process or by a process created by the system then chown'ed to me, and that the Window Manager was using root's appearance preferences for font smoothing rather than mine.

I tested this theory. I launched System Preferences as root and lo and behold, the Appearance preference Font Smoothing setting was 'Automatic'. I changed it to 'Medium' the way I like it, and lo again, System Dialogs now have 'Medium' smooth fonts. To try it yourself, open the Terminal and type:

sudo /Applications/System\ Preferences.app/Contents/MacOS/System\ Preferences

Enter your password when prompted. Then go adjust root's preferences as needed.

MaCthugha

A long time ago, my good friend Dug turned me on to a neat little program he ran on his linux box called Cthugha. At the time (circa 1994), it was the only thing of its kind, a real time visualizer of sound. He played music through his linux box and swirls of color pulsated on the screen in sync with the music. It was the neatest thing I'd ever seen.

It ran kinda chunky though. I think the screen resolution was something like 320x240 and it ran at a rate of something like 10 fps on his 33 or 66mhz pentium or 486, I'm not sure which. At this point in time, Apple had just released the first generation PowerMacs, and thanks to my internship at Apple, I was lucky enough to have a 7100/80. So my next thought was, "I bet I could make it run faster on my mac." To which Dug replied, "Source code is on the internet. Go download it." So I did.

About a week later, after may late nights in front of my computer in my underwear, MaCthugha came to life, and my PowerMac delivered on the money. 320x240 at 30+ fps, 640x480 at 10fps. I returned my new creation and all of its source code back to the internet.

It wasn't long before I had a bunch of new net-friends who thought I was the coolest. Little did I know I'd end up meeting and becoming good actual friends with quite a few of them, or that it would help me get jobs, or that it would eventually go mainstream with Winamp and iTunes. Since then, a few others, namely Andy O'Meara with G-Force (which kicks a lot of ass, great work Andy!), have jumped in to further this exotic and underappreciated artform. Meanwhile, I get the occasional e-mail asking me about MaCthugha and I then reply with a glum response of how I've let it fall into disuse.

No longer. MaCthugha is making a comeback. Only, since I always hated the name, I'm calling the renewed project Catnip. I think my cat Disco would approve.

Now that I've gotten the history out of the way...

It begins

Quite frequently I find myself determined to do something that, according to the internet, no one has done before. Upon figuring out how to do it, it occurs to me it is a considerable loss to not make that newfound knowledge available to the world at large, better enabling someone to spend less time solving the problems I already have. I know I sure appreciate quick solutions others have been kind enough to post when I go looking for them. Thanks internet. It's my turn to give some back.