Skip to content

Latest commit

 

History

History
107 lines (77 loc) · 2.76 KB

README.md

File metadata and controls

107 lines (77 loc) · 2.76 KB

cover

Intuitive sound synthesis in python.

Installation

pip install pynthlib

Or directly from this repo:

git clone https://github.com/MatejBevec/pynth
pip install ./pynthlib

To visualize the computation graphs, you will also need to install Graphviz, which

Note that the graphviz library, used to visualize computation graphs, requires an installation of the Graphviz sofware. See https://pypi.org/project/graphviz/ for installation instructions.

Usage

Below are some usage examples. For more info, feel free to read DESCRIPTION.pdf and check out examples.py.

Please note that this project is in a prototype stage and is not optimized in terms of performance and reliability and is missing many planned features.

Overtones

from pynthlib import *

out = 0.5 * Sin(200)
for i in range(5):
  out += 0.1 * Sin(100*i)
  
drawgraph(out)
showsound(out, t2=0.1)
out.play(5*SR)

overtones.mp4

Vocal remover

sample, sr = librosa.load("file.wav", mono=False)
l = Wave(sample[0, :])
r = Wave(sample[1, :])
SR = sr

out = 0.5 * (0.5*l - 0.5*r)
out += 0.5 * MovingAvg(0.5*l + 0.5*r, M=50)

vocal-remover.mp4

Procedural wind

noise = WhiteNoise()
cutmod = Unipol(.5*Sin(1/3) + .5*Sin(1/5)) * 0.1
resmod = Unipol((.5*Sin(1) + .5*Sin(.8)) >> 0.3)
resmod = resmod * 0.4 + 0.1
out = Scope(Lowpass(noise, cutmod, resmod))

wind.mp4

Karplus-Strong string emulator

noise = Wave(np.random.rand(4000)-0.5)
delay = Delay(None, delay=0.005)
add = noise + delay
delay.ins["a"] = 0.95 * MovingAvg(add, M=10)
out = add

frozen = Wave(add.eval(2*SR))

karplus.mp4

User input, envelopes and scopes

import keyboard
control = Input()
env = Envelope(Scope(control), (2000, 0, 0, 8000))
out = Scope(env)
out = Scope(out * Saw(100))

val = 0
def loop(t):
  if keyboard.is_pressed(’l’):
    control.set(1)
  else:
    control.set(0)
    
out.play(30*SR, live=True, callback=loop)