Refactoring to extract sound generation