Ejemplo n.º 1
0
def to_infinity_curve_test():
    c = Line(-80, -10, 10e3)
    p = Line(-100, 100, 5e3)
    #s = Sine(duration=20e3)*Gain(c)
    s = Sine(duration=10e3) * Pan(p)
    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, to_infinity_curve_test)
Ejemplo n.º 2
0
def test_implicit_add_channel():
    s = Sine()  #[0:2]
    #s[0] += 0.4*Triangle(duration=6e3) # exceeding signal bounds in time
    s[2] = 0.2 * Triangle()  # channels it into mono channel with empty R
    #print(s)
    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, test_implicit_add_channel)
Ejemplo n.º 3
0
def multichannel_test():
    s = Sine(frequency=midC(1))
    s[1] = Sine(frequency=midC(-3))
    s[2] = Sine(frequency=midC(-7))
    s[3] = Sine(frequency=midC(4))
    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, multichannel_test)
Ejemplo n.º 4
0
def slice_test():
    hihat = WAV(african)[:1061] * MovingAverage(5)
    hihat **= 30

    part = WAV(african)[5 * 1061:5 * 1061 + 3 * 1061]
    part **= 20
    s = WAV(african) + part * Shift(4 * 1061) * Gain(-6) - hihat
    #s = hihat
    audio = s.mixdown(sample_rate=32000, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, slice_test)
Ejemplo n.º 5
0
def pan_mono_test3():
    s = Sine(duration=2e3) * Pan(-100)
    s |= Sine(duration=2e3) * Pan(0)
    s |= Sine(duration=2e3) * Pan(100)

    c = Line(-100, 100, 5e3) | Logistic(100, -100, duration=5e3)
    s2 = Sine(duration=10e3) * Pan(c)

    Pan.panLaw = -6
    audio = s2.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, pan_mono_test3)
Ejemplo n.º 6
0
def reverse_phase_test():
    s = WAV(african)

    L = s[10e3:11e3] | -s[11e3:12e3] | s[12e3:13e3] | -s[13e3:14e3] | s[14e3:15e3] \
        | -s[15e3:16e3] | s[16e3:17e3]
    R = s[10e3:17e3]

    s = L * Repan(0, None) + R * Repan(None, 1)

    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, reverse_phase_test)
Ejemplo n.º 7
0
def test_ADSR():
    notes = [-3, -6, 1, 4, 3, -1, 1, 9, 8, 4, 6] * 2
    melody = Signal.concat(*[
        Square(frequency=midC(notes[i]), duration=0.5e3) * ADSR(attack=0.03e3,
                                                                decay=0.1e3,
                                                                sustain=0.8,
                                                                release=0.02e3,
                                                                hold=0.1e3)
        for i in range(len(notes))
    ])
    melody[1] = Signal.concat(*[
        Square(frequency=midC(notes[(i + 2) % (len(notes))]), duration=0.5e3) *
        ADSR(attack=0.03e3, decay=0.1e3, sustain=0.8, release=0.02e3, hold=0)
        for i in range(len(notes))
    ])
    melody *= MovingAverage(5)
    audio = melody.mixdown(sample_rate=24000, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, test_ADSR)
Ejemplo n.º 8
0
def pan_mono_test2():
    panMax = 100
    panMin = -100
    width = panMax - panMin
    eps = 0.001

    panLaw = -6  # -3 seems appropriate for headphones
    time = 8e3

    pan_shape = lambda x: np.log((x + panMax) /
                                 (width))  # +0.1 to prevent log(0)
    LdB = lambda x: (-panLaw / np.log(2)) * pan_shape(x)
    RdB = lambda x: LdB(-x)

    L = lambda t: LdB(width * t * 1000 / time + panMin)
    R = lambda t: RdB(width * t * 1000 / time + panMin)

    # =-===========
    s = Sine(duration=10e3)[0:2]
    s *= Gain(Curve(L, duration=time), Curve(R, duration=8e3))

    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    #play_Audio(audio)
    export_test(audio, pan_mono_test2)