a6da312bef19e23357650acd3f18bc76e09fc499,librosa/feature.py,,ifptrack,#,584

Before Change


        // The mask selects out constant regions + active borders
        mask   = ~np.pad(matches[:, t], 1, mode="constant")
        
        starts = np.argwhere(matches[:, t] & mask[:-2]).squeeze()
        ends   = np.argwhere(matches[:, t] & mask[2:]).squeeze()
        
        // Set up inner loop    
        frqs = np.zeros_like(starts, dtype=float)
        mags = np.zeros_like(starts, dtype=float)
        
        for i, (u, v) in enumerate(zip(starts, ends)):
            // Weight frequencies by energy
            weights = np.abs(D[u:v+1, t])
            mags[i] = weights.sum()
            
            // Compute the weighted average frequency.
            // FIXME: is this the right thing to do? 
            // These are frquencies... shouldn"t be a 
            // weighted geometric average?
            frqs[i] = weights.dot(if_gram[u:v+1, t])
            if mags[i] > 0:
                frqs[i] /= mags[i]
            
        // Clip outside the ramp zones
        idx        = (fmax[-1] < frqs) | (frqs < fmin[0])
        mags[idx]  = 0
        frqs[idx]  = 0
        
        // Ramp down at the high end
        idx        = (fmax[-1] > frqs) & (frqs > fmax[0])
        mags[idx] *= (fmax[-1] - frqs[idx]) / (fmax[-1] - fmax[0])
        
        // Ramp up from the bottom end
        idx        = (fmin[-1] > frqs) & (frqs > fmin[0])
        mags[idx] *= (frqs[idx] - fmin[0]) / (fmin[-1] - fmin[0])
        
        // Assign pitch and magnitude to their center bin
        bins                = np.round(0.5 * (starts+ends)).astype(int)
        pitches[bins, t]    = frqs
        magnitudes[bins, t] = mags

    return pitches, magnitudes, D

After Change


        // The mask selects out constant regions + active borders
        mask   = ~np.pad(matches[:, t], 1, mode="constant")
        
        starts = np.argwhere(matches[:, t] & mask[:-2])
        ends   = np.argwhere(matches[:, t] & mask[2:])
        
        // Set up inner loop    
        frqs = np.zeros_like(starts, dtype=float)
        mags = np.zeros_like(starts, dtype=float)
        
        for i, (u, v) in enumerate(zip(starts, ends)):
            // Weight frequencies by energy
            weights = np.abs(D[u:v+1, t])
            mags[i] = weights.sum()
            
            // Compute the weighted average frequency.
            // FIXME: is this the right thing to do? 
            // These are frquencies... shouldn"t be a 
            // weighted geometric average?
            frqs[i] = weights.dot(if_gram[u:v+1, t])
            if mags[i] > 0:
                frqs[i] /= mags[i]
            
        // Clip outside the ramp zones
        idx        = (fmax[-1] < frqs) | (frqs < fmin[0])
        mags[idx]  = 0
        frqs[idx]  = 0
        
        // Ramp down at the high end
        idx        = (fmax[-1] > frqs) & (frqs > fmax[0])
        mags[idx] *= (fmax[-1] - frqs[idx]) / (fmax[-1] - fmax[0])
        
        // Ramp up from the bottom end
        idx        = (fmin[-1] > frqs) & (frqs > fmin[0])
        mags[idx] *= (frqs[idx] - fmin[0]) / (fmin[-1] - fmin[0])
        
        // Assign pitch and magnitude to their center bin
        bins                = np.round(0.5 * (starts+ends)).astype(int)
        pitches[bins, t]    = frqs
        magnitudes[bins, t] = mags

    return pitches, magnitudes, D
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: librosa/librosa
Commit Name: a6da312bef19e23357650acd3f18bc76e09fc499
Time: 2013-11-22
Author: brm2132@columbia.edu
File Name: librosa/feature.py
Class Name:
Method Name: ifptrack


Project Name: librosa/librosa
Commit Name: 74ed014804075d039299a5588b3b5dbdc154fe5d
Time: 2014-01-16
Author: brm2132@columbia.edu
File Name: librosa/feature.py
Class Name:
Method Name: ifptrack