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.

Supported Chord Types Revisited
Friday May 21, 2004

I’ve chosen for my accompaniment generation program to support the following list of chords for now. This list is derived from statistics collected over hundreds of BiaB files of jazz standard chord charts obtained from the Web, and represent over 99.5% of the chords used in them.

(Maj) Maj7 Maj9
6 69
sus

m m7 m9 m11 m6 mMaj7

7 9 13 7b9 13b9 7#9 13#9 7b5 9b5 7#5 9#5 7+ 9+ 7#5#9 7b5b9 7#5b9 7b5#9 7sus 9sus 7#11 9#11

m7b5 dim

+ aug

So what should the program do when it imports a BiaB file containing unsupported chords? Currently they are substituted with ones that are supported. Of course this may alter the harmonic intent. The user is informed when substitutions are made. He can then edit the chords in the chord editor. Here’s a screenshot of that alert sheet.

C++ Reading List
Wednesday May 19, 2004

Here’s a list of books I believe one should read to become good at C++. And yes, you have to read them all except the last few. Next time someone criticizes C++, ask him how many of these books he has read. That will be a good gauge of the credibility of the criticism.

Accelerated C++: Practical Programming by Example. A. Koenig and B. Moo. Addison-Weseley. 2000.
[Read this book to learn C++ quickly.]

The C++ Programming Language (Special 3rd Edition). B. Stroustrup. A-W. 2000.
[Self-explanatory.]

Effective C++ (2nd Ed.). S. Meyers. A-W. 1997.
More Effective C++. S. Meyers. A-W. 1995.
Exceptional C++. H. Sutter. A-W. 2000.
More Exceptional C++. H. Sutter. A-W. 2002.
[Read these to learn to use various elements of C++ correctly.]

STL Tutorial and Reference Guide: C++ Programming with the Standard Template Library (2nd Ed.). D.R. Musser, G.J. Derge, and A. Saini. A-W. 2001.
[Read this to learn to use the STL.]

Effective STL: 50 Specific Ways to Improve Your Use of the Standard Template Library. Scott Meyers. A-W. 2001.
[Read this to learn to use the STL correctly.]

Modern C++ Design. A. Alexandrescu. 2001.
[Read this to learn what C++ templates can do (I know, the book is also about design patterns). If you do not read this book, at least read something about generic programming and templates, e.g., implement your own STL containers, template expressions, etc.]

Multi-Paradigm Design for C++. J.O. Coplien. A-W. 1999.
[Read about program design using C++.]

Design Patterns: Elements of Reusable Object-Oriented Software. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. A-W. 1995.
[Of course this is the "gang-of-four" book, and not a C++ book. But with all that C++ you’ve learned, this book will teach you practical object-oriented design. Design patterns are not software engineering, and will better deliver on the promise of bridging the gap between coding and design.]

The Design and Evolution of C++. B. Stroustrup. A-W. 1994.
Ruminations on C++. A. Koenig and B. Moo. A-W. 1997.
[Read the rationale of design decisions that went into the language.]

C++ Gems: Programming Pearls from The C++ Report. S. B. Lippman (Ed.). SIGS Books. 1997.
More C++ Gems. R.C. Martin (Ed.). SIGS Books. 2000.
Design and Coding Reusable C++. M.B. Carroll and M.A. Ellis. A-W. 1995.
Advanced C++. J.O. Coplien. A-W. 1992.
Inside the C++ Object Model. S.B. Lippman. A-W. 1996.
[(Optional) These are all books of great historical interest. They may be difficult to read because the C++ language was still evolving at the time of writing.]

Using C++ objects from Objective-C/Cocoa
Tuesday May 18, 2004

It turns out to be easier than I thought to integrate my jazz theory classes/accompaniment generation algorithm (written in C++/STL) and my chord editor (written in Objective-C/Cocoa). My application requires only a “loose coupling” between the two. However with the Objective-C++ compiler, I can imagine that programs with more interdependent C++ and Objective-C components should not be much more difficult to put together.

Here’re the steps I took. Note that in my program, the C++ code carries out the main “computation” and the Objective-C code handles the GUI and file I/O.

  1. Add new constructors and member functions to the C++ code that will take CoreFoundation objects as parameters and generates CoreFoundation objects as results.
  2. Wrap an Objective-C++ adapter (as an Objective-C object) around the C++ code.
  3. The Objective-C/Cocoa code can now make use of the C++ code through the adapter by passing the required CoreFoundation object parameters and getting back CoreFoundation object results.
I’d of course much rather deal with one language than two. But it would have been quite unpleasant if I implemented the jazz theory classes and accompaniment generation algorithm in Objective-C rather than C++. Since programming for Cocoa requires Objective-C, this is probably the best way to implement such a program.

When I hear people talk about how they prefer one programming language over others, I actually sense a lot of insecurity in the languages they don’t prefer. Specifically many people who say they don’t like C++ don’t really know the language that well. I’ll post a reading list in the future to clarify what I mean by “knowing C++ well”. It consists of roughly ten books.

May 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 31
Apr  Jul

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