Group 03

Download .ipynb

This notebook comes from outside the course materials: it is shown here to read, not to run.

Rebuild the groove

Groove id: superstition
Category: fidelity
Group: [removed]

Use drumkit.py and the Python standard library. Keep play(...) as the last cell: it is what we listen to.

from IPython.display import Audio
from drumkit import *

def play(wave, sample_rate=SR):
    return Audio(wave, rate=sample_rate, normalize=False, autoplay=False)

def pitched_snare(
    frequency=180,
    duration=0.20, amplitude=0.15, noise_gain=0.5,
    sample_rate=SR,
):
    pitch = [
        frequency + (frequency + 120) * value
        for value in envelope_exp(duration, tau=0.010, sample_rate=sample_rate)
    ]
    body = vca(
        square_wave_f(pitch, amplitude=amplitude, sample_rate=sample_rate),
        envelope_exp(duration, tau=0.025, sample_rate=sample_rate),
    )
    wires = vca(
        noise(duration, amplitude=amplitude, sample_rate=sample_rate),
        envelope_exp(duration, tau=0.055, sample_rate=sample_rate),
    )
    return edge_fade(
        mix(body, wires, ga=1.0, gb=noise_gain),
        sample_rate=sample_rate,
    )

Tempo and grid

bpm = 90
step_s = 60 / bpm / 4   # one step = one sixteenth

Patterns

One track per instrument. Replace this example with what you hear.

#          1 e & a 2 e & a 3 e & a 4 e & a
intro = [
    ("x...x.xx", lambda sample_rate: pitched_snare(sample_rate=sample_rate, frequency=98), step_s),
]

tracks = [
    ("x.......x.......", lambda sample_rate: pitched_snare(sample_rate=sample_rate, frequency=98), step_s),
    ("....x.......x...", lambda sample_rate: pitched_snare(sample_rate=sample_rate, frequency=65), step_s),
    ("..xxx.x..xxxx.x.", lambda sample_rate: closed_hat(sample_rate=sample_rate, amplitude=.05), step_s),
    ("x.......x.......", lambda sample_rate: open_hat(sample_rate=sample_rate, amplitude=.05, tau=0.1), step_s),
]

intro_bar = render_tracks(intro)
bar = render_tracks(tracks)

Listen

play(intro_bar + bar * 4)