af = dummy_access()
        wl.access(t, l, af)
        return af.values

    def ts_access(t, n):
        # we just get samples as close to the beginning of the delay line as possilbe
        t = wl.time_zero_ago - W
        return pv.process(t, False)
else:
    wl = window_tools.windowed_lookup(x, W)

    def wl_access(t, l):
        return wl.access(t)


pv = pvoc_synth(signal.get_window('hann', W), signal.get_window('hann', W), W,
                H, wl_access)

if not REAL_TIME:
    ts_access = time_stretch_ts_access(s, pv, av)

ps = pitch_shifter(ts_access, B=H)

y = np.zeros_like(x)
for h in range(0, N, H):
    if REAL_TIME:
        wl.process(x[h:h + H])
    ts_access.s = np.mean(s[h:h + H])
    y[h:h + H] = ps.process(p[h:h + H])

fig, axs = plt.subplots(2, 1)
f1 = 600 / 16000
ps0 = 0.5
ts0 = 1 / 3
ps1 = 2
ts1 = -3
x = np.concatenate((
    signal.chirp(np.arange(W), f0, W, f0),
    np.zeros(N0 - W),
    signal.chirp(np.arange(W), f1, W, f1),
    np.zeros(N1 - W),
))
x += np.random.standard_normal(N) * 1e-6

wl = windowed_lookup(x, W)

pv = pvoc_synth(signal.get_window('hann', W), signal.get_window('hann', W), W,
                H, lambda n: wl.access(n))

ps = pitch_shift.pitch_shifter(lambda t: pv.process(int(np.round(t)), False))
y = np.zeros(N)
for n in np.arange(0, N0 - W, H):
    y[n:n + H] = ps.process(np.ones(H) * ps0, np.ones(H) * ts0)
pv.reset_past_output()
ps.set_pos_at_block_start(N0)
for n in np.arange(N0, N - H, H):
    y[n:n + H] = ps.process(np.ones(H) * ps1, np.ones(H) * ts1)

x.tofile('/tmp/in.f64')
y.tofile('/tmp/out.f64')
n = np.arange(N)
plt.plot(n, x, label='in')
plt.plot(n, y, label='out')