Skip to content

Instantly share code, notes, and snippets.

View bmcfee's full-sized avatar

Brian McFee bmcfee

View GitHub Profile
@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)
{
"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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmcfee
bmcfee / Instrument tag extraction.ipynb
Created July 23, 2014 20:35
Instrument keyword extraction heuristics
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.