I have seen that inside headphones there is a magnet with a coil of thin wire around it. There must be longitudinal waves coming out of it that is why we can listen to audio. There must be pressure waves created as sound is nothing but pressure wave. So, my question is how is the pressure actually created there in the first place and how are the variations in pressure created? There is the electric current that flows through the wires and the electric and magnetic fields due to the current and the magnet. So, how do they "exert" pressure on air?
A permanent magnet has a fixed north/south polarity - in this example, lets say north is facing up and south is facing down. This magnet has a membrane of some kind attached to its north face.
An electromagnet beneath the permanent magnet can switch the direction of its north/south polarities by changing the direction of the electric current running through it.
When the electromagnet's south is pointing up, it pushes away the permanent magnet's south pole and therefore the membrane, creating an area of pressure in the air.
When the electromagnet's north is pointing up, it attracts the permanent magnet's south pole and therefore the membrane, allowing for the next pressure wave to be made.