All those problems are solved by grade separation. If railways are fully grade separated there is no need for trains to use their horns. Since rail needs shallower gradients than road it often makes sense to sink it below street level, drainage allowing.