My class made loudspeakers like this. We put alternating current from a signal generator into a coil of wire, which was taped to the back of a paper cone. The coil turns into an electromagnet but with north and south poles that alternate with the current. The coil-electromagnet sits between the poles of a permanent magnet. They alternately attract and repel, which makes the cone vibrate and you get a buzzing noise at the set frequency.