Exemple #1
0
def fglitch(ns, audio):
    # periodically flatten/modulise out bits.
    density = inputs.askfunc(
        "Enter relative density for glitches (0.1-100), or 'd' for default: ",
        "glitch density", float, 0.1, 100, 10)
    maxlen = inputs.askfunc(
        "Enter max glitch length in seconds (0-2), or 'd' for default: ",
        "glitch maxlen", float, 0.1, 2.0, 0.5)
    i = random.randint(1000, 10000)
    while (i < (ns - 100000)):
        if (random.uniform(0, 1) < (0.01 * density)):
            ch = random.randint(0, 1)
            glen = int(44100 * random.uniform(0.001, maxlen))
            while (abs(audio[i, ch]) < 500):
                # cycle until find a non-quiet value or end of file
                i += 1
                if (i == ns):
                    return
            if (random.random() < 0.5):
                j = i + random.randint(0, 100)
                ch2 = 1 - ch
                flatten(audio, j, glen, ch2)
            flatten(audio, i, glen, ch)
            i += glen  # length of glitch
        i += random.randint(100, 10000)
    print("Finished flatten glitch\n")
    return
Exemple #2
0
def lofi(ns, audio):

    print(
        "Note, lo-fi may take over a minute for longer files, whole-file, and higher bitrates.... \n"
    )
    bitrate = 17 - inputs.askfunc("Enter bit rate, or 'd' for default: ",
                                  "bitrate", int, 3, 16, 8)
    modval = 2**bitrate
    choice = input(
        "Enter 'y' for whole-file lo-fi, any other key for partial lo-fi: \n")
    if choice == "y":
        whole_lofi(ns, audio, bitrate, modval)
    else:
        dscale = 44100 * inputs.askfunc(
            "Enter density scale in seconds, or 'd' for default: ",
            "density scale", int, 1, 100, 10)
        lscale = 44100 * inputs.askfunc(
            "Enter length scale in seconds, or 'd' for default: ",
            "length scale", int, 1, 100, 5)

        p1 = random.randint(0, dscale)
        while (p1 < (ns - lscale)):
            p2 = p1 + random.randint(0.6 * lscale, 1.4 * lscale)
            p2 -= p2 % bitrate  # make sure [p1, p2] interval is sound
            ch = random.randint(0, 1)
            if (random.random() < 0.5):
                # do 2nd channel, at similarish position
                p2 = p1 + random.randint(0, 10000)
                ch2 = 1 - ch
                part_lofi(ns, audio, bitrate, modval, p1, p2, ch2)
            part_lofi(ns, audio, bitrate, modval, p1, p2, ch)
            p1 += random.randint(0.8 * dscale, 2 * dscale)

    print("Finished lo-fi \n")
    return
Exemple #3
0
def reverse(ns, audio):
    # main reverse function

    lscale = 44100 * inputs.askfunc(
        "Enter length scale in seconds, or 'd' for default: ", "length scale",
        int, 1, 100, 2)
    dscale = 44100 * inputs.askfunc(
        "Enter density scale in seconds, or 'd' for default: ",
        "density scale", int, 1, 100, 5)
    cscale = inputs.askfunc(
        "Enter decimal probability of both channel reverse, or 'd' for default: ",
        "channel reverse", float, 0, 1, 0.4)

    p1 = random.randint(lscale, 4 * lscale)
    while (p1 < (ns - 4 * lscale)):  # bit clumsy
        ch = random.randint(0, 1)
        while (audio[p1, ch] != 0):
            p1 += 1
        p2 = p1 + random.randint(lscale, lscale * 4)
        while (audio[p2, ch] != 0):
            p2 += 1
        if (random.random() < cscale):
            # do 2nd channel, at similarish position
            p3 = p1 + random.randint(0, int(lscale / 50))
            p4 = p2 + random.randint(0, int(lscale / 50))
            ch2 = 1 - ch
            while (audio[p3, ch2] != 0):
                p3 += 1
            while (audio[p4, ch2] != 0):
                p4 += 1
            revseg(audio, p3, p4, ch2)
        revseg(audio, p1, p2, ch)
        p1 = p2 + random.randint(dscale, dscale * 3)

    print("Finished reversed \n")
    return
Exemple #4
0
def lpf(ns, audio):
    # y[i] = b * x[i] + (1-b)y[i-1]  0 < b < 1   y is filtered; x unfiltered. b=1 = filter freq = sample rate (i.e. no change)
    print("\n into lpf...")

    b = inputs.askfunc("Enter frequency (0-1), or 'd' for default: ",
                       "frequency", float, 0.0, 1.0, 0.1)

    # ask for degree of variablity? vary it gradually at random, also independent channel?

    audio[0, 0] = 0.0
    audio[0, 1] = 0.0
    for i in range(1, ns):
        audio[i, 0] = b * audio[i, 0] + (1 - b) * audio[i - 1, 0]
        audio[i, 1] = b * audio[i, 1] + (1 - b) * audio[i - 1, 1]

    return
Exemple #5
0
def stutter(ns, audio):
    #
    density = 44100 * inputs.askfunc(
        "Enter density scale in seconds, or 'd' for default: ",
        "density scale", int, 1, 100, 10)

    p1 = 20000 * random.randint(3, 12)

    while (p1 < (ns - 1.5 * density)):
        ch = random.randint(0, 1)
        if (random.random() < 0.5):
            # do 2nd channel, at similarish position
            p3 = p1 + random.randint(0, 10000)
            ch2 = 1 - ch
            stut(audio, p3, ch2)
        stut(audio, p1, ch)
        p1 += random.randint(density, density * 2)

    print("Finished stutter \n")
    return