Posted by: automusic | July 4, 2009

HBFS Wrap-up

It has been a long time, so give me a second to catch up.  This is how Harder Better Faster Sitar ended.

HBFS was written in Max/MSP, and Java, with some precomputation in Perl.  I really wanted to use a dynamic language like Ruby or Python inside of Max, but never actually ended up doing that.  Maybe next time!

Chords

There are far too many different chords out there, in far too many styles, to have Harder Better Faster Sitar learn how to build them on the fly.  I was afraid that any grammar I wrote to generate them would be too inflexible to use outside of  a handful of songs.

I decided to have the user supply a midi file (or files) in the style they wish to play in.  I’d then transpose the midis to all different keys, then scan through them and find each instance of more than one note being on, and store them in a table.  The keys were the pitch classes (A, C#, E), and the values were the actual midi numbers of the notes present (45, 57, 62, 67, …).

Pitch Detection

Nothing fancy here, just filters set up at every value of ‘A’ and summed together.  Notes above a configurable threshold were on, the others were not.  This lets me hear more than one pitch at a time (good!) but fails if the user is out of tune (bad!).

Although, that was a strong incentive for me to start tuning more regularly.

Chord Selection

The Levenshtein Distance (wp) is the minimum number of changes you have to make to go from one string to another.  The changes allowed are insertion, deletion, and substitution of a single character.  It also happens to be one of my favorite metrics, for no particular reason.

To pick a chord to play, take the notes that are on and plug them in to the table.

Nothing there?  Randomly try the chords of Levenshtein distance 1.

Nothing there either?  Try all chords of Levenshtein distance 2.

Nothing there?  Just play back the pitches you heard, as close to middle C as you can get.  It will be a pretty uninteresting voicing, but it will be harmonically right.

In first case, you will get back a pretty interesting chord, with the proper voicing for your style.  In the second, you played a passing tone or something, and it didn’t occur in the corpus you supplied.  That’s ok!  Non-harmonic tones are wonderful things, and we should be able to find a harmony around them.  The next case is a little more desperate, and the final one is just so there are no awkward silences coming from your accompaniment.

Rhythm

Beat tracking is hard!  Even with third-party libraries and a bunch of papers on the topic, I couldn’t get it working right.  Plus, I had to do this all in a semester.  After banging my head against the wall (in 3/4 time), I decided to just hook the whole project up to a step sequencer (wp).  You can define all your rhythms and tempos ahead of time, and switch between them with a key press.

The tempo of the step sequencer can be set by tap-tempo, which was fun to implement.

If I find the time (or a single person asks me) I will clean up my code and release it.  Stick around for that!


Leave a response

Your response:

Categories