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.

Walking Bass Lines
Friday March 5, 2004

Here’s how I propose to generate a walking bass line from a given chord chart. As a first step, we pick the note to play on the first beat of each bar, or the note to play “under” each chord if a bar contains more than one chord. Then we pick the notes to play in between each pair of these chosen notes as a separate subproblem. This should narrow the choices a lot because the root is often played on the first beat of each bar. There are exceptions but we can deduce rules to govern their occurrences. This technique should generate the type of bass lines found in method books and web sites such as this one and this other one.

Here’re some rules I’ve come up with for picking these “first notes” after studying many bass lines.

  • Mostly use notes from the octave just below middle C. Occasionally pick from notes a few notes above and below that range.
  • Play the root most of the time.
  • Occassionally play the 3rd, 5th, or 7th. However, don’t do this at the beginning of a section (or tonality change).
  • Almost always play the root for chords that last two beats. Occasionally, play a 3rd or 5th for the last of a sequence of such chords, but play the root on the following beat.
  • The second part of the previous rule can work for chords with longer durations too. When the 3rd, 5th, or 7th is played as the first note, following that with the root will place the emphasis on the second beat. This may also be combined with embellishments ending with the root on the second beat.
  • For consecutive chords with the same root (especially ones lasting two beats), play the 3rd or 5th on the second chord. E.g., for Eb followed by Ebm, play Eb, then Gb.
  • If a chord lasts two bars, on the first beats of the bars, play root-3rd, 3rd-root, root-5th, 5th-root, root-7th, or 7th-root.
  • Try to use notes from the entire allowable range.
  • If a long (two bars or more) descending line is being played, the normal rules for choosing roots can be temporarily “suspended”.

Rests, Boost.Python, and Guitar Accompaniment
Thursday March 4, 2004

I’ve thought about the representation of “rests” in my class library today. The design decision I’ve come to is to not represent them at all, since they don’t carry any information other than their durations! Instead I now store the starting beat (and subdivisions) of each note as well as its duration in a sequence. So my Sequence class template is revised as follows.

template <class T>
class Sequence : public std::list<trio<Beat, Duration, T> >
{
  ...
};
The trio class template is a generalization of pair. The tuple class template in the Boost class library can also be used but since it’s very simple to write, I decided to use my own.

I also spent a little time looking at Boost.Python. It would be nice if my jazz theory classes can be used in Python! Unfortunately at this point there’s no indication on the mailing lists that anyone manages to use Boost.Python on Mac OS X yet.

I also found the paper Generating Rhythmic Accompaniment for Guitar: the Cyber-João Case Study by Dahia, Santana, Trajano, Sandroni, and Ramalho. I’ll read it and report back soon.

Take Five
Wednesday March 3, 2004

I wrote some code today to deal with meters other than 4/4 time. Implementing it cleanly and generally is more difficult than one might think! Added a few header lines to my text file format to represent information like title, meter, key, and tempo. Here’re the charts for Some Day My Prince Will Come and Take Five. Can’t think of any other 3/4-time jazz tune. Certainly can’t think of another 5/4-time tune and one in Ebm!

Title: Some Day My Prince Will Come
Meter: 3/4
Key: F
Tempo: 90
| FMaj7 | A7#5 | BbMaj7 | Am7 _ D7 |
| Gm7 | D7#5 | Gm9 | C9 |
| FMaj7/A | Abdim | Gm7 | C7 |
| FMaj7/A | Abdim | Gm7 | C7 |
| FMaj7 | A7#5 | BbMaj7 | Am7 _ D7 |
| Gm7 | D7#5 | Gm9 | C9 |
| CMaj7 | F7 | Bb | Bdim |
| FMaj7 _ F#dim | Gm7 _ C7 | F6 | _ C7 _ |
| F6 | |

Title: Take Five Meter: 5/4 Key: Ebm Tempo: 120 | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | | CbMaj7 _ _ Abm6 _ | Bbm7 _ _ Ebm7 _ | Abm7 _ _ Db7 _ | GbMaj7 _ _ Gdim _ | | CbMaj7 _ _ Abm6 _ | Bbm7 _ _ Ebm7 _ | Abm7 _ _ Db7 _ | Fm7b5 _ _ Bb7b9 _ | | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ | Ebm _ _ Bbm7 _ |

Chord Changes in Text Files
Tuesday March 2, 2004

The design of “time sequence” containers I wrote about earlier for representing chord changes, bass lines, drum tracks, etc. works great. I ended up just calling the template Sequence: the type of data a sequencer may manipulate. I then specialized the class Sequence<Chord> to read from files in BiaB or text format and to write to files in text format.

I needed a notation that precisely specifies the duration of the chords. To illustrate, consider the chord changes of The Christmas Song in the text format read and written by my Sequence<Chord> class.

| Eb6 Bb7 | Eb6 _ Fm7 Bb7 | Eb6 _ Bbm7 Eb9 | Ab G7#5 |
| Cm7 Abm6 | Eb _ Am7 D7 | GMaj7 _ Abm7 Db9 | GbMaj7 _ Fm7 Bb7 |
| Eb6 Bb7 | Eb6 _ Fm7 Bb7 | Eb6 _ Bbm7 Eb9 | Ab G7#5 |
| Cm7 Abm6 | Eb _ Am7 D7 | Gm7 C7 Fm7 Bb7 | Eb6 |
| Bbm7 Eb9 | Bbm7 _ Eb9 Eb7 | Bbm7 Eb9 | AbMaj7 |
| Abm7 Db9 | GbMaj7 | Cm7 F7 | Fm7 Bb7b9 |
| Eb6 Bb7 | Eb6 _ Fm7 Bb7 | Eb6 _ Bbm7 Eb9 | Ab _ _ G7 |
| Cm7 Abm7 | Eb Cm7 D7 F#dim | Gm7 Cm7 Fm7 Bb7b9 | Eb6 |
Notice how each bar contains one, two, or four “entries”, each of which may be a chord or an underscore. The latter serves as place holder to disambiguate the durations of the chords. For example in the bar containing the Ab and G7, the Ab lasts three quarter notes.

Here’re the last few bars of From This Moment On that show that one can omit the place holder entirely in a bar in which the previous chord (DbMaj7) repeats.
| DbMaj7 | | Dbm7 | Gb9 |
| Ab | Bdim | Cm7 | _ F7 |
| Bb7 _ _ Bbm7/Eb | Eb _ _ Eb7 | Ab |
Note also that “slash chords” are supported.

February 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

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
Jan  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