Example #1
0
def melody(space):
    return sp.scale_normalize(
        sp.reverb(sp.saw(song, melody_pattern(song, steps=7, reps=25)), 1. /
                  60., 5) -
        sp.reverb(sp.saw(song, melody_pattern(song, 0.5, 2, 15, 7)), 1. /
                  55., 5)) * sp.square(space + sp.sin(space, 1. / 40.) * 40,
                                       40)
Example #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)
Example #3
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')
Example #4
0
def rpeak(space):
    dur = len(space) / sp.SAMPLE_RATE
    return sp.saw(space, dur / 20., np.pi / 4.) * sp.gate(
        space, dur / 20. * 19.)
Example #5
0
def closing_scream(space):
    return sp.saw(space, 990 - sp.sin(space, 3)) - sp.saw(
        space / 5. * sp.sin(space, 0.1), 890) - sp.saw(space, 650)
Example #6
0
def drum_line(space):
    return (
        sp.saw(space + sp.noise(space) * 0.004 + sp.saw(space, 12) * 5., 40) *
        sp.gated_pulse(space, 4, 0.25) * sp.sin(space, 4) +
        sp.gated_pulse(space, 4, 0.125, np.pi * 0.1))