Esempio n. 1
0
def color_flow(state):
    dimm = 0.5 # Be kind to our retinas

    pulse_len = 12.5

    # Get base color from palette
    p1 = [(0.5,0.5,0.5,0.0),
          (0.5,0.5,0.5,0.0),
          (2.0,1.0,0.0,0.0),
          (0.5,0.20,0.25,0.0)]

    # Cycle through the palette
    cycle_period = 15 * 60 # 15 minutes
    base = fn.palette(*p1, osc.saw(cycle_period, state.t))

    # flowing pulse
    v_pos = fn.linear_window_duration(1,
                                      pulse_len,
                                      state.t % (pulse_len * 1.1)) \
                * (state.v_res + 8)

    f_pulse = fn.linear_window(-8 + v_pos, 0 + v_pos, state.v)
    pulse = 1.0 - fn.parabola(1.95, f_pulse)

    return (base[0] * pulse * dimm,
            base[1] * pulse * dimm,
            base[2] * pulse * dimm,
            0.04)
Esempio n. 2
0
def synth_adsr(a, d, s, r, t_on, t_off, v, t):
    """
    Generate envelope from synth state based on
    Attack: Time until max value
    Decay: Time until sustain is reached
    Sustain: Sustain level
    Release: Time until zero level is reached
    """

    if t_on <= 0.0:
        return 0.0

    # Release
    if t_off > t_on and t > t_off + r:
        return 0.0

    if t >= t_off and t_off > t_on:
        release_win = fn.linear_window_duration(t_off, r, t)
        release = fn.interpolate_cosine(s, 0.0, release_win)

        return release

    # Attack
    if t >= t_on and t < t_on + a:
        attack_win = fn.linear_window_duration(t_on, a, t)
        attack = fn.interpolate_cosine(0.0, v, attack_win)

        return attack

    # Decay
    if t >= t_on + a and t < t_on + a + d:
        decay_win = fn.linear_window_duration(t_on + a, d, t)
        decay = fn.interpolate_cosine(v, s, decay_win)

        return decay

    if t >= t_on:
        return s

    if t_off > t_on and t >= t_off:
        return 0.0

    return 0.0
Esempio n. 3
0
def flow_pulse(state):
    pulse_len = 4.5

    blue_base = 0.2 * gen.waber(1, 0, state)

    # hull parabola / outer fade
    f_hull = fn.linear_window(-2, state.v_res + 1, state.v)
    hull = fn.mix(0.1, 1.0, fn.parabola(8, f_hull))

    # flowing pulse
    v_pos = fn.linear_window_duration(1, pulse_len, state.t % (pulse_len * 1.5)) * (state.v_res + 8)
    f_pulse = fn.linear_window(-8 + v_pos, 0 + v_pos, state.v)
    pulse = fn.parabola(4, f_pulse) * hull

    # flowing pulse
    v_pos2 = fn.linear_window_duration(1.4, pulse_len, state.t % (pulse_len * 1.5)) * (state.v_res + 8)
    f_pulse2 = fn.linear_window(-8 + v_pos2, 0 + v_pos2, state.v)
    pulse2 = fn.parabola(4, f_pulse2) * hull

    return (0, pulse2, blue_base, pulse)
Esempio n. 4
0
def pulse_wob(state):
    blue_base = 0.2 * gen.waber(1, 0, state)

    pulse_base = 1.0 - fn.impulse(8,
                                  fn.linear_window_duration(
                                    4, 1, state.t % 10.0))


    pulse_up = fn.impulse(8, fn.linear_window(pulse_base * state.v_res - 1,
                                               pulse_base * state.v_res + 8,
                                               state.v))

    return (0, 0, blue_base, pulse_up * 0.7)
Esempio n. 5
0
def gauge_pulse(state):

    base = 0.2 * gen.waber(1, 0, state)
    base2 = 0.08 * gen.waber(1, 5, state)

    f0 = fn.impulse(12, fn.linear_window_duration(5, 2, state.t % 10))
    f1 = osc.cosine(8, state.t)

    f1p = fn.mix(0.1, 0.3, f1)

    f3 = fn.clamp(0, 1, f1p + f0)

    # Render gauge
    gauge = gen.gauge(f3, state)


    # return (0.3 * gauge, 0, 0.2 * gauge + base, base2)
    return (0, 0.4 * gauge,  0.2 * gauge + base, base2)
Esempio n. 6
0
def pulse(state):

    pulse_up = osc.linear(0, 13, 2, state.t)
    if state.v == pulse_up:
        return (1,0,0,0)

    return (0,0,0,0)


    pulse_base = 1.0 - fn.impulse(8,
                                  fn.linear_window_duration(
                                    0, 1, state.t % 3.0))


    pulse_up = fn.impulse(8, fn.linear_window(pulse_base * state.v_res - 1,
                                               pulse_base * state.v_res + 8,
                                               state.v))

    return (pulse_up, 0,0,0)