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)
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)
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)
def additive_complex_sound_test(): 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) ]) freqs = [ midC(-3), midC(1), midC(-4), midC(4), midC(6), midC(2), midC(-1), midC(11) ] * 2 duration = 1e3 t = Signal.concat(*[s(f, duration) for f in freqs]) audio = t.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2) #play_Audio(audio) export_test(audio, additive_complex_sound_test)
def t1(): t = Triangle(frequency=midC(-1.5), duration=5000) * MovingAverage(21) * SineAM(frequency=0.8, size=0.3) 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**(-0.3 + 0.3 * (min(n, 0.3)) / 0.3) t += 0.01 * Sawtooth(frequency=midC(-1.5), duration=5000) * Amplitude(env) audio = t.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.01) play_Audio(audio)
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)
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)
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)
def solfege_test_1(): num_notes = 20 duration = 0.5e3 silence = 0.5e3 starting_note = 0 Note = Triangle notes = [Note(starting_note, duration) * Extend(silence)] for i in range(num_notes): starting_note += np.random.randint(-4, 5) notes.append(Note(midC(starting_note), duration) * Extend(silence)) s = Signal.concat(*notes) audio = s.mixdown(sample_rate=22050, byte_width=2, max_amplitude=0.2) play_Audio(audio, is_wait=False)