Exemple #1
0
# prepare control signals
W = 1024
H = 128
T_out = T
N_out = int(np.ceil(SR * T_out))
y = np.zeros(N_out)

# activation gate
tone_out_T0 = 1
tone_out_N0 = tone_out_T0 * SR
tone_out_N1 = N_out
gate_0 = np.zeros_like(y)
gate_0[tone_out_N0:tone_out_N1] = 1

rs = envelopes.region_segmenter(H)
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))
av = time_map_tstretch.attack_avoider(attack_times, -3 * H, W + 2 * H, H)
aaa = time_map_tstretch.attack_avoid_access(
    lambda t, r: pv.process(int(np.round(t)), r), av)
ps = pitch_shift.pitch_shifter(aaa, B=H)
adsr = envelopes.gate_to_adsr(200, 1, 1, 200)

# control signals
pos_sig = np.linspace(3 * SR, 3 * SR, N_out)
ps_sig = np.linspace(ps_0, ps_0, N_out)
ts_sig = np.linspace(ts_0, ts_0, N_out)

for n_ in range(0, N_out, H):
    seg_starts[seg_starts != 0])
seg_starts *= note_states
seg_ends = np.diff(np.concatenate((seg_sig, [0])))
seg_ends[seg_ends != 0] = seg_ends[seg_ends != 0] / np.abs(
    seg_ends[seg_ends != 0])
seg_ends *= note_states

n = np.arange(N)
common.logic_plot(n, 0.9 * note_starts + 2, label='note starts')
common.logic_plot(n, 0.9 * note_ends + 1, label='note ends')
common.logic_plot(n, 0.9 * note_states, label='note states')
common.logic_plot(n, 0.5 * seg_sig + 3.5, label='segmenting signal')
common.logic_plot(n, 0.25 * seg_starts + 3.5, label='segment starts')
common.logic_plot(n, 0.25 * seg_ends + 3.5, label='segment ends')

rs = region_segmenter(N_blk)
rs_starts_dict = dict(label='augmented starts')
rs_ends_dict = dict(label='augmented ends')
for n_ in range(0, N - N_blk, N_blk):
    ant, ans, ane, regs = rs.region_segmenter_update(note_starts[n_:],
                                                     note_ends[n_:],
                                                     note_states[n_:])
    common.logic_plot(n[n_:n_ + N_blk + 1],
                      0.4 * ans + 4.5,
                      color='k',
                      **rs_starts_dict)
    common.logic_plot(n[n_:n_ + N_blk + 1],
                      0.4 * ane + 4.5,
                      color='grey',
                      **rs_ends_dict)
    for s, e in regs: