[Haskell-cafe] Analysing music

Achim Schneider barsoap at web.de
Thu Jun 5 14:27:53 EDT 2008

The recent discussion about Markoff chains inspired me to try to
train one with all the Bach midi's I have on my disk, collecting
statistics on what intervals tend to get played simultaneously,
which follow others and in which way the pitch offsets from its mean,
so that melodies fall and raise "naturally".

The rationale is that if it's Bach, it's harmonious but not respecting
any kind of usual chord progression.

So far, I got (a bit confused around the edges):

getMid mf = do
    mid <- MidiLoad.fromFile mf
    return $ MidiRead.retrieveTracks mid

toMelody :: MidiMusic.T -> StdMelody.T
toMelody = Music.mapNote f 
        f note = 
            let body = MidiMusic.body note 
            in Melody.Note StdMelody.na (MidiMusic.pitch body)
main = do
    args <- Env.getArgs
    let mf:[] = args
    m <- getMid mf 
    putStr $ Format.prettyMelody $ Optimise.all 
        $ Music.chord $ map (\m -> Music.line $ map toMelody m) m

which results in
  [e 3 bn na,
     [b 2 wn na,
        [hnr, d 3 wn na, hnr, cs 3 hn na, a 2 hn na,
         chord [cs 3 hn na, line [b 2 hn na, c 3 hn na]]]]]

, for a set of random clicks in rosegarden's matrix editor.

Right now, I'm desperately searching for functions that can help me
analyse this beast, which afaict right now works best by having a
multitude of transformations (e.g. one big top-level chord with maximum
polyphony and a hell a lot of rests) that provide easy access to
whatever information is needed.

Does anyone of you know about previous work in this area? I don't want
to break cultural imperatives by not being as lazy as possible.

(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 

More information about the Haskell-Cafe mailing list