Beispiel #1
0
def envelopes():
    type_hint, time_hint = env_hint()
    acc = []

    def pick_time(hint):
        if hint == "fast":
            return rnd(0.1)
        elif hint == "medium":
            return coin(0.75, rnd(0.2), rnd(0.5))
        else:
            return 0.5 + coin(0.75, rnd(2), rnd(6))

    for op in (1, 2, 3):
        typ = coin(p_env_changeup, pick(["adsr", "asr", "perc"]), type_hint)
        tm = coin(p_env_changeup, pick(["fast", "medium", "slow"]), time_hint)

        att = pick_time(tm)
        dcy = pick_time(tm)
        rel = pick_time(tm)
        sus = coin(0.5, 0.5 + rnd(0.5), rnd())
        if typ == "asr":
            sus = 1.0
        elif typ == "perc":
            sus = coin(0.75, 0.0, rnd(0.1))
            dcy /= 2
            rel *= 2
        acc.append((att, dcy, sus, rel))
    return acc
Beispiel #2
0
 def pick_time(hint):
     if hint == "fast":
         return rnd(0.1)
     elif hint == "medium":
         return coin(0.75, rnd(0.2), rnd(0.5))
     else:
         return 0.5 + coin(0.75, rnd(2), rnd(6))
Beispiel #3
0
def pick_env_type_hint(hint=None, p_changeup=1.0):
    hint = hint or coin(0.8,
                        coin(0.25, PERCUSSIVE,ADSR),
                        coin(0.67, ASR, GATE))
    if coin(p_changeup):
        return pick_env_type_hint(hint,0)
    return hint
Beispiel #4
0
def envelopes():
    type_hint, time_hint = env_hint()
    acc = []
    def pick_time(hint):
        if hint == "fast":
            return rnd(0.1)
        elif hint == "medium":
            return coin(0.75, rnd(0.2), rnd(0.5))
        else:
            return 0.5+coin(0.75, rnd(2), rnd(6))
    for op in (1,2,3):
        typ = coin(p_env_changeup, pick(["adsr","asr","perc"]), type_hint)
        tm = coin(p_env_changeup, pick(["fast","medium","slow"]), time_hint)
        
        att = pick_time(tm)
        dcy = pick_time(tm)
        rel = pick_time(tm)
        sus = coin(0.5, 0.5+rnd(0.5), rnd())
        if typ == "asr":
            sus = 1.0
        elif typ == "perc":
            sus = coin(0.75, 0.0, rnd(0.1))
            dcy /= 2
            rel *= 2
        acc.append((att,dcy,sus,rel))
    return acc
Beispiel #5
0
 def pick_time(hint):
     if hint == "fast":
         return rnd(0.1)
     elif hint == "medium":
         return coin(0.75, rnd(0.2), rnd(0.5))
     else:
         return 0.5+coin(0.75, rnd(2), rnd(6))
Beispiel #6
0
def pick_filter(id):
    floor,ceiling = 100,16000
    ff = int(floor+rnd(ceiling-floor))
    trk = coin(0.75,0,pick((0.5,1,2)))
    head = ceiling-ff
    r = rnd()
    if r<0.25:
        env = cenv = 0
    elif r<0.50:
        env = int(rnd(head))
        cenv = 0
    elif r<0.75:
        cenv=int(rnd(head))
        env=int(rnd(head-cenv))
    else:
        env=0
        cenv=int(rnd(head))
    if ff > 6000:
        env = coin(0.8,-1,1)*env
        cenv = coin(0.8,-1,1)*cenv
    if cenv==0 and env==0:
        plfo = 0.5
    else:
        plfo = 0.1
    lfo = coin(plfo, int(head), 0)
    vlfo = coin(0.05,int(head),0)
    return filter(id,freq=ff,track=trk,
                  env=env,cenv=cenv,lfo=lfo,vlfo=vlfo,
                  res=rnd())
Beispiel #7
0
def pick_env_time_hint(is_percussive=False):
    if is_percussive:
        h = coin(0.74, SLOW, coin(0.67, MEDIUM, GLACIAL))
    else:
        h = coin(0.75,
                 pick((ULTRA_FAST,FAST,FAST, MEDIUM)),
                 pick((FAST,MEDIUM,SLOW,GLACIAL,FULL)))
    return h
Beispiel #8
0
def _env(n, time_hint, mode):
    times = []
    for i in range(4):
        times.append(_env_time(time_hint))
    bp = r(coin(0.75, 0.5 + rnd(0.5), rnd()))
    sus = r(coin(0.75, 0.5 + rnd(0.5), rnd()))
    mode = coin(0.90, mode, coin(0.50, 0, 1))
    return env(n, times, [bp, sus], mode)
Beispiel #9
0
def pick_fm_modulation_ratio(is_harmonic):
    if is_harmonic:
        rs = coin(0.75,
                  pick(HARMONICS),
                  pick(HARMONICS2))
    else:
        rs = coin(0.75, 0.5+rnd(5), rnd(12))
    return rs
Beispiel #10
0
def _env(n, time_hint, mode):
    times = []
    for i in range(4):
        times.append(_env_time(time_hint))
    bp = r(coin(0.75, 0.5+rnd(0.5), rnd()))
    sus = r(coin(0.75, 0.5+rnd(0.5), rnd()))
    mode = coin(0.90, mode, coin(0.50, 0, 1))
    return env(n,times,[bp,sus],mode)
Beispiel #11
0
def percussion_envelope(time_hint):
    a = env_segment_time(0.05)
    d1 = env_segment_time(time_hint*0.5)
    d2 = env_segment_time(time_hint)
    r = env_segment_time(time_hint)
    bp = coin(0.75, 0.9+rnd(0.1), 0.5+rnd(0.5))
    s = coin(0.75, min(0.5+rnd(0.5), bp), rnd(0.25))
    hold = True
    return a,d1,d2,r,bp,s,hold
Beispiel #12
0
def addsr_envelope(time_hint):
    a = env_segment_time(time_hint)
    d1 = env_segment_time(time_hint)
    d2 = env_segment_time(time_hint)
    r = env_segment_time(time_hint)
    bp = coin(0.75, 0.9+rnd(0.1), 0.5+rnd(0.5))
    s = coin(0.50, rnd(bp), rnd())
    hold = False  # coin(0.75, False, True)
    return a,d1,d2,r,bp,s,hold
Beispiel #13
0
def pick_stack_feedback(p_feedback):
    fb = env = lfo = 0.0
    if coin(p_feedback):
        fb, env, lfo = coin(
            0.75,  # p "simple" feedback w/o modulation
            (rnd(2), 0.0, 0.0),
            (coin(0.33, rnd(), 0), coin(0.33, rnd(), 0), coin(0.33, rnd(), 0)))
    fb = _round(fb)
    env = _round(env)
    lfo = _round(lfo)
    return fb, env, lfo
Beispiel #14
0
def pick_stack_feedback(p_feedback):
    fb = env = lfo = 0.0
    if coin(p_feedback):
        fb,env,lfo = coin(0.75,      # p "simple" feedback w/o modulation
                          (rnd(2),0.0,0.0),
                          (coin(0.33, rnd(), 0),
                           coin(0.33, rnd(), 0),
                           coin(0.33, rnd(), 0)))
    fb = _round(fb)
    env = _round(env)
    lfo = _round(lfo)
    return fb,env,lfo
Beispiel #15
0
def random_flanger(slot=127, *_):
    p = flngr(slot, "Random", amp=0,
              delay = coin(0.75, 0.5, rnd()),
              modDepth = rnd(),
              modFreq = coin(0.75, rnd(), rnd(10)),
              feedback = random_sign()*rnd(0.9),
              loweq = coin(0.75, 20000, pick([1000, 2000, 4000, 8000])),
              higheq = coin(0.75, 20, pick([200, 400, 800, 1600])),
              efxMix = coin(0.75, 0.5+rnd(0.5), rnd()),
              xmodDepth = 0.0,
              xmixScale = 0.0)
    return p
Beispiel #16
0
def percussive_envelope(time_hint):
    if time_hint < MEDIUM:
        time_hint = pick_env_time_hint(True)
    junk,dcy1,dcy2,rel = pick_env_times(time_hint,0.0)
    att = coin(0.80, 0.00, rnd(0.01))
    dcy1,dcy2 = min(dcy1,dcy2),max(dcy1,dcy2)
    while dcy1 > 1:
        dcy1 = dcy1-1
    if dcy2 < 0.5:
        dcy2 = coin(0.25, dcy2, pick([dcy1*2,dcy1*3,dcy1*4]))
    bp = coin(0.50,rnd(0.75),0.75)
    sus = coin(0.90,0.0,rnd(0.12))
    return round_env_values([att,dcy1,dcy2,rel,bp,sus,0])
Beispiel #17
0
def random_flanger(slot=127, *_):
    p = flngr(slot,
              "Random",
              amp=0,
              delay=coin(0.75, 0.5, rnd()),
              modDepth=rnd(),
              modFreq=coin(0.75, rnd(), rnd(10)),
              feedback=random_sign() * rnd(0.9),
              loweq=coin(0.75, 20000, pick([1000, 2000, 4000, 8000])),
              higheq=coin(0.75, 20, pick([200, 400, 800, 1600])),
              efxMix=coin(0.75, 0.5 + rnd(0.5), rnd()),
              xmodDepth=0.0,
              xmixScale=0.0)
    return p
Beispiel #18
0
def pick_env_segment_time(time_hint):
    if time_hint == ULTRA_FAST:
        rs = coin(0.75, 0.0, rnd(0.03))
    elif time_hint == FAST:
        rs = rnd(0.1)
    elif time_hint == MEDIUM:
        rs = 0.1+rnd(0.5)
    elif time_hint == SLOW:
        rs = 0.5+rnd(6)
    else:
        rs = 4+rnd(MAX_ENV_SEGMENT_TIME-4)
    if coin(0.1):
        rs = pick_env_segment_time(pick_env_time_hint())
    return rs
Beispiel #19
0
def _percussive_envelope(time_hint):
    if time_hint < MEDIUM:
        time_hint = pick_env_time_hint(True)
    status("Percussive", time_hint)
    junk, dcy1, dcy2, rel = pick_envelope_times(time_hint, 0.0)
    att = coin(0.80, 0.00, rnd(0.01))
    dcy1, dcy2 = min(dcy1, dcy2), max(dcy1, dcy2)
    if dcy1 > 1:
        dcy1 = coin(0.75, rnd(), dcy1)
    if dcy2 < 0.5:
        dcy2 = coin(0.25, dcy2, pick((dcy1 * 2, dcy1 * 3, dcy1 * 4)))
    bp = coin(0.50, rnd(0.75), 0.75)
    sus = coin(0.90, 0.0, rnd(0.12))
    return _round_env_values((att, dcy1, dcy2, rel, bp, sus, 0))
Beispiel #20
0
def _percussive_envelope(time_hint):
    if time_hint < MEDIUM:
        time_hint = pick_env_time_hint(True)
    status("Percussive", time_hint)
    junk,dcy1,dcy2,rel = pick_envelope_times(time_hint,0.0)
    att = coin(0.80, 0.00, rnd(0.01))
    dcy1, dcy2 = min(dcy1,dcy2),max(dcy1,dcy2)
    if dcy1 > 1:
        dcy1 = coin(0.75, rnd(), dcy1)
    if dcy2 < 0.5:
        dcy2 = coin(0.25, dcy2, pick((dcy1*2,dcy1*3,dcy1*4)))
    bp = coin(0.50,rnd(0.75),0.75)
    sus = coin(0.90, 0.0, rnd(0.12))
    return _round_env_values((att,dcy1,dcy2,rel,bp,sus,0))
Beispiel #21
0
def scanner_random(slot,*_):
    srate = coin(0.50, rnd(7),coin(0.90, rnd(), rnd(100)))
    wave = coin(0.70, 0.5, rnd())
    delay = rnd(0.05)
    depth = rnd()
    feedback = random_sign(0.5, coin(0.75, 0.5+rnd(0.49), rnd(0.75)))
    if abs(feedback) > 0.75:
        lowpass = pick((16000, 12000, 8000, 8000, 8000, 4000, 4000, 2000))
    else:
        lowpass = 16000
    dry = 0.5
    wet = 0.5

    return scanner(slot, "Random",
                   srate, wave, delay, depth,
                   feedback,lowpass, dry, wet, wet, 0.0)
Beispiel #22
0
def lfos(pconfig={}):
    vfreq = pick_vibrato_frequency()
    lfo1 = pick_lfo_frequency()
    lfo2 = lfo1
    while lfo2 == lfo1:
        lfo2 = pick_lfo_frequency()
    pvib = pconfig.get("p-vibrato")
    rs = {"vfreq" : vfreq,
          "vdelay" : round(rnd(4),4),
          "vsens" : round(coin(0.75, rnd(0.3),rnd()),4),
          "vdepth" : round(coin(pvib, rnd(),0.0),4),
          "lfo1_ratio" : lfo1,
          "lfo2_ratio" : lfo2,
          "lfo1_delay" : round(coin(0.5, 0.0, rnd()), 4),
          "lfo2_delay" : round(coin(0.5, 0.0, rnd()), 4)}
    return rs
Beispiel #23
0
def env_type_hint(pconfig={}):
    hint = pconfig.get("env-hint",None)
    pchange = pconfig.get("p-env-changeup",0.1)
    def select():
        return pick([GATE,ASR,ADSR,PERCUSSIVE])
    if not hint: hint = select()
    return coin(pchange, select(), hint)
Beispiel #24
0
def cratios():
    harmonic = (1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4,
                5, 6, 8)
    acc = []
    for i in range(3):
        acc.append(coin(0.80, pick(harmonic), rnd(8)))
    return tuple(acc)
Beispiel #25
0
def env_time_hint(pconfig={}):
    hint = pconfig.get("env-time-hint", None)
    pchange = pconfig.get("p-env-changeup",0.1)
    def select():
        return coin(0.75, coin(0.5,FAST,MEDIUM),coin(0.5,SLOW,GLACIAL))
    if not hint: hint = select()
    return coin(pchange, select(), hint)
Beispiel #26
0
def pick_env_type_hint(hint=None, p_changeup=1.0):
    hint = hint or pick((GATE, PERCUSSIVE, PERCUSSIVE, PERCUSSIVE, PERCUSSIVE,
                         ADSR, ADSR, ADSR, ADSR, ASR, ASR))
    #hint = coin(p_changeup, pick_env_type_hint(None,0), hint)
    if coin(p_changeup):
        return pick_env_type_hint(hint, 0)
    return hint
Beispiel #27
0
def pick_env_time_hint(is_percussive=None):
    if is_percussive:
        h = pick((MEDIUM, MEDIUM, SLOW, SLOW, SLOW, SLOW, SLOW, SLOW, SLOW,
                  GLACIAL))
    else:
        h = coin(0.75, pick((ULTRA_FAST, FAST, MEDIUM)),
                 pick((ULTRA_FAST, FAST, MEDIUM, SLOW, GLACIAL, FULL)))
    return h
Beispiel #28
0
 def mutate(self, program):
     current = program[self.param]
     new_value = current
     if coin(self.probability):
         mn,mx = self.range_
         new_value = clip(self.function(current), mn,mx)
         program[self.param] = new_value
     return new_value
Beispiel #29
0
def cratios():
    harmonic = (1,1,1,1,1,1,1,1,
                2,2,2,2,2,2,2,2,
                3,3,3,4,4,5,6,8)
    acc = []
    for i in range(3):
        acc.append(coin(0.80, pick(harmonic), rnd(8)))
    return tuple(acc)
Beispiel #30
0
def random_panner(slot=127, *_):
    static = coin(0.20)
    if static:
        pos = random_sign()
        p = panner(slot, "Random", amp=0, pos=pos, lfoDepth=0, xscale=0)
    else:
        pos = coin(0.75, 0.0, random_sign())
        lfoFreq = coin(0.75, rnd(0.1), rnd(5))
        lfoDepth = rnd()
        p = panner(slot,
                   "Random",
                   amp=0,
                   pos=pos,
                   lfoFreq=lfoFreq,
                   lfoDepth=lfoDepth,
                   xscale=0)
    return p
Beispiel #31
0
def pick_env_type_hint(hint=None, p_changeup=1.0):
    hint = hint or pick((GATE,
                         PERCUSSIVE,PERCUSSIVE,PERCUSSIVE,PERCUSSIVE,
                         ADSR,ADSR,ADSR,ADSR,
                         ASR,ASR))
    #hint = coin(p_changeup, pick_env_type_hint(None,0), hint)
    if coin(p_changeup):
        return pick_env_type_hint(hint,0)
    return hint
Beispiel #32
0
def pick_harmonic_envmod(n):
    if coin(0.60):
        return 0
    else:
        if n > 12:
            psign = 0.75
        else:
            psign = 0.25
    return random_sign(psign)*pick(HARMONICS)
Beispiel #33
0
def env_time_hint(pconfig={}):
    hint = pconfig.get("env-time-hint", None)
    pchange = pconfig.get("p-env-changeup", 0.1)

    def select():
        return coin(0.75, coin(0.5, FAST, MEDIUM), coin(0.5, SLOW, GLACIAL))

    if not hint: hint = select()
    return coin(pchange, select(), hint)
Beispiel #34
0
def pick_filter_mod(ff):
    if coin(0.25):
        if ff > 4000:
            psign = 0.75
        else:
            psign = 0.25
        return random_sign(psign)*pick(FILTER_FREQUENCIES)
    else:
        return 0
Beispiel #35
0
def pitch_env():
    rs = {}
    for a in (0,1,2,3,4):
        v = round(random_sign()*coin(0.5,0,rnd()),4)
        rs["pe_a%d" % a] = v
    for t in (1,2,3,4):
        v = round(rnd(MAX_ENV_SEGMENT), 4)
        rs["pe_t%d" % a] = v
    return rs
Beispiel #36
0
def env_type_hint(pconfig={}):
    hint = pconfig.get("env-hint", None)
    pchange = pconfig.get("p-env-changeup", 0.1)

    def select():
        return pick([GATE, ASR, ADSR, PERCUSSIVE])

    if not hint: hint = select()
    return coin(pchange, select(), hint)
Beispiel #37
0
def random_tremolo(slot=127, *_):
    freq = 0.01 + rnd(10)
    dpth = rnd()
    with_external = coin(0.25)
    if with_external:
        xdepth = coin(0.5, 0, rnd())
        fm = coin(0.5, 0, rnd())
        am = coin(0.5, 0, rnd())
        p = trem(slot, "Random", amp=0,
                 lfo = [freq, dpth],
                 xtern = [xdepth, fm, am],
                 limit = 1)
    else:
        p = trem(slot, "Random", amp=0,
                 lfo = [freq, dpth],
                 xtern = [0.0, 0.0, 0.0],
                 limit = 1)
    return p
Beispiel #38
0
def pick_noise_mod(nfreq):
    if coin(0.25):
        if nfreq > 4000:
            psign = 0.75
        else:
            psign = 0.25
        return random_sign(psign)*pick(FILTER_FREQUENCIES)
    else:
        return 0
Beispiel #39
0
def lfos(pconfig={}):
    vfreq = pick_vibrato_frequency()
    lfo1 = pick_lfo_frequency()
    lfo2 = lfo1
    while lfo2 == lfo1:
        lfo2 = pick_lfo_frequency()
    pvib = pconfig.get("p-vibrato")
    rs = {
        "vfreq": vfreq,
        "vdelay": round(rnd(4), 4),
        "vsens": round(coin(0.75, rnd(0.3), rnd()), 4),
        "vdepth": round(coin(pvib, rnd(), 0.0), 4),
        "lfo1_ratio": lfo1,
        "lfo2_ratio": lfo2,
        "lfo1_delay": round(coin(0.5, 0.0, rnd()), 4),
        "lfo2_delay": round(coin(0.5, 0.0, rnd()), 4)
    }
    return rs
Beispiel #40
0
def pitch_env():
    rs = {}
    for a in (0, 1, 2, 3, 4):
        v = round(random_sign() * coin(0.5, 0, rnd()), 4)
        rs["pe_a%d" % a] = v
    for t in (1, 2, 3, 4):
        v = round(rnd(MAX_ENV_SEGMENT), 4)
        rs["pe_t%d" % a] = v
    return rs
Beispiel #41
0
def random_tremolo(slot=127, *_):
    freq = 0.01 + rnd(10)
    dpth = rnd()
    with_external = coin(0.25)
    if with_external:
        xdepth = coin(0.5, 0, rnd())
        fm = coin(0.5, 0, rnd())
        am = coin(0.5, 0, rnd())
        p = trem(slot, "Random", amp=0,
                 lfo = [freq, dpth],
                 xtern = [xdepth, fm, am],
                 limit = 1)
    else:
        p = trem(slot, "Random", amp=0,
                 lfo = [freq, dpth],
                 xtern = [0.0, 0.0, 0.0],
                 limit = 1)
    return p
Beispiel #42
0
def pick_frequencies(p_harmonic=None):
    if p_harmonic is None:
        p_harmonic = coin(0.75, 0.90, rnd())
    if verbose:
        print("Probability of harmonic frequencies: %s" % p_harmonic)
    acc,bcc = [],[]
    for i in range(8):
        acc.append(_pick_op_ratio(p_harmonic))
        bcc.append(_pick_op_bias(p_harmonic))
    return _round(acc),_round(bcc)
Beispiel #43
0
def _env_time(hint):
    hnt = coin(0.8, hint, pick(['FAST','MEDIUM','SLOW','GLACIAL']))
    if hnt == 'FAST':
        return r(rnd(0.1))
    elif hnt == 'MEDIUM':
        return r(0.1 + rnd(2))
    elif hnt == 'SLOW':
        return r(0.5 + rnd(4))
    else:
        return r(3+rnd(9))
Beispiel #44
0
def _env_time(hint):
    hnt = coin(0.8, hint, pick(['FAST', 'MEDIUM', 'SLOW', 'GLACIAL']))
    if hnt == 'FAST':
        return r(rnd(0.1))
    elif hnt == 'MEDIUM':
        return r(0.1 + rnd(2))
    elif hnt == 'SLOW':
        return r(0.5 + rnd(4))
    else:
        return r(3 + rnd(9))
Beispiel #45
0
def pick_frequencies(p_harmonic=None):
    if p_harmonic is None:
        p_harmonic = coin(0.75, 0.90, rnd())
    if verbose:
        print("Probability of harmonic frequencies: %s" % p_harmonic)
    acc, bcc = [], []
    for i in range(8):
        acc.append(_pick_op_ratio(p_harmonic))
        bcc.append(_pick_op_bias(p_harmonic))
    return _round(acc), _round(bcc)
Beispiel #46
0
def pick_env_segment_time(hint=FULL, p_changeup=0.1):
    hint = coin(p_changeup, pick_env_time_hint(),hint)
    mn,mx = 0.0,MAX_ENV_SEGMENT
    try:
        mn,mx = {ULTRA_FAST : (0.00, 0.01),
                 FAST : (0.00, 0.10),
                 MEDIUM : (0.10, 1.0),
                 SLOW : (1.0,4.0),
                 GLACIAL : (4.0,MAX_ENV_SEGMENT)}[hint]
    except KeyError:
        pass
    return mn+rnd(mx-mn)
Beispiel #47
0
def pick_envelopes(type_hint=None,
                   time_hint=None,
                   p_type_changeup=0.1,
                   p_time_changeup=0.1,
                   p_duplicate_carrier=0.35):
    type_hint = type_hint or pick_env_type_hint()
    time_hint = time_hint or pick_env_time_hint()
    acc = []
    for stk in "ABC":
        tyhint = coin(p_type_changeup,pick_env_type_hint(),type_hint)
        tihint = coin(p_time_changeup,pick_env_time_hint(),time_hint)
        stack = _pick_stack_envelopes(tyhint,tihint,p_type_changeup,p_time_changeup)
        if stk == "A":
            for e in stack: acc.append(e)
        elif stk == "B":
            acc.append(stack[1])
            acc.append(stack[0])
            acc.append(stack[2])
        else:
            acc.append(stack[0])
            acc.append(stack[1])
    return acc
Beispiel #48
0
def _pick_stack_envelopes(type_hint=None,
                          time_hint=None,
                          p_type_changeup=0.1,
                          p_time_changeup=0.1,
                          p_duplicate_carrier=0.35):
    acc = []
    type_hint = type_hint or pick_env_type_hint()
    time_hint = time_hint or pick_env_time_hint()
    for i in range(3):
        if i > 0 and coin(p_duplicate_carrier):
            acc.append(acc[0])
        else:
            env_type = pick_env_type_hint(type_hint, p_type_changeup)
            tihint = coin(p_time_changeup, pick_env_time_hint(), time_hint)
            if env_type == ADSR:
                acc.append(_adsr_envelope(tihint))
            elif env_type == ASR:
                acc.append(_asr_envelope(tihint))
            elif env_type == PERCUSSIVE:
                acc.append(_percussive_envelope(tihint))
            else:
                acc.append(_gate_envelope())
    return tuple(acc)
Beispiel #49
0
def pick_env_segment_time(hint=FULL, p_changeup=0.1):
    hint = coin(p_changeup, pick_env_time_hint(), hint)
    mn, mx = 0.0, MAX_ENV_SEGMENT
    try:
        mn, mx = {
            ULTRA_FAST: (0.00, 0.01),
            FAST: (0.00, 0.10),
            MEDIUM: (0.10, 1.0),
            SLOW: (1.0, 4.0),
            GLACIAL: (4.0, MAX_ENV_SEGMENT)
        }[hint]
    except KeyError:
        pass
    return mn + rnd(mx - mn)
Beispiel #50
0
def env(op, pconfig={}):
    type_hint = env_type_hint(pconfig)
    time_hint = env_time_hint(pconfig)

    def pick_time():
        if time_hint == FAST:
            rs = 0.0 + rnd(0.05)
        elif time_hint == MEDIUM:
            rs = 0.05 + rnd(0.5)
        elif time_hint == SLOW:
            rs = 0.5 + rnd(2)
        elif time_hint == GLACIAL:
            d = MAX_ENV_SEGMENT - 2
            rs = 2 + rnd(d)
        else:
            rs = rnd(MAX_ENV_SEGMENT)
        return round(rs, 4)

    att = dcy1 = dcy2 = rel = 0.0
    bp = sus = 1.0
    mode = 0
    if type_hint == PERCUSSIVE:
        att = round(coin(0.75, 0.0, rnd(0.05)), 4)
        dcy1 = 0.5 * pick_time()
        dcy2 = pick_time()
        rel = pick_time()
        bp = round(coin(0.75, 0.5 + rnd(0.5), rnd()), 4)
        sus = 0
        mode = coin(0.75, 0, 1)
    elif type_hint == GATE:
        att = dcy1 = dcy2 = rel = 0.0
        bp = sus = 1.0
        mode = 0
    elif type_hint == ASR:
        att = pick_time()
        rel = pick_time()
        dcy1 = dcy2 = 0
        bp = sus = 1
        mode = 0
    else:
        att = pick_time()
        dcy1 = pick_time()
        dcy2 = pick_time()
        rel = pick_time()
        bp = round(coin(0.75, 0.5, rnd()), 4)
        sus = round(coin(0.75, rnd(bp), rnd()), 4)
        mode = coin(0.90, 0, 1)
    rs = {
        "op%d_attack" % op: att,
        "op%d_decay1" % op: dcy1,
        "op%d_decay2" % op: dcy2,
        "op%d_release" % op: rel,
        "op%d_breakpoint" % op: bp,
        "op%d_sustain" % op: sus,
        "op%d_env_mode" % op: mode
    }
    return rs
Beispiel #51
0
def pick_envelopes(type_hint=None,
                   time_hint=None,
                   p_type_changeup=0.1,
                   p_time_changeup=0.1,
                   p_duplicate_carrier=0.35):
    type_hint = type_hint or pick_env_type_hint()
    time_hint = time_hint or pick_env_time_hint()
    acc = []
    for stk in "ABC":
        tyhint = coin(p_type_changeup, pick_env_type_hint(), type_hint)
        tihint = coin(p_time_changeup, pick_env_time_hint(), time_hint)
        stack = _pick_stack_envelopes(tyhint, tihint, p_type_changeup,
                                      p_time_changeup)
        if stk == "A":
            for e in stack:
                acc.append(e)
        elif stk == "B":
            acc.append(stack[1])
            acc.append(stack[0])
            acc.append(stack[2])
        else:
            acc.append(stack[0])
            acc.append(stack[1])
    return acc
Beispiel #52
0
def random_program(slot=127, *_):
    lp = [
        400, 800, 1600, 3150, 6300, 8000, 10000, 10000, 10000, 10000, 16000,
        16000, 16000, 16000
    ]
    hp = [20, 100, 100, 100, 100, 200, 400, 800, 1600, 3150]
    p = carnal(slot,
               "Random",
               amp=0,
               delayTime=coin(0.5, rnd(0.5), rnd(MAX_DELAY)),
               xDelay=0,
               wow=coin(0.75, 0, coin(0.75, rnd(0.1), rnd())),
               wowFreq=coin(0.75, rnd(), rnd(5)),
               flutter=coin(0.75, 0, coin(0.75, rnd(0.2), rnd())),
               feedback=coin(0.75, 0.5 + rnd(0.4), rnd(0.95)),
               gain=1.0,
               threshold=1.0,
               eq=[pick(lp), pick(hp)],
               wetMix=coin(0.75, 0.5 + rnd(0.25), rnd()),
               xWetMix=0)
    return p
Beispiel #53
0
def fm_params(op, pconfig={}):
    pdeep = pconfig.get("p-deep-modulation", 0.1)
    plfo = pconfig.get("p-lfo", 0.1)
    mscale = coin(pdeep, pick([1, 10, 100, 1000, 10000]),
                  pick([1, 1, 10, 10, 10, 10]))
    rs = {
        "fm%d_ratio" % op: pick_ratio(pconfig),
        "fm%d_moddepth" % op: round(coin(0.75, rnd(), 0.0), 4),
        "fm%d_modscale" % op: float(mscale),
        "fm%d_lag" % op: round(coin(0.50, 0.0, rnd()), 4),
        "fm%d_lfo1" % op: round(coin(plfo, coin(0.5, rnd(0.25), rnd()), 0.0),
                                4),
        "fm%d_lfo2" % op: round(coin(plfo, coin(0.5, rnd(0.25), rnd()), 0.0),
                                4),
        "fm%d_external" % op: 0.0,
        "fm%d_left" % op: 0,
        "fm%d_right" % op: 0
    }
    return rs
Beispiel #54
0
def car(op, ff, ratios, envs, amp):
    env = envs[op - 1]
    mode = coin(0.50, 0, 1)
    modDepth = coin(0.75, rnd(4), rnd(8))
    if mode: modDepth /= 2.0
    rs = carrier(op,
                 formant=ff[op - 1],
                 ratio=ratios[op - 1],
                 mode=mode,
                 velocity=coin(0.75, rnd(), 0),
                 tremolo=coin(0.75, 0, coin(0.75, rnd(0.3), rnd())),
                 modDepth=modDepth,
                 attack=env[0],
                 decay=env[1],
                 sustain=env[2],
                 release=env[3],
                 lag=coin(0.5, 0, rnd()),
                 key=60,
                 leftScale=0,
                 rightScale=0,
                 x=0.0,
                 amp=amp)
    return rs
Beispiel #55
0
def io_random(slot, *_):
    envs = envelopes()
    amps = []
    for i in (1, 2, 3):
        amps.append(coin(0.75, 0.5 + rnd(), rnd()))
    amps[pick((0, 1, 2))] = 1.0
    ff = cformants()
    rr = cratios()
    p = io(slot,
           "Random",
           amp=0.1,
           vibrato=vibrato(freq=coin(0.75, 4 + rnd(4), rnd(16)),
                           lock=coin(0.75, 1, 0),
                           noise=coin(0.5, 0.0, rnd()),
                           sens=coin(0.80, rnd(0.1), rnd()),
                           depth=coin(0.25, 0, coin(0.75, rnd(0.3), rnd())),
                           x=0.0,
                           tremRatio=trem_ratio()),
           blip=blip(attack=coin(0.75, rnd(0.1), rnd(MAX_BLIP_SEGMENT_TIME)),
                     decay=coin(0.75, 0.1 + rnd(0.2),
                                rnd(MAX_BLIP_SEGMENT_TIME)),
                     depth=coin(0.75, 0.0, coin(0.75, rnd(0.2), rnd()))),
           noise=noise(ratio=coin(0.75, 1.0, pick(NOISE_RATIOS)),
                       amp=coin(0.75, rnd(0.4), rnd())),
           modulator=modulator(ratio=pick((1, 1, 1, 1, 2, 2, 2, 2, 3, 4)),
                               feedback=coin(0.5, 0.0,
                                             coin(0.75, rnd(2), rnd(4))),
                               lfo=coin(0.75, 0.0, coin(0.75, rnd(0.2),
                                                        rnd()))),
           op1=car(1, ff, rr, envs, amps[0]),
           op2=car(2, ff, rr, envs, amps[1]),
           op3=car(3, ff, rr, envs, amps[2]))
    return p
Beispiel #56
0
def trem_ratio():
    r = coin(0.75, (1.0, ""), pick(TREMOLO_RATIOS))
    return r[0]
Beispiel #57
0
def _pick_mod_scale(p_deep_modulation=0.1):
    s = coin(p_deep_modulation,
             coin(0.75, pick((1e2,1e3)), pick((1e4,1e5))),
             coin(0.50, 1,10))
    return s
Beispiel #58
0
 def pick_amps():
     q = coin(0.1, 1.0, coin(0.75, 0.3+rnd(0.7), coin(0.5, rnd(0.3),0)))
     r = coin(0.1, 1.0, coin(0.75, 0.3+rnd(0.7), coin(0.5, rnd(0.3),0)))
     return 1.0,_round(r),_round(q)
Beispiel #59
0
def m_random(slot=127, *_):
    time_hint = pick(('FAST', 'MEDIUM', 'SLOW', 'GLACIAL'))
    env_mode = coin(0.80, 0, 1)
    rb1 = _tune()
    rb2 = coin(0.50, rb1 + (coin(0.50, rnd(0.01), 0)), _tune())
    amps = []
    for i in range(3):
        amps.append(coin(0.75, 0.333 + rnd(0.667), 0))
    amps.append(coin(0.75, 0, rnd()))
    amps[pick([0, 1, 2])] = 1.0
    p = m(slot,
          "Random",
          port=coin(0.1, rnd(), 0),
          amp=0.1,
          lfo=lfo(vFreq=r(
              coin(0.75, 4 + rnd(4), coin(0.75, 1 + rnd(9), rnd(99)))),
                  vSens=r(coin(0.75, 0.1, rnd())),
                  vDepth=r(coin(0.75, 0.0, rnd())),
                  xPitch=0.0,
                  aRatio=_lfo_ratio(),
                  bRatio=_lfo_ratio(),
                  cRatio=_lfo_ratio(),
                  aDelay=pick(LFO_DELAYS),
                  bDelay=pick(LFO_DELAYS),
                  cDelay=pick(LFO_DELAYS),
                  tLag=r(coin(0.50, 0, rnd()))),
          enva=_env('a', time_hint, env_mode),
          envb=_env('b', time_hint, env_mode),
          envc=_env('c', time_hint, env_mode),
          a=toneA(ratio=min(
              _tune() *
              pick([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 6, 8, 12, 16, 24, 32]), 99),
                  keyscale=[60, 0, 0],
                  quotient=[
                      pick([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),
                      coin(0.75, 0, pick(range(8))),
                      coin(0.75, 0, pick(range(8))), 0
                  ],
                  pulse=[
                      r(coin(0.5, 0.5, rnd())),
                      r(coin(0.75, 0.0, rnd())),
                      r(coin(0.75, 0.0, rnd())), 0.0
                  ],
                  clkmix=coin(0.75, 0.0, rnd()),
                  envpitch=coin(0.90, 0.0,
                                sign() * rnd()),
                  tremolo=coin(0.75, 0, rnd())),
          b=toneB(ratio1=rb1,
                  ratio2=rb2,
                  keyscale=[60, 0, 0],
                  n1=[
                      pick(range(32)),
                      coin(0.75, 0.0, pick(range(32))),
                      coin(0.75, 0.0, pick(range(32))), 0.0
                  ],
                  n2=[
                      pick(range(32)),
                      coin(0.50, 0.0, rnd()),
                      coin(0.75, -1, coin(0.75, 1, 0))
                  ],
                  envpitch=coin(0.90, 0.0,
                                sign() * rnd()),
                  tremolo=coin(0.75, 0, rnd())),
          c=toneC(ratio=_ctune(),
                  keyscale=[60, 0, 0],
                  pulseFreq=[
                      _ctune(),
                      coin(0.75, 0, pick(range(4))),
                      coin(0.75, 0, pick(range(4))), 0.0
                  ],
                  pwm=[
                      coin(0.5, 0.5, rnd()),
                      coin(0.5, 0.0, rnd()),
                      coin(0.75, 0.0, rnd()), 0.0
                  ],
                  inciteSelect=coin(0.50, 0.0, rnd()),
                  envpitch=coin(0.90, 0,
                                sign() * rnd()),
                  tremolo=coin(0.75, 0, rnd())),
          noise=noise(lp=coin(0.75, 20000, 500 + coin(5000)),
                      hp=coin(0.75, 10, 500 + coin(5000)),
                      lag=coin(0.5, 0.0, rnd()),
                      tremolo=coin(0.75, 0, rnd())),
          mix=mixer(mix=amps,
                    pan=[
                        sign() * rnd(),
                        sign() * rnd(),
                        sign() * rnd(),
                        sign() * rnd()
                    ]),
          f1=filter_(
              1,
              freq=r(coin(0.75, rnd(5000), rnd(20000))),
              track=r(pick([0, 0, 0, 1])),
              res=coin(0.75, rnd(0.5), rnd()),
              lfo=[coin(0.75, 0.0, rnd(5000)),
                   coin(0.75, 0.0, rnd(5000))],
              env=[
                  coin(0.25, 0, coin(0.75, rnd(10000), -rnd(10000))),
                  coin(0.25, 0, coin(0.75, rnd(10000), -rnd(10000)))
              ],
              pan=0.0),
          f2=filter_(
              2,
              freq=r(coin(0.75, rnd(5000), rnd(20000))),
              track=r(pick([0, 0, 0, 1])),
              res=coin(0.75, rnd(0.5), rnd()),
              lfo=[coin(0.75, 0.0, rnd(5000)),
                   coin(0.75, 0.0, rnd(5000))],
              env=[
                  coin(0.25, 0, coin(0.75, rnd(10000), -rnd(10000))),
                  coin(0.25, 0, coin(0.75, rnd(10000), -rnd(10000)))
              ],
              pan=0.0))
    return p