|
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 ones own list of completions efficiently requires subclassing NSTextView and implementing a NSWindow delegate.
Heres a screen shot of my text completion code for chords in action! Ill integrate this into my chord editor in the next few days. Unfortunately the Cocoa implementation isnt 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. Cmon Apple...
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 isnt 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 dont lined up at their beats give a sloppy appearance.
Heres an example of the output produced by the chord spacing algorithm. Its 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.
Heres 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 :-).
Monday April 19, 2004
Ill let my LaTeX file speak for itself. Its hard to write about things like this in HTML.
|
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
|