I have found the answer to this problem, at least for my system. It is not a sound problem, it is a Compiz problem.
I went into the system settings => universal access => hearing tab, and turned on the visual alerts. Nothing happened when I pressed the test button. So, I thought that the event was not being fired. I also tried typing echo -e "\a"
in gnome terminal, and no sound was emitted.
I then ran metacity --replace
and the sounds started working in all places, as expected. Returning to Compiz (compiz --replace) made them stop.
EDIT: I guess I was in the gnome compatibility mode when I did this test, and did not realize it's harder in Unity, because the window manager doesn't appear to run and Alt-F2 doesn't work. However, I tried it in Unity, and was able to bring up the Terminal using Alt-Ctrl-T, then ran "Compiz --replace&" from that to get back to Unity.
Sorry to anyone who may have suffered due to my post.