Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
0
def curve_continuity_test():
    c = Line(220, 330, 4e3) | Constant(330, 4e3)
    s = Sine(frequency=c, duration=8e3)

    c2 = Constant(220, 2e3) | Line(220, 330, 9e3) | Constant(330, 2e3)
    s = Sine(frequency=c2, duration=18e3)
    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 4
0
def lowpass_FIR_test():
    #s = WAV(african)[10e3:20e3]*LowPassBasic(cutoff=880, width=100)
    c = Line(55, 110, 3e3) | Constant(110, 2e3)
    c |= Line(110, 220, 3e3) | Constant(220, 2e3)
    c |= Line(220, 440, 3e3) | Constant(440, 2e3)
    c |= Line(440, 880, 3e3) | Constant(880, 2e3)
    s = Sine(frequency=c, duration=20e3)[0:2]
    s[1] *= LowPassBasic(cutoff=330, width=100)
    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
Esempio n. 5
0
def after_test_1():
    signal = Sine(frequency=midC(-7), duration=6e3)
    s2 = Signal.concat(
        *[Sine(frequency=midC(k - 4), duration=1e3) for k in range(6)])
    signal += s2

    print(signal)
    audio = signal.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio, is_wait=True)
Esempio n. 6
0
def after_test_2():
    # test ** as repeat
    s = Signal.concat(Sine(midC(-7 + 12), 1e3), Sine(midC(-3), 1e3),
                      Sine(midC(-8 + 12), 1e3), Sine(midC(-1), 1e3))
    s **= 5
    s += WAV(african)

    print(s)
    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio, is_wait=True)
Esempio n. 7
0
def envelope_test():
    env = lambda n: (n / 1000) if n < 1000 else (0.5 + np.sin(2 * np.pi * 2 * n
                                                              / 1000) / 2)
    env = lambda n: (0.5 + np.sin(2 * np.pi * 2 * n) / 2)
    env = lambda n: (0 if n == 0 else np.sin(n) * (min(n, 1)))
    env = lambda n: np.e**(-3 + 3 * (min(n, 3)) / 3)
    wav = Sine(duration=5000) * Amplitude(env)

    audio = wav.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.03)
    play_Audio(audio, is_wait=True)
Esempio n. 8
0
def Butterworth_test():
    #s = WAV(african)[10e3:20e3]
    c = Line(55, 110, 3e3) | Constant(110, 2e3)
    c |= Line(110, 220, 3e3) | Constant(220, 2e3)
    c |= Line(220, 440, 3e3) | Constant(440, 2e3)
    c |= Line(440, 880, 3e3) | Constant(880, 2e3)
    c |= Line(880, 2 * 880, 3e3) | Constant(2 * 880, 2e3)
    s = Sine(frequency=c, duration=20e3)[0:2]
    s[1] *= Butterworth(cutoff=880)
    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 9
0
def pan_test():
    seconds = 10
    t = Sine(frequency=230,
             duration=seconds * 1000)[0:2]  #*SineAM(frequency=1, size=0.2)

    top = seconds * 11025

    pans = (lambda x: np.log(1 + (np.e - 1) * (top - x) / top),
            lambda x: np.log(1 + (np.e - 1) * x / top))

    #t *= Pan(*pans) # not relevant for new Pan

    audio = t.mixdown(sample_rate=11025, byte_width=2)
    play_Audio(audio, is_wait=True)
Esempio n. 10
0
def test_gain_dB():
    s = Signal()

    for i in range(10):
        s |= Sine(duration=1e3) * Gain(-6 * i)

    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 11
0
def concat_overload_test():
    #s = Sine(frequency=250, duration=2e3) | Triangle(frequency=300, duration=3e3)
    s = WAV(african)

    s = s[5e3:5.5e3] | s[6e3:6.8e3] | s[11e3:13e3] * Reverse() + Sine(
        frequency=300, duration=2e3) | s[9e3:10.8e3]

    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 12
0
def melody_test():
    step = 500
    notes = (midC(0), midC(-3), midC(-7), midC(4), midC(7), midC(-1), midC(2))
    t = sum([
        Sine(frequency=f, duration=step + 100) *
        Fade(is_in=True, duration=step * 5) *
        Fade(is_in=False, duration=step + 100) * Shift(duration=(1 + i) * step)
        for (i, f) in enumerate(notes)
    ])
    audio = t.mixdown(sample_rate=11025, byte_width=2)
    play_Audio(audio)
Esempio n. 13
0
def after_test_3():
    b1 = 1.2e3
    b2 = 1e3
    b3 = 0.8e3
    b4 = 1.4e3

    p1 = [-6, -3, -8, -1, 1]
    p2 = [9, 4, 6, 8, 11]
    p3 = [12 + 1, 12 + 4, 12 + 6, 12 + 8, 12 + 1, 12 + 3, 12 + 11]
    p4 = [-12 + 2, -12 - 1, -12 + 1, -12 - 3]

    s = Signal.concat(*[Sine(midC(p), b1) for p in p1])**5
    s += 0.8 * Signal.concat(*[Sine(midC(p), b2) for p in p2])**6 * Shift(000)
    s += 0.3 * Signal.concat(*[Sine(midC(p), b3) for p in p3])**6
    s += 2 * Signal.concat(*[Sine(midC(p), b4) for p in p4])**5
    s *= MovingAverage(11)

    print(s)
    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio, is_wait=False)
Esempio n. 14
0
def simple_test(f=220, seconds=5):
    t = 0.7 * Sine(frequency=230, duration=seconds * 1000) * SineAM(
        frequency=1, size=0.2)[0:2]
    t[1] += Triangle(frequency=380, duration=seconds * 1000) * SineAM(
        frequency=0.4, size=0.3)
    t[0] += Square(frequency=300, duration=seconds * 1000) * SineAM(
        frequency=0.7, size=0.2)
    t *= Fade(is_in=True, duration=3 * 1000)
    #t *= Fade(is_in=False, duration=20)
    t *= Shift(duration=1 * 1000)
    play_Audio(t.mixdown())
Esempio n. 15
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)
Esempio n. 16
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)
Esempio n. 17
0
def SweepTest(stay=0.5e3, step=0.5e3):  # start at really low A
    start = 55
    octaves = 4
    c = Constant(start, stay)

    for octave in range(octaves):
        c |= Line(start, start * semitone**4, step) | Constant(
            start * semitone**4, stay)
        start *= semitone**4
        c |= Line(start, start * semitone**3, step) | Constant(
            start * semitone**3, stay)
        start *= semitone**3
        c |= Line(start, start * semitone**5, step) | Constant(
            start * semitone**5, stay)
        start *= semitone**5

    return Sine(frequency=c, duration=(step + stay) * 3 * octaves + stay)
Esempio n. 18
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)
Esempio n. 19
0
def channel_slice_test():
    # series of tests
    #s = WAV(african)[5e3:15e3]

    # t = s[0]
    # t = s[1,1e3:7e3]
    # t = s[1e3:7e3]

    #s[1] = 0.132*WhiteNoise(duration=10e3)#*Gain(-20)

    #s[0,3e3:7e3] = s[1,2e3:6e3]
    #s[0,1e3:6e3] += 0.13*Sine(frequency=midC(8))
    #s[0,1e3:5e3] *= Reverse()
    #s[1] = s[0]*Gain(-6)
    # etc...

    ##########
    s = 0.1 * Sine()
    s[1] = WAV(african)[0, 5e3:15e3]

    audio = s.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 20
0
 def s(f, duration):
     return sum([
         (1 / i**1.5) * Sine(frequency=f * i, duration=duration) * ADSR(
             (0.01e3) * (i), 0.8, 0.5 + (1 / (i + 2)), 0.02e3)
         for i in range(1, 20)
     ])
Esempio n. 21
0
def test_to_stereo_syntax():
    s = Sine()[0:2]  # automatically casts into stereo
    s[0] += 0.2 * Triangle(frequency=360)
    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 22
0
def pan_mono_test():
    c = Constant(-100, 2.5e3) | Line(-100, 100, 5e3)
    s = Sine(duration=10e3) * Pan(c)

    audio = s.mixdown(sample_rate=11025, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Esempio n. 23
0
def timing_test():
    t = 0.7 * Sine(frequency=230, duration=3 * 1000) * SineAM(frequency=1,
                                                              size=0.2)[0:2]
    t += Square(frequency=250, duration=3 * 1000) * Shift(duration=3 * 1000)
    audio = t.mixdown(sample_rate=11025, byte_width=2)
    play_Audio(audio, is_wait=True)