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 XML, DTD and XML
Friday October 17, 2003

I need to study the MIDI XML so I can start to build a player/ensemble interface that uses patch and note names (instead of bank select and patch numbers). The MMA web site makes the DTD documents available but provides no other documentation. These .midnam documents plus output files the program Cherry Picker produces are probably the only clues to how to interpret these files at this time!

I want to learn enough DTD to understand the MIDI XML DTD documents. So I read this tutorial and this other tutorial. I couldn't say I recommend either of them, but by also consulting the XML specifications, I'm now able to read the DTD files.

Now I have to find a tool to validate the .midnam files, so I can make use of the names stored in them. At least validating an XML document already converted to tree form by the CoreFoundation XMLParser shouldn't be too difficult.

Mule Deer and Coconut Milk Jello
Thursday October 16, 2003

Thought I'd post something different today. Here's a picture of a mule deer who came to visit this morning. This one is probably a year old.

Their favorite food in my backyard are the berries on the cotoneasters and the American mountain ash. I even saw them stand up on their hind legs to eat the latter. That way they can reach five, six feet high, quite amazing! Someday I'll get a picture of that.

I found out how to make coconut milk jello (椰汁糕) yesterday by experiment! This is quite a standard dim sum in Chinese tea houses but the closest one is half an hour away. More than the time required to make some. Here's the recipe:

1 can (400ml)coconut milk
1 packagegelatin (like Knox)
100 mlwater
5 tspsugar
1 tspcoconut extract

Soak the gelatin in water. Warm (but not boil) coconut milk. Dissolve sugar in it. Add coconut extract and combine with gelatin and water. Divide into 4 jello cups. Cool. Stir well. Refrigerate.

Substitute half and half for coconut milk and almond extract for coconut extract to make almond jello!

Here's a «port» of SysExSenderX to use the FCM framework I posted yesterday (you need the updated version). Since the latter is in a separate project, you may need to adjust a few paths in the SysExSenderX project for PB to find it. I've used a relative path to refer to the framework so it should work if FCM/ and SysExSenderX-FCM/ are in the same directory. This code also demonstrates the use of the FCMSetupChanged notification. Open a few document windows, make changes in Audio MIDI Setup, and notice how the popup buttons also change.

Fish Creek MIDI Framework
Wednesday October 15, 2003

I have implemented yesterday's design. I present to you the Fish Creek MIDI (FCM) framework (with Perl Artistic License). It provides a clean and simple API for applications to send and receive sysex data.

The project comes with three (command-line) test programs to demonstrate the use of the framework and exercise the code in it. To build everything, from a shell, type pbxbuild -alltargets in the top directory. The framework and test programs will be created in the build directory.

When a test program is run, the dynamic loader needs to be able to locate the FCM framework. Either move the latter into ~/Library/Frameworks/ or create a link to it there. Alternatively, set the environment variable DYLD_LIBRARY_PATH to the top directory of the framework.

The following is a transcript showing how the test programs can be run.

~/Documents/Programming/FCM/build$ ls
FCM.build FCM.framework NamesAndEntityUIDsTest ReceiveTest SendTest
~/Documents/Programming/FCM/build$ export DYLD_LIBRARY_PATH=FCM.framework/
~/Documents/Programming/FCM/build$ ./NamesAndEntityUIDsTest
Yamaha DX7-II
~/Documents/Programming/FCM/build$ ./NamesAndEntityUIDsTest -u
Yamaha DX7-II, uid = 0xc8669f48
~/Documents/Programming/FCM/build$ ./ReceiveTest 'Yamaha DX7-II' temp.syx
~/Documents/Programming/FCM/build$ ./SendTest temp.syx 'Yamaha DX7-II'
~/Documents/Programming/FCM/build$
Enjoy!

[Fish Creek is the creek that runs behind my house. Kind of appropriate since we're dealing with streams of data, right :-)?]

Design of MIDI Sysex Device API
Tuesday October 14, 2003

Here's a design of an API for sending and receiving sysex messages useful for implementing sysex librarians (such as SysExSenderX) or patch editors/librarians. FCM is just an arbitrary prefix I'm using for now.

@interface FCMClient : NSObject {
...
}

- (FCMClient *)init;
- (void)dealloc;
+ (FCMClient *)sharedInstance;

- (NSArray *)getSysexDeviceNames;
- (NSArray *)getSysexDeviceEntityUIDs;

@end

The singleton FCMClient instance must be initialized before any sysex transfers can occur. Arrays of names and UID's of all sysex devices can be obtained from it.
@interface FCMSysexDevice : NSObject {
...
}

- (FCMSysexDevice *)initWithName:(NSString *);
- (FCMSysexDevice *)initWithEntityUID:(MIDIUniqueID);
- (void)dealloc;

- (BOOL)sendData:(NSData *);
- (void)cancelSend;
- (int)numBytesSent;

- (BOOL)receiveData;
- (NSData *)finishReceive;
- (int)numBytesReceived;

@end
As a simplification of the interface used in the code of SysExSenderX, the “send operation” and “receive operation” objects are incorporated into a FCMSysexDevice object. This works fine because a particular sysex device should really only be performing a send or receive at any given time. Progress reporting is done by polling and and the sendData and receiveData calls are asynchronous. This follows the design proven successful in SysExSenderX.

The last piece of the interface is the notification named FCMSetupChanged in the default notification center. By registering for this notification, code displaying a popup button, e.g., can update the list of sysex device names when the MIDI setup has been changed.

Sysex Device Names
Monday October 13, 2003

Just a short program to post today: an implementation of last Friday's design. Running it prints out appropriate names of all external devices capable of bidirectional sysex transfers. Again the reason for the emphasis on bidirectional transfers is we're interesting in implementing something like a patch librarian. So we must be able to send a sysex message to these devices to initiate a sysex dump, which we then receive, for example.

Fixed a Emacs bug during the weekend too. But that's over on my other web page.

Also, Happy Thanksgiving to my Canadian friends!

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