How do you make music?

I am relatively new to arduino and I am building an instrument that uses infrared sensors to create music notes. I don't really know how to do this. What exactly is midi and what do I need to do to make this work programming and hardware wise.

Hardware - you have infrared transmitters, and detectors that sense when the IR is blocked?
Then you will create a midi command to send out?
You have a midi sound module to receive that midi command and make the actual notes?

How exactly does the midi module work, what kind do I need, where can I get it, and how do I wire and program everything?

Do some wikipedia reading on MIDI
Here's an example of a Midi Sound Module.
What you get & where you get it depends on what sound you & what you're willing to pay.

[
EDIT: Link that I thought I had posted originally

]

It would be a lot easier if you build your instrument first, even if it just generates a "simple" tones. Or, build a MIDI device first with "simple switches", and then add your infrared sensors/interface.

About 99% of the time a MIDI instrument is a keyboard. It's going to have a synthesizer built-into the instrument so you can play it without using the MIDI interface, and you'll be able to upload (to the instrument) various instrument-sounds.

You can also send MIDI commands from the computer to the instrument so that the computer is playing the instrument. And, you may be able to load a MIDI file/sequence into the instrument to automatically play the instrument with no computer attached.

You can send MIDI commands from the instrument to the computer while you are playing to "capture" the performance/commands for playback/editing later. When you play-back the MIDI file, you can play it back with a different instrument-sound.

You can play MIDI files on your computer, and with the appropriate software you can edit the files.

I just want to be able to generate tones using Arduino. I have a small Midi keyboard, is there a way to use that?

Not to generate tones there is not unless it has a MIDI input. You can use it to input numbers into the arduino to turn on LEDs or make noises. Look at the arduino tone function for how to make a simple noise.