def pitch_shifter(self, chunk, shift):
        """ Pitch-Shift the given chunk by shift semi-tones. """
        freq = numpy.fft.rfft(chunk)

        N = len(freq)
        shifted_freq = numpy.zeros(N, freq.dtype)

        S = numpy.round(shift if shift > 0 else N + shift, 0)
        s = N - S

        shifted_freq[:S] = freq[s:]
        shifted_freq[S:] = freq[:s]

        shifted_chunk = numpy.fft.irfft(shifted_freq)

        return shifted_chunk.astype(chunk.dtype)
def pitch_shifter ( self , chunk , shift ) : freq = numpy . fft . rfft ( chunk ) N = len ( freq ) shifted_freq = numpy . zeros ( N , freq . dtype ) S = numpy . round ( shift if shift > 0 else N + shift , 0 ) s = N - S shifted_freq [ : S ] = freq [ s : ] shifted_freq [ S : ] = freq [ : s ] shifted_chunk = numpy . fft . irfft ( shifted_freq ) return shifted_chunk . astype ( chunk . dtype )
Pitch-Shift the given chunk by shift semi-tones.