Managing music for your Palm

To really get the most out of music on your Palm, you need to have good music management software on your desktop machine. A good music manager will automatically find and catalog your existing music. As well, it will allow you to set properties and search (or create playlists) using combinations of properties.

MediaMonkey is a decent music manager for Windows. It offers several choices for viewing your music collection. You can view songs by artist, title, genre or rating. It provides access to Palm devices with a plug-in which allows you to access removeable disks–such as a Palm device connected via “Data Import” or a memory card inserted into a card reader. You can easily move or copy music around, so you can set up a playlist, insert your memory card into the card reader, then transfer it over.

If you are using Linux, then you should look at amaroK, which is a KDE-based music manager. Similar to MediaMonkey, amaroK searches for existing music files. It allows you to organize playlists and to transfer files to a Palm device or memory card (through a card reader). amaroK seems to have slightly better support for getting album art and lyrics than MediaMonkey.

Both of these music programs support a wide range of music formats, including the ubiquitous MP3, but they also support OGG. These programs provide a lot of flexibility which can make dealing with a large music collection much easier. You can easily create smaller playlists (something that will fit on your Palm device), and then download that music to your PDA.

Software warranties

Why doesn’t most software have a warranty? You can find software that comes with warranties and guarantees–just not from a major software company. Many small companies will routinely put a warranty and guarantee on their software, saying that the software will work substantially as specified in the manual or you get your money back.

Try finding that from a major software company–or at least, try finding it as a normal consumer. I’m sure that y0u can get whatever you want if you are a larage corporation and you are willing to negotiate your own contracts. Of course, you’ll be paying a lot extra for warranties or guarantees.

The software I write and sell for my side business comes with a warranty and a 30-day money-back guarantee. It’s the only professional thing to do. Plus you get all upgrades for free, forever (well, as long as I keep writing new upgrades).

Interestingly enough, the lifetime free upgrades also seems to be common in smaller companies. Many years ago, I bought a music composing program (Melody Assistant), which included free upgrades forever. I recently decided to play with it again, so I downloaded the latest version and tried my registration code. It didn’t work any more because the registration system had changed. I emailed them and got a new registration code for free.

In economics, there is the theory of “economy of scale” which says that it is cheaper to produce lots of something than it is to produce a little bit of something. However, there should be a theory of “diseconomy of scale” which says that a large company can’t afford to make small quantities. So a product that might sell 1,000 or even 10,000 copies a year isn’t interesting to a large software company–it won’t make enough money to justify being a product.

– Scott

Practical Computer Science Theory

There are two useful pieces of computer science that are fairly easy to understand. These are the halting problem and P versus NP.

Simply stated, the halting problem says that we can’t (in general) tell whether or not a given program halts. This is important because the two steps in formally proving that a program is correct are to verify that it produces the correct output if it exits (halts) and to show that the program halts for all inputs.

A basic form of the proof of the halting problem starts by imagining that we have a program, called H, which can determine whether or not an input program P halts for all inputs. Then, imagine that we construct a new program H2. H2 takes an input program P and runs H on P to see if P halts. If P halts, then H2 loops forever. If P doesn’t halt, then H2 exits immediately. Now, feed the source for H2 into H2. That creates a contradiction–if H2 halts, then H2 will loop forever. If H2 doesn’t exit, then H2 will quit immediately. Therefore, there is no program H, which means we can’t tell (in general) whether or not a given program halts.

So this means that we will have problems trying to prove programs correct, but what are the practical implications? It turns out that a lot of checking that we would like to have the compiler do is equivalent to solving the halting problem. For example, it would be nice if a C / C++ compiler could detect any dereferencing of a NULL pointer. However, this is equivalent to solving the halting problem. Imagine that you have a new compiler, called N, which can determine whether or not a given program P dereferences a NULL pointer. Run N on P. If P does not dereference a NULL pointer, then create P2, which is P plus a NULL pointer dereference right before P exits. Now run P2 through N. If P2 dereferences a NULL pointer, then P2 halts. Otherwise, P2 does not halt. Thus, checking for dereferencing NULL pointers is equivalent to solving the halting problem, which means that it can’t be done (in general). The same goes for all sorts of other useful checks.

The other part of computer science theory I want to talk about is P versus NP. Some people call these “Possible” and “Not-Possible”, but the letters actually stand for Polynomial and Non-Polynomial. This refers to the complexity of the best known solution.

There is an entire class of problems called NP-complete. These problems are isomorphic to each other. If you can solve one of them, you can solve them all. For these problems, then best known solution is non-polynomial, which means that they become computationally intractable at very small sizes. One of the classic problems is the travelling salesperson. A salesperson wants to minimize the cost of travel between various cities (cost can be the cost of plane tickets or the time it takes to travel between the cities). Finding the optimal itinery to visit each city is NP-complete. Basically, the only completely correct algorithm is to check every possible path to see which is the cheapest.

If you find that the problem you are working on is NP-complete (equivalent to one of the known NP-complete problems), then you have two choices. You can stop looking for a good solution, or you can get ready to receive your Turing award and the appreciation of many programmers.

– Scott

Locating commands with a simple Python script

This script is pretty simple. It lets you find commands by entering a string. Any commands which contain that string will be displayed. For example, running python cmdfind.py find returns:

./cmdfind.py
/sbin/findfs
/usr/X11R6/bin/find
/usr/X11R6/bin/find2perl
/usr/X11R6/bin/findsmb
/usr/X11R6/bin/gst-typefind-0.8
/usr/X11R6/bin/xfindproxy
/usr/bin/find
/usr/bin/find2perl
/usr/bin/findsmb
/usr/bin/gst-typefind-0.8
/usr/bin/xfindproxy
/usr/kde/3.3/bin/dcopfind
/usr/kde/3.3/bin/kappfinder
/usr/kde/3.3/bin/kfind
/usr/qt/3/bin/findtr

Here is the script itself:

#!/usr/bin/python2.3

“”"
This script does a partial search for a command name in your path.

Usage:
cmdfind
cmdfind –help
“”"

import sys
import glob
import os

def find(name):
“”"This scripts searches for the name in your path.”"”

search_pattern = “*” + name + “*”
initial_path = os.environ[’PATH’].split(’:')

# Strip duplicates
path = { }
for dir in initial_path:
path[dir] = dir
files = [ ]
for directory in path.keys():
glob_pattern = os.path.join(directory, search_pattern)
files.extend(glob.glob(glob_pattern))

# Sort and remove duplicates
final_files = { }
for file in files:
final_files[file] = file

commands = final_files.keys()
commands.sort()
if len(commands) > 0:
print “\n”.join(commands)
else:
print “No commands found.”

if __name__ == ‘__main__’:
if len(sys.argv) == 2 and sys.argv[1] != ‘–help’:
find(sys.argv[1])
else:
print __doc__

Note the use of dictionaries to create a list without duplicates. This is a trick I picked up from the Python Cookbook. The second instance of stripping duplicates probably isn’t needed–if the original path was stripped, then the final outputs should be stripped as well.

The other trick I like is using the __doc__ string as the usage message.

This script shows the power of the “batteris are included” philosophy in Python. The libraries provide enough power to make a script like this easy to write. The nice part about scripting languages is the easy integration with the shell and the operating system.

Book News:
Palm and Treo Hacks is now available for purchase at Amazon! It actually went live yesterday. The page has changed from “preorder” to “this title usually ships within 24 hours”. I’m going to start scouting book stores now to see when it shows up.

– Scott

Palm and Treo Hacks Released

I got my first copy of Palm and Treo Hacks in the mail on Friday.

Scott holding Palm and Treo Hacks

I like the way the book came out. Hopefully, I will get to do some talks or demos around town. The book should be in stores within 1-2 weeks. You can also preorder it from Amazon or Powell’s.

Palm Robots

There are a couple of ways that you can make a robot with a Palm OS device. There is the Palm Pilot Robot Kit, which converts an older Palm device into a robot. You can buy commercial kits from Acroname. This gives you a small little robot that you can control by writing programs on a Palm device.

You can also get tips and techniques for designing and building your own robot from scratch from the PalmBot site. This was written by a college student who designed and built his own robot using a Palm device as the brains.

Another choice is to use Lego Mindstorms to build a robot with, then use your Palm device to control it. For simple controls, you can use a program like OmniRemote to turn your Palm device into a remote control. You will need to find the IR codes for the Mindstorms remote or put OmniRemote into learning mode. You can also get the pbrick library, which provides an API for communicating between a Palm device and a Mindstorms robot. The pbrick library only works with older (pre-OS 5) devices–it might be a good reason to resurrect that old Palm you have stashed in the closet.

– Scott

Palm Music Hack

So, a Palm device isn’t an iPod, but it can still play music. One nice iPod feature that is missing from Palm music players is the ability to rate the music. Music that is more highly rated is played slightly more often than music that isn’t.

There is an easy hack to get a similar feature on a Palm music player. Create a play list (if you haven’t already done so). On the play list, you can add a song multiple times. Thus, you can hear the songs you like better more often than the other songs.

I turned in my changes to the second (and hopefully final) set of page proofs today for Palm and Treo Hacks. I think this means that the books will be printed soon and in bookstores shortly thereafter.

First programming lessons

If our twins were old enough for me to teach them how to program now, then I would be teaching them Python. 15 years ago (has it really been that long?) when I was in college, I taught some of my friends how to program in C (yes, that parses both ways: I taught some of my friends how to program and I taught some of them C). But Python has a lot of advantages for teaching a beginner the fundamentals of programming.

I won’t teach the boys how to program so that they will become programmers–if they ultimately decide to become professional programmers, that will be their choice, not mine.

But in the same fashion that we will teach our children to read, write, and make music, I will also teach them the basics of programming. Programming is a useful mental exercise, and it can be directly useful in a number of jobs (science, web design, working with spreadsheets).

Python is powerful (as are all of the scripting languages) and easy to read. The complexity in Python isn’t in its syntax. As with other scripting languages, Python takes care of memory management for you. For teaching someone the concepts of programming, that is useful. For most non-professional programmers, that is a bonus as well.

Did you know that there is a version of Python available for Palm OS? It is called pippy. Unfortunately, the project doesn’t seem to be active at the moment, which is too bad. It would be nice to have a more complete (or at least better-documented) version of Python to play with on my PDA. Maybe I will work on it in my copious amounts of spare time (notice that we have twins, if you want the context for that statement).

My book, Palm and Treo Hacks should be coming out soon. I have checked the first set of page proofs and sent my comments back. As far as I know, that is the last writing-related thing I need to do before the book is published. Scott Berkun had some comments about writing and publishing a book in his blog. One of the comments I have been feeling the truth of recently is that publishing is a lot of hurry-up-and-wait. There is an explosion of busyness (getting chapters done, sending in figures) and then a period of active waiting. Palm and Treo Hacks is now listed on Powell’s web site, which is very cool.

– Scott

Home

My name is Scott MacHaffie. I live in Tigard which is just outside Portland, Oregon, with my wife and our twin boys.

I learned to program 25 years ago. I’ve been getting paid to program for the past 18 years. I have a B.S. in Computer Science from University of Washington and an M.S. in Computer Science from Portland State. I have studied human-computer interactions and user interface design for 15 years.

I have specialized in working on graphical user interfaces (GUIs) for scientific, engineering, and technical applications. I currently work on Maestro, the GUI for chemistry applications at Schrodinger, Inc. My first internship was working on a chemistry GUI for Tektronix, in the Computer-Aided Chemistry (CAChe) group. It’s a small world.

I am also the author of the forthcoming O’Reilly book Palm and Treo Hacks. Hopefully, I will get to do some talks or demos around town when it comes out. Currently, it looks like the book will be out at the end of October or early November. But what do I know–I’m only the author.

I will be writing about programming, GUI design, Python, Palm OS, Gaelic, Irish history, and anything else I can fit in here.

Welcome!