Пример #1
0
def whispers(space):
    return sp.scale_normalize(
        sp.noise(space) * 0.03 - sp.sin(
            space + sp.noise(space) * 0.0001,
            sp.arp(space,
                   np.array([98, 99, 98, 99, 97, 98, 99, 97, 96, 99] * 10)) *
            5.) * 0.45 * sp.pulse(sp.sin(space, 0.01) * 50, 120, 0.25) * 0.02)
Пример #2
0
    sp.sin(space, 2) * 220
)  #because of broadcasting, you can use waves to control the frequency of other waves
deriv = sp.sin(sp.sin(space, 2) * 2 * np.pi,
               sp.sin(space, 20) * 3)  #the sin of a sin
square = sp.square(space, 440)  #square wave
modulated_square = sp.square(space, 440) * sp.sin(space, 440) - sp.square(
    space, 443, 0.5)  #combining waves
beating = (sp.sin(space, 440) + sp.sin(space, 110)) * sp.square(
    space, 90000) * sp.square(space, 1.50) * sp.sin(space, 3) * sp.square(
        space, 11) * sp.sin(space, 0.5)
wamp = np.clip((sp.sin(space, 200) - sp.square(space, 101) * 0.25) *
               (sp.sin(space, 1.74) +
                sp.sin(space,
                       sp.sin(space, 200) * 3 + 220 - sp.sin(space, 30)) +
                sp.sin(space, 12) * 0.25), -1., 1.)
arp = sp.saw(space, sp.arp(space, [60, 70, 80, 90, 120, 90, 80, 70, 60
                                   ])) * sp.sin(space, 1.7) * sp.sin(space, 3)
ripple = np.fmod(sp.saw(space, sp.arp(space, [220, 240, 275, 220, 170] * 5)),
                 sp.saw(space, 0.3333)) * sp.saw(space, 0.7, shift=np.pi / 2.)
purr = sp.reverb(np.fmod(sp.saw(space, 1),
                         sp.sin(space, 12) * 2.), 0.125, 5, 0.75)
snare = sp.noise(space) * (sp.gated_pulse(space, 3, 0.15) + sp.gated_pulse(
    space, 4, 0.15, -np.pi)) * sp.sin(space, 220) * sp.sin(
        space, 2)  #use pulses to create rhythmic patterns
full_demo = np.concatenate(
    (concertA, modulatedA, buzz, div, complex_beat, fmod, deriv, square,
     modulated_square, beating, wamp, arp, ripple, purr, snare))

if len(sys.argv) == 1 or sys.argv[1] == 'play':
    play(concertA)
    play(modulatedA)
    play(square)
Пример #3
0
 def test_arp(self):
     space = np.linspace(0, 10)
     arped = sp.arp(space, [1, 2, 3])
     self.assertEqual(arped[0], 1.)
     self.assertEqual(arped[17], 2.)
Пример #4
0
import shaded as sd
from sounddevice import play
import soundfile as sf
import numpy as np
song = sd.space(13)
overall_env = sd.smoothstep(0, 1, song) - sd.smoothstep(12, 14.8, song)

bass_line = sd.arp(song, [110, 130.81, 146.83, 110] *
                   5)  #this time, the "*" means we're repeating
bass_line_wave = sd.smooth_normalize(
    sd.sin(song, bass_line) * sd.pulse(song, 3, 0.333, normalize=False))

drums = sd.noise(song) * sd.sigmoid(song, 10) * sd.sigmoid(
    song, 12, 0.25 * 2 * np.pi) * 0.2

melody_a = sd.arp(song, [440, 880, 440, 220])
melody_b = sd.arp(song, [523.25, 392.00, 659.25] * 6)
string = sd.saw(song, melody_a) * 0.25 + sd.saw(song, melody_b) * 0.25

full_song = bass_line_wave * sd.smoothstep(
    2, 3, song) + drums * 0.25 + string * 0.5 * (sd.smoothstep(4, 6, song) -
                                                 sd.smoothstep(8, 10, song))

sf.write('working/demo.wav', full_song, int(44100), 'FLOAT')
Пример #5
0
def whisper_slide(space):
    return (sp.sin(space, 0.01) * sp.sin(space, 0.02) * sp.sin(
        space,
        sp.arp(space,
               [0.125, 0.5, 0.9, 3., 3.2, 0.125, 0.52, 0.4, 3., 9, 0.125])))
Пример #6
0
def melody_pattern(space, base=220, low=0.2, high=4., steps=5, reps=3):
    mults = np.linspace(low, high, steps) * base
    np.random.shuffle(mults)
    return sp.arp(space, np.repeat(mults, reps))
Пример #7
0
def bass_enter_exit(space, reps=3):
    return sp.arp(space, [
        1, 1, 1, 1.25, 0.75, 0.25, 0.25, 0.125, 0.125, 0, 0, 0, 0.5, 0.5, 0.5,
        0.25, 0.25, 1, 1, 1
    ] * reps)
Пример #8
0
def bass_prog(space, reps=3):
    prog = sp.arp(space, [60, 65, 80, 85, 60, 65, 80, 83, 70, 72] * reps)
    return sp.pulse(space, prog, 0.45)