How does the output speakers and headphones work?

sound travels from the computer to the speakers where sound waves pick up and the sound gets played