MIDI input from a keyboard?

Blitz3D Forums/Blitz3D Programming/MIDI input from a keyboard?

Um, yep I am a grade 8 pianist! So I know what the values of midi 'pitch' represent (ie. 60 = middle C).

I am attempting to use midi input to play samples at the correct pitch. It's a really rough attempt, and I'm only really doing it for fun. If I increment the sample rate by the difference in midi 'pitch' (ie. 62 = D = 2 above middle C) it's accurate, but the further away I get from middle C, the further out the pitch goes.

I was wondering if anyone had experimented with sample pitch according to midi pitch before. There must be an accurate way of reproducing a sample at the correct pitch based on input - ok, so it might sound awful due to the pitch-shifting of the sample used, but if I use several samples spread across each region of the keyboard (ala soundfonts) I might be able to get a decent sound.

I'm a wee bit drunk to play with it again tonight, but maybe tomorrow I'll have another go. I'm sure it's a matter of exponentially increasing the sample pitch.