'Return an initialized :class:`audiotools.replaygain.ReplayGain`
instance, which requires the sample rate of the song(s) on which
the ReplayGain values will be computed. The item is passed in case
the sample rate is invalid to log the stored item sample rate.
:return: initialized replagain object
:rtype: :class:`audiotools.replaygain.ReplayGain`
:raises: :exc:`ReplayGainError` if the sample rate is invalid'

def init_replaygain(self, audiofile, item):

    try:
        rg = self._mod_replaygain.ReplayGain(audiofile.sample_rate())
    except ValueError:
        raise ReplayGainError(u'Unsupported    sample    rate    {}'.format(item.samplerate))
        return
    return rg
