Skip to main content

Intuitive sound synthesis in python.

Project description

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 pynth 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)

https://user-images.githubusercontent.com/40042371/213463015-5cdd5f04-aa9d-4fe6-bfb3-5fa47394b6f1.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)

https://user-images.githubusercontent.com/40042371/213463075-75020d90-9f85-4ac3-9728-504b07fb9995.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))

https://user-images.githubusercontent.com/40042371/213463145-76281843-c404-4aa1-a73d-95d23d691cea.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))

https://user-images.githubusercontent.com/40042371/213463212-e894d9f7-7ee3-4b75-9c26-2594c877b96c.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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pynthlib-0.0.3.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynthlib-0.0.3-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file pynthlib-0.0.3.tar.gz.

File metadata

  • Download URL: pynthlib-0.0.3.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pynthlib-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3928b89bded4a2ed53e997e0c24ef47a9bcba4556ecbb441b81a6ce4be888ff4
MD5 26051aebe9a78f9a1a1557513197e15f
BLAKE2b-256 0090d84332e71714ae0f15dbd1810e3c46dae577830aa833565d7b939c8acd35

See more details on using hashes here.

File details

Details for the file pynthlib-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pynthlib-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for pynthlib-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bd9f01014f89ade1f15adc4319ca5e6fcd1d541286ff52baea52c7d04e170a9f
MD5 cce711a4df1cf3613f17d0c2eead20ad
BLAKE2b-256 d3a47071ae67d309e50018017125a09ce1ee14e5cdcc8b23ed8451d2b905aadb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page