not exactly hard to do, mind you
to cancel out noises, one channel needs to have the waveform inverted. so, left or right channel would be inverted. This would cancel out everything. so, you have a mic on one side with a dsp that inverts the sound waves and throwing that into one ear. Then the headphones play whatever you want them to. pretty low tech actually