Пример #1
0
    def envelopeFollow(self, x, winLen, hopSize):
        self.winLen = winLen
        self.hopSize = hopSize
    
        xPad = zeros((self.winLen/2))

      #  size(xPad,1) = size(x,1)
        xPad = concatenate([xPad, x])
            
        
        xBuf = M.shingle(xPad, self.winLen, self.hopSize)
        xBuf.shape = (size(xBuf,0), size(xBuf,1))
        featureLen = size(xBuf, 0)
        
        #creat window
        win = hanning(self.winLen)
        self.winMat = tile(win, (featureLen, 1))
        
        #window buffers
        self.xBuf = xBuf * win
        
        #square and mean
        self.xEnvelope = mean(abs(self.xBuf),1)
        
        return self.xEnvelope
Пример #2
0
    def SmoothEnvelope(self, envelope, window_len, hop_size):
        xPad = zeros(window_len / 2)

        # size(xPad,1) = size(self.x,1)
        xPad = concatenate([xPad, envelope, xPad])

        # Iterate over xPad and smooth with a window
        xBuf = M.shingle(xPad, window_len, hop_size)

        xBufSmoothed = median(xBuf, axis=1)

        return xBufSmoothed
Пример #3
0
    def SmoothEnvelope(self, envelope, window_len, hop_size):
        xPad = zeros(window_len/2)

       # size(xPad,1) = size(self.x,1)
        xPad = concatenate([xPad, envelope, xPad])

        # Iterate over xPad and smooth with a window
        xBuf = M.shingle(xPad, window_len, hop_size)

        xBufSmoothed = median(xBuf, axis=1)
        
        return xBufSmoothed
Пример #4
0
    def calcSoneLoudness(self):

        yPad = zeros((self.winLen / 2))
        yPad = concatenate((yPad, self.y, yPad), 0)

        self.yBuf = M.shingle(yPad, self.winLen, self.winLen)
        self.bufLen = size(self.yBuf, 0)

        soneVec = zeros(self.bufLen)

        self.count = 0
        for i in range(self.bufLen):
            self.count += 1
            soneVec[i] = self.getSegmentSone(i)

        #gate signal
        E = ED.onsetDetect(self.fftParams)
        envelope = E.envelopeFollow(self.y, self.winLen * 2, self.winLen)
        envelope = divide(envelope, envelope.max())

        soneVec = soneVec * envelope

        return soneVec
Пример #5
0
    def envelopeFollowEnergy(self, x, winLen, hopSize):
        self.winLen = winLen
        self.hopSize = hopSize

        xPad = zeros(self.winLen / 2)

        # size(xPad,1) = size(self.x,1)
        xPad = concatenate([xPad, x, xPad])

        xBuf = M.shingle(xPad, self.winLen, self.hopSize)
        xBuf.shape = (size(xBuf, 0), size(xBuf, 1))
        featureLen = size(xBuf, 0)

        #creat window
        win = hanning(self.winLen)
        winMat = tile(win, (featureLen, 1))

        #window buffers
        xBuf = xBuf * win

        #square and mean
        xLocEnrg = mean(square(xBuf), 1)

        return xLocEnrg
Пример #6
0
    def envelopeFollow(self, x, winLen, hopSize):
        self.winLen = winLen
        self.hopSize = hopSize

        xPad = zeros((self.winLen / 2))

        #  size(xPad,1) = size(x,1)
        xPad = concatenate([xPad, x])

        xBuf = M.shingle(xPad, self.winLen, self.hopSize)
        xBuf.shape = (size(xBuf, 0), size(xBuf, 1))
        featureLen = size(xBuf, 0)

        #creat window
        win = hanning(self.winLen)
        self.winMat = tile(win, (featureLen, 1))

        #window buffers
        self.xBuf = xBuf * win

        #square and mean
        self.xEnvelope = mean(abs(self.xBuf), 1)

        return self.xEnvelope
Пример #7
0
    def envelopeFollowEnergy(self, x, winLen, hopSize):
        self.winLen = winLen
        self.hopSize = hopSize
        
        xPad = zeros(self.winLen/2)

       # size(xPad,1) = size(self.x,1)
        xPad = concatenate([xPad, x, xPad])
        
        xBuf = M.shingle(xPad, self.winLen, self.hopSize)
        xBuf.shape = (size(xBuf,0), size(xBuf,1))
        featureLen = size(xBuf, 0)
        
        #creat window
        win = hanning(self.winLen)
        winMat = tile(win, (featureLen, 1))
        
        #window buffers
        xBuf = xBuf * win
        
        #square and mean
        xLocEnrg = mean(square(xBuf),1)
        
        return xLocEnrg
Пример #8
0
    def calcSoneLoudness(self):     

        yPad = zeros((self.winLen/2))
        yPad = concatenate((yPad, self.y, yPad),0)

        self.yBuf = M.shingle(yPad, self.winLen, self.winLen)
        self.bufLen = size(self.yBuf, 0)

        soneVec = zeros(self.bufLen)

        self.count = 0
        for i in range(self.bufLen):
            self.count +=1
            soneVec[i] = self.getSegmentSone(i)


        #gate signal
        E = ED.onsetDetect(self.fftParams)
        envelope = E.envelopeFollow(self.y, self.winLen*2, self.winLen)
        envelope = divide(envelope,envelope.max())
        
        soneVec = soneVec * envelope
        
        return soneVec