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.

Generating Bass Notes for a Bar
Saturday March 13, 2004

Here’s a bass line for Blues for Alice generated by the latest version of my program.

| F3 A3 C4 D4 | E4 Ab3 A3 D#4 | D4 F3 G3 D3 | C3 F#3 F3 D#4 |
| D4 C4 Bb3 B3 | Bb3 E3 Eb3 A#3 | A3 D#3 D3 Abb2 | Ab2 Abb3 Ab3 Db3 |
| G2 A2 Bb2 C#3 | C3 D3 E3 Fb3 | F3 Db3 D3 A2 | G2 Cb2 C3 C3 |
The program uses only a simple “formula” for generating notes for chords lasting the entire bar. A better program should probably implement a number of these formulas and apply them when conditions are suitable.

Here’s how the notes of a bar are currently chosen. The forth note is simply an approach note, chosen in the manner I described a few days earlier. The third note is a chord note between the first notes of this bar and the next bar. The second note is a scale note between the first and the third note.

Implementing this procedure using the jazz theory classes quickly reveals how well (or poorly) their interfaces have been designed. Subproblems such as “list all chord notes of Fmaj7 between F3 and E4” must be specified easily with the classes. This actually raises a number of interesting design questions for supporting the kinds of questions that may be asked about the musical objects being represented. These aren’t explored in any detail by class library designs documented in the literature.

Bass Lines!
Wednesday March 10, 2004

I wrote quite a bit of code today, so there’ll only be time for a short entry. Here’s a bass line the current version of my program generates for three choruses of Blues for Alice.

| F3 | E3 Bb2 A2 C3 | D3 A2 G2 Db3 | C3 G2 F2 B2 |
| Bb2 | Bb3 E3 Eb3 Ab3 | A3 C4 D4 A3 | Ab3 Gb4 F4 Db4 |
| G3 | C3 | F3 E3 D3 A2 | G2 Db3 C3 Bb2 |
| A2 | E3 G2 A2 Db3 | D3 Ab2 G2 D3 | C3 Gb2 F2 A2 |
| Bb2 | Bb3 E4 Eb4 G3 | A3 Eb3 D3 A2 | Ab2 Gb3 Ab3 Db3 |
| G3 | G2 | F2 Eb3 D3 F3 | G3 Db4 C4 Gb3 |
| F3 | E3 G3 A3 E3 | D3 F3 G3 D3 | C3 D3 C3 F3 |
| Bb2 | Bb3 D3 Eb3 Bb2 | A2 Eb3 D3 Gb3 | Ab3 B2 Db3 C3 |
| D3 | C4 | F3 C3 D3 A2 | G2 D3 C3 C3 |
The chord chart is of course:
| FMaj7 | Em7b5 A7 | Dm7 G7 | Cm7 F7 |
| BbMaj7 | Bbm7 Eb7 | Am7 D7 | Abm7 Db7 |
| Gm7 | C7 | FMaj7 Dm7 | Gm7 C7 |
Notice that only chords lasting two beats are handled at the moment. Since tonality analysis is performed on the chords, the program always chooses diatonic approach notes correctly.

Choosing Approach Notes
Monday March 8, 2004

Suppose we’ve selected the first note to play for each chord as I suggested last week. How do we choose the other notes in the walking bass line we’re constructing? Let’s first consider the simple case when there’re two chords per bar.

Let the chord under consideration (which lasts two beats) be C1, and let C2 be the chord following it. Since the first notes to play for all chords have already been chosen, we only need to choose the second note for C1. Most method books will suggest the use of an approach note that “transitions into” the first note for C2 (the target): either a diatonic or chromatic approach note from above or below.

A chromatic approach note is easy to determine, it’s just the note a half note above or below the target. To find the diatonic approach note, we need to know what scale/mode we’re playing for C2! To illustrate, consider the first few chords of the rhythm changes:

| Bb Gm7 | Cm7 F7 | Bb ...
Let’s say the previous step of our algorithm has chosen to play the roots of all the chords. The chromatic approach note for the second Bb is A (below) or B (above). Since we’re in the tonality of Bb, the diatonic approach note is (also) A (below) or C (above). Note that an Ab will imply a different tonality and is not as good a choice. That’s why I believe programs that don’t perform tonality analysis of the chord changes cannot possibly make a correct decision here. Fortunately, for my program, I’ve already worked out such a tonality analysis algorithm a few weeks ago.

Sometimes candidates for the approach note will coincide with chord notes of C1. E.g., in the previous example, A and C are the third and fifth of F7, respectively. In such a case, the approach note serves dual purposes, which may be reason for us to give it a higher preference.

Of course approach notes can also be played as the last note for chords longer than two beats. For such chords, there’s more freedom in the choices of the other notes (“wide open” is more accurate). I hope to write about this soon.

March 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
Feb  Apr

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