Sounds are moving air. Active cancelation uses a microphone to listen to the sound, and then make an “opposite” sound by pushing air in the other direction. These opposite sounds are added to the music coming through the headphones.
By the time it gets to your ear, the combined air from the original (ambient) sound and the opposite sound created by the device cancel out (mostly), so you hear more of your music with less outside noise.
The music quality is a bit less because the music has extra sound added on top, but there’s no more danger to your ears than listening to regular music.
Latest Answers