refactor to take bits per sample into account