|
About Andrew Choi
MIDI Programs
MIDI File Player (External Device)
MIDI Destination Pop-Up Button
MIDI File Player (Internal Synth)
MusicSequence Sample Code
MIDI File Writer
MIDI Name Document Parser
NameConfigSetup
Fish Creek MIDI Framework
MidnamUtility
SysExSenderX
Other Programs
FCBlogEditor
FCBlog and Patch
Chinese Checkers Program
jyut6 ping3 Cantonese Input Method
Cocoa Sample Programs
Syntax Coloring Using Flex
NSTextField and Undo
NSToolbar
Implementing File Import
Launch Application and Open URL
Saving Uncommitted Text Field Edits
Algorithms
Jazz Chord Analysis as Optimization
Optimal Line Breaking for Music
Optimal Chord Spacing
|
|
|
|
A blog where I will write mostly about programming in Cocoa and CoreMIDI, and experiences from my ports of Emacs and XEmacs to the Mac OS.
Saturday September 20, 2003
I played with Guile a little today. I need to know what kind of features I'm missing if I decide not to use it. Guile 1.6.4 builds on Mac OS X after applying a patch in its mailing list archive. Although the build succeeds, important features, many relating to the dynamic loader, are not working.
I ported the Guile-powered turtle graphics toy described in a Guile tutorial to Cocoa. You can download it here. To play with it, type Scheme expressions into the text field and click Evaluate. Try this, for example:
(define (move-n-turn angle)
(tortoise-move 100) (tortoise-turn angle))
(for-each move-n-turn (make-list 9 80))
I also considered some alternatives to Scheme. The tool SWIG seems interesting. So do the programming languages Python, Ruby, and O'Caml.
Friday September 19, 2003
So, how many Scheme implementations can one install in one afternoon? Well, not too many, if you start with Chicken. That's one slow compiler compiling itself! Then I got Bigloo, Guile, and Scheme48 to work.
There are also many smaller Scheme implementations one can play with, such as Bit, libscheme, Siod, and UMB Scheme. These can all be found at the Scheme repository.
I'm looking at Scheme interpreters and compilers because I want to embed one in my MIDI applications. With that I can, for instance, write a MIDI filter that can be customized by the user by changing a few lines of Scheme code. What is a good Scheme implementation for my purpose? One that is small, fast, has good, predictable real-time behavior (difficult in the presence of garbage collection), and release under a liberal license. The last criterion is necessary because I'll be releasing some code under the artistic license and some as a commercial product. Ironically, Guile seems to suit that requirement the best, with its exception clause to the GPL. Then again, I may not want to deal with FSF at all and just go with a smaller implementation like libscheme or Siod. Gimp is very powerful using only Siod. We'll see.
[I spoke too soon: in the CVS, Guile 1.7 is now changed to use the LGPL. Oh well. I'm glad I notice this before I spend a lot of time on it though. ]
Thursday September 18, 2003
Like everyone else, I suppose, I'm receiving more and more spam at my E-mail address. Just today, more than twenty messages arrived from faked Microsoft addresses with .exe attachments. Of course I can't run these on my Mac. I probably can't run them on my latest version of Windows either, which is Win95 :-). Of course I also know it's highly unlikely that they are really security updates. I didn't start using the computer yesterday. Nevertheless it's annoying to get all of this garbage in my mailbox.
I've been using fancy mail splitting in Gnus with a simple set of rules I wrote to detect spam. They weren't particularly effective and missed 30% of the time. But since I was only receiving a handful a day, it was an acceptable solution, sometimes these messages are even amusing to read :-). As it became worst, I knew I needed a better spam filter.
Since I use Emacs/Gnus for E-mail and news (well, I'm kind of obliged to), I now use spam.el in Gnus for spam filtering. Unfortunately it's not included in the CVS version of Emacs so I needed to install the latest version of Gnus from the Gnus homepage. A number of external spam filters can be used with spam.el. Bogofilter looked the easiest to install, so that's the one I chose. To use bogofilter, I needed Berkeley DB, which was easy to install as well.
I've been using bogofilter for a few days. It's already doing surprisingly well! I'm even a little happy to receive some spam because I can use it to train the bogofilter :-). I really shouldn't have put off installing a spam filter for so long.
|
Final Version of SysExSenderX
|
Wednesday September 17, 2003
I finished coding SysExSenderX yesterday. Now it can receive as well as send sysex messages. It has a nice Cocoa document-based application interface. And it has progress indicators for both send and receive. Here is the final version.
I spent a little time improving the design of the program today (how often does one actually do that after a program is finished?). The biggest improvement is a simplification: I've completely removed the delegate/callback mechanism in MySendSysexOp and MyReceiveSysexOp! Callbacks are ugly and error-proned (although I got it to work correctly). For a sysex utility, real-time behavior isn't the biggest issue. Also the need to implement progress indicators actually makes polling a preferable solution: they are there for human observation, which makes latencies of fractions of seconds acceptable. A repeated NSTimer is now started in MyDocument whenever a send or recieve operation begins. When it fires, the progress of the operation is checked and the corresponding progress indicator is updated.
So now the design is very clean. The C structs MySysexSeqSendReq and MySysexSeqReceiveReq prepare the CoreMIDI API for composition into Objective C classes. The Objective C classes MySendSysexOp and MyReceiveSysexOp encapsulate send and receive operations for sequences of sysex messages, respectively. The classes MyMIDIClient and MyMIDIEndpoint deal with initialization of the CoreMIDI system for our application and end points for sysex transfers, respectively. Then, MyDocument is the big controller class that handles all the user interactions.
Tuesday September 16, 2003
Snow in September? You bet!
It started early this morning. It's still snowing as I write this. The forecast says it'll only last a day and we'll be back to temperatures in the high teens in two days!


Meanwhile my Kerr apple-crab is freezing. I'd better pick all ten apples on it. I planted this tree last May after I moved in and I'm quite surprised to see it bear fruit so soon. A few more apples were on it but a hail storm in July (!) got many of them.
There're still a lot of leaves on the trees. So the snow weighs quite heavily on them. Somehow the amazing trees manage. If the snow's too heavy, it falls off. Great design! Here's a picture of the fruits on my American mountain ash. The deer love them. I saw one put its front legs on the fence to reach the higher branches. They must taste good.

Monday September 15, 2003
I wrote code to receive sysex messages today. The lesson learned from working on the code for sending is that one should first work out a good data structure and set of routines in C using Core Foundation calls for the basic engine. A Objective C class can then be wrapped around it. So here is the core I worked out today. In the main window, select the MIDI source, click the Receive and Save buttons to start and stop receiving, respectively. A save panel then let you choose where to save the file containing the sysex data.
The structure MySysexSeqReceiveReq encapsulates a receive operation for a sequence of sysex messages. The operation is initiated by calling receiveSysexSeq and stopped by calling stopReceiveSysexSeq.
The Core Foundation class CFMutableData greatly simplifies the implementation of the callback routine. Although the coreMIDI documentation warns about the effects of memory allocation on real-time performance of a program. We're just dealing with sysex, so I went ahead and used it. No packets seem to be lost.
|
Search this blog with
Lists
Less-Known Facts About Emacs
Emacs Rants
Chinese Restaurants in Calgary
Calgary/Banff Tourist Attractions
C++ Reading List
Science Fiction Series
Top-10 Reason I Stopped Working on Emacs
Top-10 Types of Questions I Get About Emacs
10 Defining Moments as Programmer
Misc
Carbon XEmacs
Emacs for
Mac OS X
|