Theory of vibrational anomalies in glasses