Music.SE has been trying to push for Lilypond support which has many of the features you have requested.
There is a lot of external support for Lilypond Lilypond asas shown hereby numerous third-party components, and there's defiantlydefinitely been some interesting integration done with MediaWiki where it not only displays the music, but also plays it.
Here's a simple example:
\version "2.16.0" % necessary for upgrading to future LilyPond versions.
\header{
title = "A scale in LilyPond"
subtitle = "For more information on using LilyPond, please see
http://lilypond.org/introduction.html"
}
\relative c' {
c d e f g a b c
}
and the output: