Big refactoring to extract the sound generation part from the rest