Added check for valid audio sample range