My OS X Programming Blog
Mac OS X Cocoa and CoreMIDI Programming
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.

MIDI Device, Entity, and Endpoint Names
Friday October 10, 2003

I was thinking about how sysex input and output will fit into the ensemble/player model that I've been considering. I now think that perhaps they don’t fit at all! A player is identified by name, MIDI device, channel, and program change. But a “device” for receiving and sending sysex messages is only identified by name and MIDI device. We also probably view these devices as capable of bidirectional transfers in, say, a library application.

So there should be a separate model for sysex transfers (as oppose to MIDI note and control message transfers). Once we've obtained a handle to a “sysex device object” (say the DX-7 II), we can send and receive sysex to and from it. Both source and destination endpoints will be associated with the sysex device. So the calls to the library will look something like this:

[[SysexDevice sysexDeviceWithName:@"DX-7 II"] send:sysexdata];
[[SysexDevice sysexDeviceWithName:@"DX-7 II"]
receive:&sysexdata optionForStopping:opt];

That's the whole interface! We may need to encapsulate the send and receive operation in objects as was done in SysExSenderX.

Again, the CoreMIDI API makes it a little hard to identify such “sysex devices”. So I wrote this program to print out a lot of information about devices, entities, and source and destination endpoints. After looking at the output of this program, I've come up with the following design.

Enumerate all devices (not external devices) in the system. For each device, enumerate all its entities. Consider listing as sysex devices those entities that have exactly one source endpoint and one destination endpoint. If the source and destination endpoints of an entity are both connected to the same external device, we list it as a sysex device using the name of the external device (e.g., DX-7 II). If the source and destination endpoints are not connected to external devices, we list it as a sysex device using the name of the device and entity (e.g., Opcode Studio 4, Port 3). The latter handles cases for which Audio MIDI Setup has not been run. In either case, the source and destination endpoints are remembered internally to implement the send and receive operations.

Free Stuffs!
Thursday October 9, 2003

I've started to read the free book Dive Into Python: Python for experienced programmers today. It's looks like a nice book to skim through after finishing the official tutorial. Go here to look for other free computer books.

Some on-line Scheme books not listed on the above web page are: Structure and Interpretation of Computer Programs, How to Design Programs, and Teach Yourself Scheme in Fixnum Days.

For literature, how about something from the Jack London Collection or a list of public domain books (non-US access)? And of course if you have a lot of time, you should explore the Project Gutenberg.

And for those of you who are learning to write, there's Strunk's the Elements of Style (before it became “Strunk and White” I guess).

For people who cook, how about Farmer's the Boston Cooking-School Cook Book?

MIDI Name Documents and XML Parser
Wednesday October 8, 2003

The MIDI Name Document format is the emerging standard for storing patch and note names of MIDI devices. At some point I'll need to learn it so I thought I might as well do this now. So I looked at this OMS to MIDI name document converter and CherryPicker. And I tried to write a program to parse their output. I read the documentation of Apple's XML parser and this article. The latter contains sample code that demonstrates the use of the parser. Unfortunately that code is more messy than necessary and doesn't print element information. I wrote this new version, which doesn’t have these problems.

Archives and Serializations
Tuesday October 7, 2003

Read Apple's Documentation on Archives and Serializations today.

Their term archives corrresponds to what we generally refer to as serialization. User-defined classes implement the NSCoding protocol to allow their instances to be archived, in a “roll-your-own” fashion. Archives can also handle more complex object graphs.

Their term serialization refers to serializing hierarchical structures formed only with NSArray, NSDictionary, NSString, NSDate, NSNumber, and NSData instances. The ensembles and players I discussed yesterday can easily be made persistent by serialization.

Putting NSPopUpButtonCell's in a NSTableView
Monday October 6, 2003


Here's a screen shot of a test program I've written today. It demonstrates the use of pop-up buttons in a table. It's not very hard to write. But you'll need to read about the difference between controls and cells. It's really quite clever how they use the lighter-weight cells instead of views in table columns and matrices.

The program also shows how to have different menu item lists for different entries in the same column. When you play with it, notice how only two channels are available for a DX-7 II and eight channels are available for other devices.

This program is, of course, also a prototype for an ensemble editor! Following the terminology of Mark of the Unicorn's FreeStyle, an ensemble is a list of players. Each player has a name, and corresponds to a MIDI device, a MIDI channel, and a program change. Note also that the ensemble editor can double as a player library editor (if we need to store a list of electric pianos available in a certain MIDI setup, for example). My next step is to implement drag-and-drop among ensemble document windows so ensembles can be created easily.

October 2003
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Sep  Nov

xml

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


Copyright © 2003, 2004, 2005 Andrew Choi (Contact Information). Created with FCBlog