# Sampling a musical instrument (or re-tuning MIDI)

I'd like to try to convert a piece of MIDI music made with SoundNote to another tuning (not microtonal or even split-black-keys, just a slightly different tuning for each note). I searched for pitch parameters and it seems it only accepts "C" or "Db", not frequencies, and plays the piece in 12-tone equal temperament. (Am I right? Or could I somehow make a MIDI note sounding at a different frequency than those pre-defined notes?)

So I'm trying to recreate piano sound with Play function. I add some harmonics to a sine wave but the more I add, the worse it sounds. Adding attack and decay shouldn't be very hard but for adding the harmonics in right amounts, I'd need to sample. I could have access to a piano and get some sound samples. In what file format should I record them so that Mathematica could run a Fourier transform on it? What functions should I use? How do I give a sound file as an input?

Or, is there any way to re-tune a MIDI file with some other program after I compose it with Mathematica and export?

• I believe you need to include a MIDI Pitch Bend Event of the correct value for each channel that you wish to "tune." I don't think this is possible from Mathematica without manually writing binary data to a file. See e.g. midi.org/techspecs/midimessages.php for a starting reference. – Mr.Wizard Apr 28 '14 at 20:02

Several audio file formats are supported by the Import and Export functions in Mathematica. These formats and the exact details of how to use them with Import and Export are provided in the Documentation Center.
Between Import and Fourier, I think you should be able to get what you want. Here's a couple of evaluations like what you might end up using:
data = Import["http://www.nch.com.au/acm/8kgsm.wav", "Data"];