Example #1
0
def common_main(script_name, files, argv):
    assert len(
        argv
    ) >= 2, "Usage: python {} folder [filename1] [filename2]...".format(
        script_name)
    folder = argv[1]
    if len(argv) == 3:
        filenames = argv[2:]
    else:
        filenames = None
    if not os.path.exists(folder):
        os.mkdir(folder)

    for name, value in files.items():
        if value.stream is not None and (filenames is None
                                         or name in filenames):
            print "Writing " + value.filename
            with open(os.path.join(folder, value.filename), 'wb') as f:
                audiogen.sampler.write_wav(
                    f, envelope(envelope(sound(), value.stream),
                                constant(0.01)))
            print "Done"
        else:
            print "Skipping " + value.filename

    return 0
def a30a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 90, 2),
            repeatlist(
                itertools.chain(repeatlist(linear(90, 40, 0.9), 4),
                                flat(90, 3)), 6)))
def a47a():
    return envelope(
        sound(),
        itertools.chain(
            repeatlist(itertools.chain(
                flat(100, 1),
                flat(0, 1),
            ), 15)))
def a44a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 90, 1),
            repeatlist(
                itertools.chain(repeatlist(linear(90, 40, 1), 4), flat(90, 4),
                                flat(0, 2)), 3)))
def a21a():
    return envelope(
        sound(),
        itertools.chain(
            repeatlist(
                itertools.chain(
                    sine_wave(0.5, 8, 80, 0),
                    flat(20, 2),
                ), 6), ))
def a23a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 80, 1),
            repeatlist(itertools.chain(
                flat(80, 0.5),
                flat(0, 0.5),
            ), 30)))
def a40a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 80, 1),
            repeatlist(itertools.chain(
                flat(80, 3),
                flat(0, 2),
            ), 6)))
def a7a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 65, 1.5),
            sine_wave(15.5, 1, 90, 40),
            dip(3, 65, 30),
            sine_wave(15.5, 1, 90, 40),
        ))
def a33a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 70, 1),
            repeatlist(
                itertools.chain(
                    sine_wave(4.25, .7, 90, 50),
                    flat(90, 3),
                ), 6)))
def a13a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 65, 1),
            repeatlist(
                itertools.chain(
                    sine_wave(5, 1, 90, 40),
                    sine_wave(7, .5, 90, 40),
                ), 6)))
def a2a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 45, 2),
            sine_wave(2.5, 3, 60, 30),
            dip(4, 45, 15),
            sine_wave(2.5, 3, 60, 30),
            dip(4, 45, 15),
        ))
def a16a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 70, 1),
            repeatlist(
                itertools.chain(
                    sine_wave(4, .7, 90, 50),
                    sine_wave(3, 1.5, 90, 50),
                ), 5)))
def a6a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 60, 2),
            repeatlist(
                itertools.chain(
                    sine_wave(4.5, 1, 80, 40),
                    dip(2, 60, 40),
                ), 7)))
def a41a():
    return envelope(
        sound(),
        itertools.chain.from_iterable([
            linear(0, 90, 1),
            repeatlist(itertools.chain(
                flat(90, 4),
                flat(0, 1),
            ), 6)
        ]))
def a3a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 45, 2),
            repeatlist(
                itertools.chain(
                    sine_wave(3.5, 1.5, 60, 30),
                    dip(3, 45, 15),
                ), 8)))
def a102a():
    return envelope(
        sound(),
        itertools.chain(
            repeatlist(
                itertools.chain(
                    repeatlist(itertools.chain(
                        flat(100, 0.8),
                        flat(0, 0.2),
                    ), 5), flat(100, 5)), 10)))
def a4a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 60, 2),
            repeatlist(
                itertools.chain(
                    sine_wave(3.5, 1.5, 80, 40),
                    dip(3, 60, 30),
                ), 5),
        ))
def a18a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 60, 1),
            repeatlist(
                itertools.chain(
                    sine_wave(4.75, .7, 90, 30),
                    flat(0, 5),
                ), 6),
        ))
def a27a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 50, 2),
            repeatlist(
                itertools.chain(
                    sine_wave(5.5, .7, 80, 20),
                    flat(0, 3),
                ), 7),
        ))
def a37a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 90, 3),
            repeatlist(
                itertools.chain(
                    flat(90, 3),
                    linear(90, 30, 2),
                    linear(30, 90, 2),
                ), 5)))
def a38a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 90, 3),
            repeatlist(
                itertools.chain(
                    flat(90, 4),
                    linear(90, 50, 1.5),
                    linear(50, 90, 1.5),
                ), 5)))
def a36a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 80, 3),
            repeatlist(
                itertools.chain(
                    flat(80, 2),
                    linear(80, 20, 2),
                    flat(20, 2),
                    linear(20, 80, 2),
                ), 5)))
def a101a():
    return envelope(
        sound(),
        itertools.chain(
            flat(0, 0.5),
            repeatlist(
                itertools.chain(
                    flat(100, 0.5),
                    flat(0, 0.3),
                    flat(100, 0.8),
                    flat(0, 0.3),
                ), 70)))
def a51a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 70, 1),
            repeatlist(
                itertools.chain(
                    sine_wave(4.5, 1, 100, 70),
                    linear(70, 0, 0.5),
                    flat(0, 3),
                    linear(0, 70, 0.5),
                ), 4)))
def a39a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 100, 3),
            repeatlist(
                itertools.chain(
                    flat(100, 3),
                    linear(100, 30, 2.5),
                    flat(30, 0.5),
                    linear(30, 100, 2.5),
                ), 5)))
def a9a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 65, 1),
            sine_wave(8.5, .8, 90, 40),
            flat(0, 3),
            sine_wave(8.5, .8, 90, 40),
            flat(0, 3),
            sine_wave(8.5, .8, 90, 40),
            flat(0, 3),
            sine_wave(8.5, .8, 90, 40),
            flat(0, 3),
            sine_wave(8.5, .8, 90, 40),
            flat(0, 3),
        ))
def a11a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 65, 1),
            sine_wave(6.25, .7, 90, 40),
            flat(90, 3),
            flat(0, 3),
            sine_wave(6.25, .7, 90, 40),
            flat(90, 3),
            flat(0, 3),
            sine_wave(6.25, .7, 90, 40),
            flat(90, 3),
            flat(0, 3),
            sine_wave(6.25, .7, 90, 40),
            flat(90, 3),
            flat(0, 3),
            sine_wave(6.25, .7, 90, 40),
            flat(90, 3),
            flat(0, 3),
        ))
def a12a():
    return envelope(
        sound(),
        itertools.chain(
            linear(0, 65, 1),
            sine_wave(6, .8, 90, 40),
            sine_wave(7, .5, 90, 40),
            flat(0, 2),
            sine_wave(6, .8, 90, 40),
            sine_wave(7, .5, 90, 40),
            flat(0, 2),
            sine_wave(6, .8, 90, 40),
            sine_wave(7, .5, 90, 40),
            flat(0, 2),
            sine_wave(6, .8, 90, 40),
            sine_wave(7, .5, 90, 40),
            flat(0, 2),
            sine_wave(6, .8, 90, 40),
            sine_wave(7, .5, 90, 40),
            flat(0, 2),
            sine_wave(6, .8, 90, 40),
            sine_wave(7, .5, 90, 40),
            flat(0, 2),
        ))
def a8a():
    return envelope(
        sound(), itertools.chain(linear(0, 65, 1), sine_wave(50, .9, 90, 40)))
def calibration():
    return envelope(sound(), itertools.chain(linear(0, 100, 10), flat(100,
                                                                      50)))