You could do the same with an inductive sensor wired to the headphone jack. This worked for Square to read magstripe data, which is significantly more complex of a signal to parse than simply counting the number of local maxima per second.
Inductive sensors are cheaper, simpler and more foolproof; cyclists have used them for decades to gather both wheel speed and cadence.