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.

Wild Life!
Saturday October 25, 2003

Who needs a dog when you have this?

Final Version of MidnamParserTest
Friday October 24, 2003

This will be the final version of the MIDI Name Document parser for now. It's been checked against all the MOTU .midnam files and it only fails on ones that are not well-formed (!). The following functionalities were added today.

  • MIDICommands can now contain LocalControl, as well as ProgramChange, ControlChange, and SysEx.
  • A bug in recognizing SysEx byte values was fixed.
  • NoteNameList's may contain NoteGroup's, as well as Note's.
  • StandardDeviceMode is now recognized. The parser can therefore handle documents for General MIDI device names now.
There remain a few things from MIDINameDocument10.dtd that are not recognized. I'll leave them for a later time if they become necessary. Notably, ExtendingDeviceNames, SupportsStandardDeviceMode, ControlNameList, and ValueNameList have not been implemented. None of the .midnam documents I found on the Web use them.

Almost Full Feature MIDI Name Document Parser!
Thursday October 23, 2003

Fixed and added many features to MidnamParser. Here is the result. Among the things added are the following.

  • MIDICommands can now contain ProgramChange, ControlChange, and SysEx.
  • DeviceModeEnable and DeviceModeDisable can now be used in CustomDeviceMode.
  • NoteNameList are correctly parsed and UsesNoteNameList may appear in a Patch.
  • The “physical entities” <, >, &, ', and " in names are now correctly converted to the corresponding characters.
In short, the parser can now handle many of the .midnam documents I found on the Web, whether they're generated by CherryPicker or OMSNameDocXML, or converted from FreeMIDI by MOTU. I've checked that it works correctly on .midnam documents for the synths I have. A last bit I need to do tomorrow is to make it parse .midnam documents describing General MIDI devices. These documents use MasterDeviceNames, unlike ones for real synths which use CustomDeviceMode. This should be easy to do.

After working with XML for a few days, I must say I can't understand the big hype on it. It's just regular expressions describing data formats. The dotcom era certainly bred people with little imagination :-).

A MIDI Name Document Parser Prototype
Wednesday October 22, 2003

It didn't take as long as I thought. Here is the MIDI Name Document Parser I started to write. It parses a .midnam file generated by CherryPicker or OMSNameDocXML into an internal Foundation data structure composed only of NSDictionary, NSArray, NSNumber, and NSString components. For now, it dumps a description of that to output to demonstrate what it has parsed. The FCM framework will use this parser in the future to implement patch and note name selection.

[A technical note.] CherryPicker and OMSNameDocXML output files have different forms. CherryPicker embeds a PatchNameList in a PatchBank while OMSNameDocXML puts the PatchNameList at the end of the MasterDeviceNames. This “flexibility” in the definition of MIDINameDocument DTD seems to have very little merit. In any case the parser handles both cases correctly and generates the Foundation data structure in the same form. Once parsed into internal form, the data can be handled uniformly.

MIDI Name Document Parser
Tuesday October 21, 2003

Started to write a MIDI Name Document parser. I got only as far as the CustomDeviceMode element now. The whole thing will probably take a few more days to finish. The purpose of the parser is to read .midnam files such as those generated by CherryPicker or OMSNameDocXML, or those distributed by MOTU, and build an internel data structure so that the FCM framework can make use of it to present patch and note names to the user for selection.

I also looked at a number of tools for working with XML files. Specifically, this XSL document can be used to pretty-print an XML file. To use it, you'll need an XSLT processor. I tried Saxon and Xalan-C++ but couldn't get them to work. Finally I found libxslt which worked for me. I use their xsltproc to pretty-print XML files and xmllint to re-indent XML files. The latter is useful for files such as those generated by the CFXMLTreeCreateXMLData function, which leaves out newlines.

Generating XML Files
Monday October 20, 2003

Wrote some code today for generating XML files using Core Foundation's CFXMLTreeCreateXMLData function. Basically you build a tree using CFTree, CFXMLTree, and CFXMLNode functions and then CFXMLTreeCreateXMLData does everything for you. I know, one can write one's own routines for this or look for a library on the Internet. I'll be manipulating XML trees when I parse .midnam files so I might as well get intimate with the functions and data structures.

Although that looks like a lot of code for generating only a few lines of headers, the hardest part is over. The body of an XML file is represented entirely by kCFXMLNodeTypeElement nodes, although attribute lists, represented by CFDictionary objects, require some more code.

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