Skip to content

Instantly share code, notes, and snippets.

View bmcfee's full-sized avatar

Brian McFee bmcfee

View GitHub Profile
@bmcfee
bmcfee / gist:8443775
Created January 15, 2014 20:20
Vectorizing stft for great justice
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@bmcfee
bmcfee / stride_tricks.ipynb
Created January 18, 2014 22:27
Using stride tricks to simulate a sliding window on a huge time series
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmcfee
bmcfee / HAMR 2014 python demo
Created January 26, 2014 12:31
HAMR 2014 python demo: librosa and mir_eval
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@bmcfee
bmcfee / beats_to_chords.py
Last active August 29, 2015 13:56
Propagate time-range annotations (chords) down to a list of reference times (beats)
def beats_to_chords(beat_times, chord_times, chord_labels):
'''Propagate lab-style annotations to a list of beat timings.
:parameters:
- beat_times : ndarray, shape=(m, 2)
The time range for beat intervals.
The `i`th beat spans time `beat_times[i, 0]` to `beat_times[i, 1]`.
`beat_times[0, 0]` should be 0, `beat_times[-1, 1]` should be the track duration.
- chord_times : ndarray, shape=(n, 2)
@bmcfee
bmcfee / gist:9255038
Created February 27, 2014 17:40
corrected delta feature implementation
def delta(data, axis=-1, width=9, order=1, trim=True):
'''Compute delta features.
:usage:
>>> # Compute MFCC deltas, delta-deltas
>>> mfccs = librosa.feature.mfcc(y=y, sr=sr)
>>> delta_mfcc = librosa.feature.delta(mfccs)
>>> delta2_mfcc = librosa.feature.delta(mfccs, order=2)
:parameters:
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@bmcfee
bmcfee / gist:10782851
Created April 15, 2014 22:17
Maximal matching for boundary detection
def matching(ref, est, window=0.5):
n_ref, n_est = len(ref), len(est)
D = np.zeros((n_ref + n_est, n_ref + n_est))
M = (np.abs(np.subtract.outer(ref, est)) <= window).astype(int)
# If we build the skew-symmetric adjacency matrix D, then rank(D) = 2 * maximum matching
D[:n_ref, n_ref:] = M
D[n_ref:, :n_ref] = -M.T
@bmcfee
bmcfee / Playlist.ipynb
Created May 3, 2014 14:48
Reconstructing playlist data from ismir2012-hypergraph
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.