Change way of call generateNoise

Use static variable int to call generateNoise() only once.