MIDI Keyboard Encoder - Arduino Piano/Keyboard (question)

I think, there are 2 questions: keyboard and midi synthesis.
For first one, search multiplexing, there are bunch of examples, including arduino codes:
http://arduino.cc/playground/Main/InterfacingWithHardware#InputTOC
http://arduino.cc/playground/Main/InterfacingWithHardware#keyb
For second, midi synthesis, there are special midi shields based on 40 polyphony IC:

Of course, you can do synthesis on PC, there are open source / free software available on-line.