Singing dunes, which emit a loud sound as they avalanche, constitute a striking and poorly understood natural phenomenon. We show that, on the one hand, avalanches excite elastic waves at the surface of the dune, whose vibration produces the coherent acoustic emission in the air. The amplitude of the sound (similar or equal to105 dB) saturates exactly when the vibration makes the grains take off the flowing layer. On the other hand, we show that the sound frequency (similar or equal to100 Hz) is controlled by the shear rate inside the sand avalanche, which for granular matter is equivalent to the mean rate at which grains make collisions. This proves the existence of a feedback of elastic waves on particle motion, leading to a partial synchronization of the avalanching sand grains. It suggests that the song of dunes results from a wave-particle mode locking.