Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
1  
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 at 20:02

1 Answer 1

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"];
dft = Fourier[data];

Re the second part of your question: I don't know about re-tuning MIDI with other programs. There may be a sound/audio-related Stack Exchange website where you'd be more likely to find people who could help you with that.

share|improve this answer
    
I have the following code: data = Import["sample.wav", "Data"]; dft = Fourier[data] And it doesn't work though sample.wav is in the same file as the notebook. –  Liisi May 1 at 10:10
    
Oh, I just found my mistake. It requires a full file name. –  Liisi May 1 at 10:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.