Code
Archived Posts from this Category
Archived Posts from this Category

I’ve spent my evening concocting an interface skin for Whamb, which is a lightweight audio player for OS X. It is freeware, and works nicely, with a very small footprint. The skin is basically a slapdash of standard UI elements and some iTunes elements. It is meant to be small, easy to use, and fully featured.
If you’d like to download it, go nuts. It is a zipped bundle, and needs to be unzipped and installed in /Library/Application Support/Whamb/Skins to work. You can also put it in the ~/Library equivalent if you want it enabled only for your user. If you want to try the skin out without installing it, just drop it onto the Whamb program logo. This skin may require version 1.2 of Whamb, but I don’t know for sure. When in doubt, upgrade!
I’ve started a project to port my application ForteNight that I wrote a while back to Cocoa for use on OS X. Why? Partly as an interesting side project, and partly so I don’t forget how C! Oh yeah, and I’m also doing it for all those people out there who just need to have a tool available for doing calculations relating to Set Theory, an obscure branch of music theory pioneered by Allen Forte. Granted, there aren’t many (maybe none) but if there are, then they can commence their rejoicing.
This will be an experiment in blending C and Objective-C, which should actually be fairly easy, because Objective-C is just a superset of C, adding exactly one syntactic form, and about a dozen keywords. If code is valid ANSI C, then it is, by definition, valid Objective-C. The challenge will be to integrate this command line code into the OO(Object Oriented) environment of Cocoa, the development framework for OS X that I prefer to use. The code is currently very procedural, which is fine, but it doesn’t lend itself to easy code reuse. OO(Object Oriented) programming principles suggest that code should be broken into logical pieces (objects) that are free to remain ignorant of each other’s internal operations, and use standard forms and methods to communicate with one another. This makes it easy to change parts of a program without breaking other parts, and it facilitates easy reuse of code, making life easier for programmers. It will be interesting to convert the procedural style of ForteNight to an OO(Object Oriented) style.
This will also give me an opportunity to try out CoreAudio and do some more graphics work to generate diagrams and plots of the information. Should be interesting. The project will probably be licensed under the GPL or perhaps a BSD license, open source either way, so anyone who’s curious how it looks under the hood is welcome to take a look once I have some functional code posted. If you’d like to check out the current C code (which should compile happily in a CGI or CLI mode on most *nix’s, including Solaris, Linux and OS X), check out the projects page and scroll down to ForteNight. You can try a live version, and download the code.
3 comments Saturday 05 Apr 2003 | Sam | Code
A new project is in my sights! Not to say that the video project is no longer interesting, but it requires many long hours of rendering. When you look at a little encoding progress bar that boasts 28 hours left for a three pass VBR encode, you can’t do much except wait.
The new project is to help Madalene with some data from her lab. She uses Matlab to do many of her calculations, and Matlab has its own little scripting language for automating procedures and creating more complex algorithms. She has a huge number of data files, each one containing data that needs to be fed into Matlab via a little program someone wrote in its scripting language. Unfortunately, the file outputs Lotus 1-2-3 documents, that are not formatted for easy manipulation. Madalene has to manually input data for over 200 files, and then open up each of the 200-odd Lotus 1-2-3 documents in Excel, copy and paste out the values she needs, and then do her calculations. Any time anyone says to me that they have to hand process 200 files, one thing comes to my mind. PERL!
Perl, as a programming language, is great for processing text files, and gathering up data. It is right up there among the most useful programming languages ever, in terms of day to day usefulness. It really lends itself to little ‘glue’ programs, things that don’t do much besides connect two things that don’t normally connect well. In this case, I have decided to aid Madalene, as well as improve my knowledge of Perl (which is woefully inadequate) by writing a script to go through these hundreds of files, grab the values necessary, feed them to Matlab, gather the output, and produce a single, well formatted Excel document. Not a difficult task for Perl, but it is still of a magnitude that I’ve never attempted before. Assuming all goes well, I’ll come out of it with a better understanding of Perl and Matlab, and the satisfaction of being able to show a bunch of stuffy researchers who The Man is by automating part of their process. Just kidding, they aren’t stuffy researchers, but if I pull this off, I’ll still get to be The Man, for a day or so at least.
4 comments Thursday 06 Mar 2003 | Sam | Code
iScrobbler has been released! Visit the project page for information and download links. Big thanks to the beta testers who helped me iron out some show-stopper bugs today, and for their input on features that are now in the works. I’m too tired to write much, but download and enjoy, people.
2 comments Monday 24 Feb 2003 | Sam | Code
iScrobbler was released into the wild this evening to a group of beta testers. Assuming all goes well for them, it will become available to all in a few days. In the mean time if you have an inkling to check out the source code on anonymous CVS, you can do so at the iScrobbler SourceForge project page. Keep an eye open here and on the AudioScrobbler pages for news concerning the public release.
I’ve been up since 5am (don’t ask), so I’m going to go to bed. To all a pleasant evening, and an enjoyable Monday!
0 comments Monday 24 Feb 2003 | Sam | Code
Damn, I just got boingboinged! I’d say it was the happiest day of my life, but you’d think I was ridiculous (hint: I’m ridiculous).
I suppose that obligates me to make an update on the progress… Its totally functional at the moment, its just got a few main problems:
The password is stored locally in plaintext. Thats not good. If anyone can point me to a good tutorial on storing passwords in the keychain, or in the very least, storing them in the preferences as an encrypted hash or something, I would be very appreciative.
The algorithm for querying iTunes isn’t very efficient. It basically uses a timer to periodically check iTunes to see what its up to. If the song playing is different from the last time the timer saw an update, it prepares and fires off a submission. I’ve got some plans on how to make this more ‘intelligent’. The current plan works, but isn’t as well behaved as it should be.
Some features from the Winamp plugin are missing. Namely the ability to wait a period of time before firing off a submission to verify that you are actually listening to the song, and not just scrolling through songs. Also, the ability to store submissions for sending later if a connection can’t be established is missing.
BUT there is good news! Support for Audion (in addition to iTunes) is in the works already. Applescript is super. If anyone knows of another mp3 player for OS X that is scriptable, let me know, and I’ll probably be able to work it in.
I’ve gotten a few emails from people wanting to beta test. If I don’t respond right away, don’t worry. Unless I get a bazillion requests, everyone who mails me can be a beta tester. Qualifications at the moment would be that you are using iTunes (until Audion support is final), and have a persistent internet connection (since error handling for when a connection can’t be established hasn’t been worked out yet). As soon as I get the password issue worked out, I’ll send out some beta copies for testing, and then once I make sure there aren’t any fatal bugs, I’ll release a public beta.
Also, in case anyone has noticed, audioscrobbler.com is down as of this moment, because RJ is having some issues with his host. “Too much traffic” they call it. I call it a great start for a project. I watched it go from 200 members to close to 1000 in the span of a few days. Anyway, RJ has all his data, and the site will be back up in a day or so, once he works out the host issues.
5 comments Thursday 13 Feb 2003 | Sam | Code
I’ve been up all night messing with a piece of software I’m writing that will generate submissions to the AudioScrobbler database via iTunes. Stay tuned for beta releases this week!
0 comments Monday 10 Feb 2003 | Sam | Code
Did some late night grocery shopping. Its nice because the store is totally empty, save you, the stockers, and a few other late night weirdos. You can hum to yourself, take up all the space in the aisle, argue with yourself about which brand of toilet paper to buy, all without the prying eyes of soccer moms trying to protect their young ones from your raving, maniacal influence.
I bought two monstrous grapefruits. They were only 50 cents each, which I think is a pretty fine deal, considering that they are nearly the size of my head. I ate one of them just now, and it was basically an entire meal.
I’ve been browsing online resources for Cocoa programming, and there are some good ones! In particular, I’m digging the fact that Ranchero Software, authors of the fabulous OS X News Aggregator NetNewsWire, has a large amount of free source code available. They are using a model for their shareware that I think is very realistic. They offer NetNewsWire for free (nag free, of course), then NetNewsWire Pro is the paid version. No ads in the Lite version, just good solid basic functionality. Paying for NetNewsWire Pro gives you a few extra features. The Pro version isn’t actually out yet, but there is a beta available for free right now. This setup is all well and good. Free basic software, paid advanced software, the developer gets some cash, people get good tools, yada yada.
But the hippy in me says “What about open source? You need to give back to the development community!” Then I find that they do give back. Instead of making their entire applications open source, they have released numerous ‘proof of concept’ applications that utilize the core functions of NetNewsWire, wrapped in a very simple application with an open source BSD license. For instance, there is an RSS parsing application. The engine is the same as the one in NetNewsWire, but the interface is just a spot to enter a URL, and then the parsed results. The idea is that anyone wanting to include RSS parsing into their application can use the code from this mini-application very easily. There are also examples and mini-applications for XML-RPC calls, OPML parsing, Syntax coloring, and more.
I think this is a good way to realistically blend open-source ideals and the reality of making a little scratch from your hard work. I applaud and support fully open-source projects, but in the context of a small business shareware model, I think Ranchero software has a good plan. Open source tools and classes for the developers, free software for the masses, and paid software for the people who just gotta have it all, and don’t feel like using the open-source tools to make their own program.
Anyway, I’m not being paid by these guys to hype them up or anything. There is plenty of other crap out there about their NetNewsWire program, I’ve just been learning Cocoa and hunting for resources to help me, and finding things like their little collections of mini-applications is like finding little treasure chests of goodness that I can learn from and utilize in anything I write.
Update: I’ve been trying to use the tag more often when I write technical crap that uses all the little acronyms that we technical people use, that get very confusing, because there are so many. Its a good way to make my markup more semantic, something I’ve been trying to improve. It makes me smarter too, because it ensures that I know what the acronym means! For instance, I’m embarrassed to note that I couldn’t remember what BSD stood for! I’ve been using BSD software for years, and yet I couldn’t remember: Berkeley Software Distribution. In trying to find out what it actually stood for, I stumbled across the amazing Acronym Finder! Their site design is a touch hectic, but it was very useful, and I’m sure it will continue to be useful in the future as I realize just how few of those techie acronyms I actually took the time to memorize.
The uber-beta web version of my Set Theory calculator program is up here. Its just running right off my Mac’s web server right now, so apologies if its slow or down or whatever. But its basically functional. You can enter in a set of notes, and it outputs some cheerfully done calculations! Of course, you can still enter invalid sets and it won’t warn you, the lookup mechanism to return what Allen Forte number your set it doesn’t work yet, and the output page isn’t very pretty. But those are all going to be fixed tomorrow hopefully.
The biggest question you’ll probably have is ‘so what’? Well, I can’t answer that for you. You need to talk to a musician. Preferably a composer or theorist. A performance musician might get it, but it won’t be very useful to them. Oh well, its fun to write, and fun for a few people out there!
Update: Fixed the URL!
2 comments Thursday 19 Dec 2002 | Sam | Code
I will be out of town from Tuesday evening until sometime on Sunday. I’m driving back to Colorado with Madalene to hang out with my parents, and her parents. We leave on Tuesday evening, around 5pm, and hopefully will drive straight through. I’m a bit of a night owl, so I should be able to make the last stretch OK. If not, we’ll just lay the seats down and sleep for a little while.
While in Colorado, I have a lot of things to do, and not much time. See my grandma, eat Tofurky with my newly vegan brother, maybe go skiing, try to see Matt LeFrenchy, set up a Mac for Greg, do homework, and study for my C exam on Monday. Hmm. It will be busy, but good. It would be helpful if I had an iBook, because then I could do my programming homework on the road. Sadly though, I don’t own an iBook (someday though.. Someday..).
I’m currently writing an interesting program for Dennis and Company. It is a program that calculates interesting Pitch Class Sets. Give it a Pitch Class Set, and it will output the inverse set, the complementary set, the Normal Form Set, and the Prime Set Class! Why is this useful you ask? Well, I honestly don’t know. But, Dennis assures me that for Music Composition folks, its useful. I’ll just take his word for it. I’ve been reading about the transformations, and generating algorithms in C to make the transformations. I barely understand ‘why’, but the ‘how’ I’ve got a solid handle on. However, it gets more complex, and I’m at the end of my ability to figure it out on my own, so after I get back into town, I have to convince Dennis to sit down with me and teach me more.
The application currently has no real name, its just sort of called ‘set theory’ at the moment. It also has no offical version number, or documentation, but I’d call it version 0.1alpha if I had to give it a number. Its not even close to being releasable software in any sense of the word.
In the meantime, however, you can download and compile the source code and try out the application. It will compile in most unix systems, including Mac OS X. It is command line only at the moment. You will need to have the developers tools installed if you are doing it on OS X. Otherwise, gcc will work fine, I’ve tested it with gcc 2.95 on a SunOS system, and gcc 3.1 on a Mac OS X.2.2 system. Its reasonably simple, and doesn’t require any weird libraries, so most other ANSI C compilers will probably make sense of it, but no guarantees. The software has no license at the moment, but consider it GPL (which is what it will be released as when finished). Basically, steal the code if you want, but anything you make using the code has to be GPL as well.
Here is the process: Download the source tarball here.
Go into the terminal, or open a shell, and go to the directory you downloaded it to.
Use the command ‘gunzip settheory.tar.gz’ to unzip the file. Now use the command ‘tar -xvf settheory.tar’ to untar the file. Now a directory was created called ‘settheory’ use ‘cd settheory’ to get into that directory.
Here is the tricky part. Use the command ‘gcc settheory.c -o settheory’ to compile the program. If it fails here, or says ‘command not found’ you may not have the developers tools or gcc installed. Too bad, you can email me about it if you need help (though honestly, its not worth it, the program doesn’t do anything useful at all, I’m only posting this to give myself something to do. And maybe it will give you someone to do for a few minutes.) If it worked, you’ll now have a file called ‘settheory’ in the folder. Use the command ’./settheory’ (yes, thats a period then a forward slash, then the word ‘settheory’) to run the program. Enter a pitch class set. A pitch class set is between 3 and 9 numbers, each between 0 and 11. They stand for musical notes, like C, C#, D, D#, and so on. Put spaces between the numbers, and when you are done, hit enter, and you will magically see various other numbers appear, which have mathematical and musical relation to the numbers you entered. Boring huh? If you answered no to that question, you a probably Dennis! Look at the source code too if you want. They are just text files, some have more explanation on why its doing what its doing.
Now that you just wasted a few minutes of your time, go back to whatever it was that you were doing before I distracted you. Have a nice day!
Its almost time for my C programming class. I’m all geared up to bust some phat algorithms. All the bruthas better hit the floor when I whip out my typin’ hands.
I’m currently learning Carbon on my own, but I’m strongly considering moving over to Cocoa. Carbon is based directly on C, so its an easy translation for me. However, Cocoa is much more powerful, and is going to have better future support. Carbon, while still useful, is on its way out, while Cocoa is getting more and more popular. Cocoa is based on Objective-C, which I was nervous about trying to learn at first, but the more I read about it, the more confident I get. It seems that Objective-C is even easier to learn than C++ when starting from a knowledge of C. The number of additions it makes to the language are very small, and its operation is very logical and intuitive. Everything I’ve read about it has people raving about how much more ‘sense’ the language makes than C++, and that someone familiar with C can pick up Objective-C in just a few days.
So maybe I’ll have to go on a book buying spree again, and pick up Learning Cocoa using Objective-C and/or Cocoa Programming for MacOS X. There is some debate about which of those two is the better book, but many people concede that they are both good books, and can complement each other’s strengths and weaknesses. They are both about 20$ each on the used book market, which isn’t too bad.
Oh, and I’m seriously considering trying to get this job as a gardener at the botanical gardens. As much as I love technology, I’m drifting away from wanting to be a ‘technician’ all my life. I think I might like working with plants…
0 comments Monday 14 Oct 2002 | Sam | Code