Beispiel #1
0
def chorale_example():
    sig = Triangle  # Square?

    beat = 0.5e3  # 120 bpm
    fermata = 0.1  # make fermatas in the melody slightly longer
    pause = 0.6  # and breathe for a moment before starting the next phrase

    s = sig(
        f"r D5 D=2 C#=1 B-13=2 A=1 D E=2 F#-13={2+fermata} r={pause} F#=1 F#=2 F#=1 E=2 F#-13=1 G F#-13=2 E={2+fermata} r={pause} "
        f"D+16=1 E=2 F#-13=1 E=2 D+16=1 B-13 C#=2 D+9={2+fermata} r={pause} A'=1 F#-13=2 D+16=1 E=2 G=1 F#-13 E=2 D=3",
        beat)
    a = sig(
        f"r A4 B-16=2 A+16=1 G=2 F#-13=1 F# B-13 A A={2+fermata} r={pause} C#=1 B=2 B=1 B A A A D A A={2+fermata} r={pause} "
        f"B=1 A=2 A=1 B-13 A=0.5 G F#=1 B-13 B A#-13 B={2+fermata} r={pause} A=1 A=2 B=1 A=2 A=1 A B-13 A F#-13=3",
        beat)
    t = sig(
        f"r F#4-13 F#=2 F#=1 D=2 D=1 D D C#-13 D={2+fermata} r={pause} C#=1 D+16=2 D+16=1 D C#-13 D E A, D C#-13={2+fermata} r={pause} "
        f"F#=1 E=2 D=1 D C#-13 D+16 D G+5 F# F#={2+fermata} r={pause} E=1 F#-13=2 F#=1 E=2 C#-13=1 A B C#-13 D=3",
        beat)
    b = sig(
        f"r D3 B-16 D F# G B-13 D B-16 G A D,={2+fermata} r={pause} A#'-13=1 B=2 A=1 G#-13 A F#-13 C#-13 D F#-13 A={2+fermata} r={pause} "
        f"B=1 C#-13=2 D=1 G, A B G E F# B,={2+fermata} r={pause} C#'-13=1 D C# B C#-13 B A D G, A D,=3",
        beat)

    chorale = s * Pan(25) + b * Pan(-25) + t * Pan(80) + a * Pan(-80)

    from gensound.filters import MovingAverage
    chorale *= MovingAverage(5)  #*Reverse()
    #export_test(chorale.mixdown(44100), chorale_example)
    chorale.play()  # can you spot the parallel octaves?
Beispiel #2
0
def pan_stereo_test():
    s = WAV(african)[10e3:30e3]
    t = s[0] * Pan(Line(-100, 50, 20e3)) + s[1] * Pan(Line(0, 100, 20e3))

    # stereo signal panned in space from (-100,0) to (50,100)
    # the stereo field moves right gradually as well as expanding
    # from an opening of 90 degrees to 45 degrees (with headphones)
    Pan.panLaw = -3
    audio = t.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Beispiel #3
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)
Beispiel #4
0
def repan_reverb_test():
    # TODO these aren't relevant for new pan
    wav = sum([
        (1 - 8 / 10) * WAV(african) * Shift(duration=100 * x) *
        MovingAverage(2 * x + 1) * Pan(*(1, 0.3)[::(1 if x % 2 == 0 else -1)])
        for x in range(5)
    ])
    wav += 0.6 * WAV(african) * Pan(
        0, None) * Downsample(factor=5) * MovingAverage(5)
    wav += 0.6 * WAV(african) * Pan(None, 1)

    audio = wav.mixdown(sample_rate=44100, byte_width=2)
    play_Audio(audio, is_wait=True)
Beispiel #5
0
def Butterworth_experiment():
    s = WAV(african)[10e3:25e3]
    s1 = s[0] * Butterworth(cutoff=880)
    c = Line(-100, 100, 13e3)
    s2 = s[1] * Pan(c)
    t = s1[0:2] + s2
    audio = t.mixdown(sample_rate=44100, byte_width=2, max_amplitude=0.2)
    play_Audio(audio)
Beispiel #6
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)
Beispiel #7
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)