A generalized cubic moment and the Petersson formula for newforms