Programming Language to use for creating Hidden Markov Model

bwu's icon

Hello all.

I'm attempting to program a Hidden Markov Model using a tutorial by Mark Stamp. I want to program Hidden Markov Models that would recognize pitch sequences, interval sequences, patterns in spectrum analysis, etc. and they would be interacting directly with Max in terms of midi and MSP. I know that the MNM library has some already programmed Hidden Markov Models and I have looked at them, but I would really like to program these HMMs without learning the FTM language. I know Java the best out of Javascript, C, and Java and I think the programming would be easiest in Java. However, I can learn C or Javascript if these will make the program run better. What do you think would be the best language to program these Hidden Markov Models in, in terms of how they interact with MaxMSP, the ease of connection to MaxMSP and efficiency.

If you want to look at the pseudo-code that I will be typing it up, it is on the 13th page of the following tutorial...

Hmmmm

bwu's icon

Thanks for the info. I checked out foxtrot, but because I'm not a c++ person (at all!) I couldn't really get much out of it.

So I'm almost done writing an HMM in java and I really hope to start using it soon. I'm finding it difficult to find articles describing how people have been using HMM's with music though. I've found a couple, 1 on drum sound detection... ( http://portal.acm.org/citation.cfm?id=1807646 ) that I really have to take a closer look at sometime soon. However I would really like to find some articles (or literature) that have already helped some people out.

mudang's icon

@bwu:
thx for the link to the hmm tutorial !
I've always wanted to check out hmm, but have never found an understandable introduction...

I don't know if this is of any help to you, but
here's a paper on "multiple-f0 tracking based on a high-order HMM":
http://articles.ircam.fr/textes/Chang08a/index.pdf

bwu's icon

Thanks all. I found some nice articles on ircam. I'm not part of the network so some of them are blocked but it's nice to know what people are even using HMM for. I'm looking at a couple of them. I think I'm going to start using the HMM program by trying to follow midi, which is something that I found an article on on ircam's website.

Ultimately, we would like to have the HMM listen to a live performance (for which it has been trained) and be able to recognize melodies, textures etc. For instance, if we play a trill on a saxophone we would like the program to simply recognize the trill and output something as simple as a bang to max. Then we would work with the bang from there. I think we're restricting our use to a monophonic instrument (likely a saxophone). Hopefully we'll be able to do a little bit more interesting stuff such as recognizing patterns in spectral analysis using an analyzer.

However, my vision is very malleable. I'd like to emphasize that I'm really not really aware of how people are using hidden markov models in music right now, so I'm really open to LOTS of ways that the hidden markov model can be used. Actually I've just finished the program and I'm pleased to say that it seems to be working well. My next task is incorporating the model into max using the mxj object (which I need to learn about).

@mudang, if you're using the tutorial I would highly recommend pairing it with the Rabiner tutorial on Hidden markov models, which is more complicated, but more reputable and detailed. As far as I can tell though, the pseudo-code from the one that I posted above is generally right. There is only 1 mistake that I noticed, but it was pretty easy to find looking at the rest of the paper.

meeble's icon

Hello BWU,

How did this project progress? Is there any Max code you could share with us?

thanks