Skip to content

Instantly share code, notes, and snippets.

@jesseengel
jesseengel / rainbowgram.py
Created September 5, 2017 17:10
Script to plot "rainbowgrams" from NSynth (https://arxiv.org/abs/1704.01279)
import os
import librosa
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['svg.fonttype'] = 'none'
import numpy as np
from scipy.io.wavfile import read as readwav
# Constants
export default function LowpassFilter(Fc) {
var Q = 0.707;
var K = Math.tan(Math.PI * Fc);
var norm = 1 / (1 + K / Q + K * K);
this.a0 = K * K * norm;
this.a1 = 2 * this.a0;
this.a2 = this.a0;
this.b1 = 2 * (K * K - 1) * norm;
this.b2 = (1 - K / Q + K * K) * norm;