README.md
author wim
Tue, 26 May 2020 11:43:51 +0200
changeset 5 377c84f956dc
parent 4 319d42cc33d8
permissions -rw-r--r--
- extended README

### Chordal Analysis

*xmlChordAna* is a python script that makes a chordal analysis of a MusicXML file.

An [interactive demo][1] is avaiable on the
[Chord Analysis][1] page. It runs the script on
my server and formats the output in some neat html.

At the command line *xmlChordAna* is used as follows:

        > ./xmlChordAna.py scorefile.xml

The output is printed in plain text looks like this:

        File: bwv539p_arr.xml, ticks per quarternote: 384
        342 note groups, 102 chord segments
        Key: Am, confidence: 33%
        ---- chord Dmin, score: 90%
           0     D3, D4, F4, A4
           2     D3, F4, A4, D5
           2 1/2 F4, A4, D5, D3
           3     F4, A4, D5, C#3
           3 1/2 F4, A4, D5, D3
        ---- chord Ehdim, score: 75%
           4     D5, E3, E4, G4
        ---- chord C#hdim, score: 92%
           5     E3, E4, G4, C#5
           5 1/2 E3, E4, G4, B4
           6     E3, E4, G4, C#5
           6 1/2 E4, G4, C#5, E3
           7     E4, G4, C#5, D3
           7 1/2 E4, G4, C#5, E3
        ...

See [this explanation](https://wim.vree.org/keys09/uitleg.html) for more info.

### KeyScape

On the [KeyScape](../keys09) page you can find two other interactive demos. One makes
a *keyscape* from a MIDI file. The other runs the same chordal analysis as *xmlChordAna*,
but for a MIDI file. There is no download page (yet) for these programs.

### Base-40 note numbers

*xml2b40* is a python script to convert a MusicXML file to a list of base-40 events.
It is invoked from the command line as follows:

        > ./xml2b40.py -t 384 scorefile.xml

and produces the following output:

        0 129
        0 169
        0 180
        0 192
        768 -192
        768 -169
        768 192
        768 209
        960 -129
        960 129
        1152 -129
        1152 124
        1344 -124
        1344 129
        1536 -192
        1536 -180
        ...

Each line contains two numbers: the time and a base-40 note.
The time is in ticks, where a quarter note is 384 ticks. The base-40 note number is positive
when the note starts sounding and negative when the note stops sounding.

The base-40 note number system encodes 40 pitches in an octave.
It is maps all single and double accidentals.
For instance, the first 10 numbers are:

        1:  Cbb
        2:  Cb
        3:  C
        4:  C#
        5:  C##
        6:  not used 
        7:  Dbb
        8:  Db
        9:  D
        10: D#

Base-40 numbers allow precise matching of chord patterns. For instance, chord pattern
C7 only matches
C-E-Bb and not C-E-A# or C-Fb-Bb or B#-E-Bb etc.

The idea of base-40 note numbers is due to B. Hewlett and described in
[this paper][2]

[1]: ../keys09/abc2chord.html?../js/pre_wind.js
[2]: http://www.ccarh.org/publications/reprints/base40/