app simplified from Velios code. Works only up to frequencies of about 25Hz