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.

Text Completion for Chords
Friday April 23, 2004

The Cocoa API in Panther added a new “text completion” feature for text views (using the F5 function key or option-Esc). Since the field editor that handles text editing for text fields is also a NSTextView, text completion can also be provided for text fields. By default the suggestion list is obtained by matching the current prefix with the system dictionary. Providing one’s own list of completions efficiently requires subclassing NSTextView and implementing a NSWindow delegate.

Here’s a screen shot of my text completion code for chords in action! I’ll integrate this into my chord editor in the next few days. Unfortunately the Cocoa implementation isn’t perfect at this time: part of the suggestion list pop-up box can go off the screen if the text field appears in a lower part of the screen. C’mon Apple...

Chord Editor Prototype
Wednesday April 21, 2004

I now believe that the “chord spacing” algorithm I posted on Monday is more important in producing nice looking chord charts than the “optimal bar layout” algorithm I wrote about last week. Since each line may only contain a few bars, there isn’t a lot of flexibility in placing more or fewer of them. This is similar to typesetting with very narrow lines. On the other hand, chords that don’t lined up at their beats give a sloppy appearance.

Here’s an example of the output produced by the chord spacing algorithm. It’s implementation is somewhat tricky :-)! Layout is simply done by fitting as many bars as will fit on a line.

For the above example, the minimum width for bars is set high enough that all (left sides of) chord names line up exactly with their beats, and all the bars are of the same width, except those on the last line.

Here’s the same example again with a narrower minimum bar width.

Notice how bar 18 (F#m7b5 B7b9) is slightly wider to accommodate the longer chord names. Without such variable-length text fields, some of the chord names will of course be truncated, as in lesser programs :-).

Chord Spacing
Monday April 19, 2004

I’ll let my LaTeX file speak for itself. It’s hard to write about things like this in HTML.

April 2004
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
Mar  May

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