Пример #1
0
def main():
    """main function"""

    # times is array of values at each time slot of the whole wav file
    times = wavelib.createtimes(TOTAL_DURATION)

    vals = wavelib.normalize(shepard_glissando(times, FREQ_A4 * 2, FREQ_A4))
    #plotlib.plot_wave_and_fft(times, vals)
    vals = wavelib.play_n(vals, 2)
    wavelib.write_wave_file('output/shepard_glissando_down_2x.wav', vals)

    vals = wavelib.normalize(shepard_discrete(times, FREQ_A4 * 2, FREQ_A4))
    #plotlib.plot_wave_and_fft(times, vals)
    vals = wavelib.play_n(vals, 2)
    wavelib.write_wave_file('output/shepard_discrete_down_2x.wav', vals)

    vals = wavelib.normalize(shepard_glissando(times, FREQ_A4, FREQ_A4 * 2))
    #plotlib.plot_wave_and_fft(times, vals)
    vals = wavelib.play_n(vals, 2)
    wavelib.write_wave_file('output/shepard_glissando_up_2x.wav', vals)

    vals = wavelib.normalize(shepard_discrete(times, FREQ_A4, FREQ_A4 * 2))
    #plotlib.plot_wave_and_fft(times, vals)
    vals = wavelib.play_n(vals, 2)
    wavelib.write_wave_file('output/shepard_discrete_up_2x.wav', vals)
def circle_fourths_discrete():
    # keep it within one octave, so we'll invert as needed
    notemin = NOTE
    notemax = NOTE * 2
    times = wavelib.createtimes(DURATION, SAMPLE_RATE)
    # use harmonic 7th for smoother beatless chord
    intervals = [
        wavelib.UNISON, wavelib.MAJOR_THIRD, wavelib.PERFECT_FIFTH,
        wavelib.HARMONIC_SEVENTH
    ]
    vals = wavelib.zero(times)
    for i in range(len(intervals)):
        interval = intervals[i]
        freq = wavelib.zero(times)
        for n in range(len(NOTES)):
            note = NOTES[n]
            f = NOTES[n] * interval
            while f >= notemax:
                f = f / 2.0
            while f < notemin:
                f = f * 2.0
            startidx = int(n * NOTE_DURATION * SAMPLE_RATE)
            endidx = int(((n + 1) * NOTE_DURATION) * SAMPLE_RATE)
            #print i, interval, note, f, startidx, endidx
            freq[startidx:endidx] = f
        #print n, note, freq
        vals += wavelib.sinewave(times, freq)

    vals = wavelib.normalize(vals)
    vals = wavelib.play_n(vals, 5)
    wavelib.write_wave_file('output/circle_fourths_chords.wav', vals)
Пример #3
0
def main():
    """main function"""
    # times is array of values at each time slot of the whole wav file
    times = wavelib.createtimes(DURATION)
    vals = wavelib.sinewave(times, wavelib.FREQ_A4)
    vals = wavelib.normalize(vals)
    wavelib.write_wave_file('output/sinewave1.wav', vals)
    # wavelib.plot_show(times, vals)
    # wavelib.fft_plot(times, vals)
    plotlib.plot_wave_and_fft(times, vals)
Пример #4
0
def main():
    """main function"""
    # x is array of values at each time slot of the whole wav file
    times = wavelib.createtimes(DURATION, SAMPLE_RATE)
    freq = wavelib.glissando_rate(times, FREQUENCY, FREQUENCY_RATE)
    vals1 = wavelib.sinewave(times, freq)
    vals2 = wavelib.sinewave(times, freq * 3 / 2)  # perfect fifth
    vals3 = wavelib.sinewave(times, freq * 5 / 4)  # perfect third
    vals = vals1 + vals2 + vals3
    vals = wavelib.normalize(vals)
    wavelib.write_wave_file('output/fallingtriad.wav', vals)
Пример #5
0
def main():
    """main function"""
    # x is array of values at each time slot of the whole wav file
    times1 = wavelib.createtimes(0.1, SAMPLE_RATE)
    times2 = wavelib.createtimes(0.9, SAMPLE_RATE)
    # constant frequency
    freq = FREQUENCY
    vals1 = wavelib.square(times1, freq)
    vals2 = wavelib.zero(times2)
    vals1 = wavelib.normalize(vals1)
    vals = np.concatenate((vals1, vals2))
    vals = wavelib.play_n(vals, 10)
    #wavelib.write_wave_file('output/alt_dry.wav', vals)
    # vals = wavelib.fx_reverb(vals)
    # vals = wavelib.normalize(vals)
    # wavelib.write_wave_file('output/alt_reverb.wav', vals)
    # print vals
    # vals = wavelib.comb_filter(vals)
    print vals
    vals = wavelib.normalize(vals)
    wavelib.write_wave_file('output/alt_comb.wav', vals)
Пример #6
0
def main():
    """main function"""
    # x is array of values at each time slot of the whole wav file
    times = wavelib.createtimes(DURATION, SAMPLE_RATE)
    # constant frequency
    freq = FREQUENCY
    vals = wavelib.triangle(times, freq)
    vals = wavelib.normalize(vals)
    wavelib.write_wave_file('output/triangle.wav', vals)

    # changing frequency
    freq = wavelib.glissando_rate(times, FREQUENCY, FREQUENCY_RATE)
    vals = wavelib.triangle(times, freq)
    vals = wavelib.normalize(vals)
    wavelib.write_wave_file('output/fallingtriangle.wav', vals)
Пример #7
0
def chord_scale_equal_temperament():
    times = wavelib.createtimes(DURATION, SAMPLE_RATE)
    intervals = [1, 3, 5, 7]
    vals = wavelib.zero(times)
    for interval in intervals:
        freq = wavelib.zero(times)
        for n in range(len(NOTES)):
            idx = (n + interval - 1) % len(NOTES)
            f = NOTES[idx]
            startidx = int(n * NOTE_DURATION * SAMPLE_RATE)
            endidx = int(((n + 1) * NOTE_DURATION) * SAMPLE_RATE)
            freq[startidx:endidx] = f
        vals += wavelib.sinewave(times, freq)

    vals = wavelib.normalize(vals)
    vals = wavelib.play_n(vals, 3)
    wavelib.write_wave_file('output/chord_scale_equal_temperament.wav', vals)
Пример #8
0
def chord_scale_just_intonation():
    times = wavelib.createtimes(DURATION, SAMPLE_RATE)
    intervals = [1, 3, 5, 7]
    vals = wavelib.zero(times)
    for interval in intervals:
        freq = wavelib.zero(times)
        for n in range(len(NOTES)):
            idx = (n + interval - 1) % len(NOTES)
            interval_ratio = JI_INTERVALS[idx]
            # always use intervals from the root note, so the harmonies are just
            f = NOTES[0] * interval_ratio
            startidx = int(n * NOTE_DURATION * SAMPLE_RATE)
            endidx = int(((n + 1) * NOTE_DURATION) * SAMPLE_RATE)
            freq[startidx:endidx] = f
        vals += wavelib.sinewave(times, freq)

    vals = wavelib.normalize(vals)
    vals = wavelib.play_n(vals, 3)
    wavelib.write_wave_file('output/chord_scale_just_intonation.wav', vals)
Пример #9
0
def main():
    """main function"""

    # times is array of values at each time slot of the whole wav file
    times = wavelib.createtimes(TOTAL_DURATION)

    freq = wavelib.glissando_lin(times, wavelib.FREQ_A4, wavelib.FREQ_A3)
    vals = wavelib.shepardtone(times, freq, tritone_sine, wavelib.FREQ_A3, 1, 1)
    vals = wavelib.normalize(vals)
    vals = wavelib.play_n(vals, 5)
    wavelib.write_wave_file('output/shepard_tritone_down_5x.wav', vals)

    freq = wavelib.glissando_lin(times, wavelib.FREQ_A3, wavelib.FREQ_A4)
    vals = wavelib.shepardtone(times, freq, tritone_sine, wavelib.FREQ_A3, 1, 1)
    vals = wavelib.normalize(vals)
    vals = wavelib.play_n(vals, 5)
    wavelib.write_wave_file('output/shepard_tritone_up_5x.wav', vals)

    # create a crescendo, fading in from 0 to full volume at the very end
    vals = wavelib.fade(vals)
    wavelib.write_wave_file('output/shepard_tritone_up_5x_crescendo.wav', vals)