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

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.2.tar.gz (13.5 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.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pynthlib-0.0.2.tar.gz
  • Upload date:
  • Size: 13.5 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.2.tar.gz
Algorithm Hash digest
SHA256 76c58000623aafcff99199c62700122215a52073d8a2617f4ea2c73e9528319f
MD5 2bb29ec502414b177bcbea3ca0abde44
BLAKE2b-256 938e0b3beadc3902f63fd82b0631cfa67e100e78f3ac57ebadbf6951c81555ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pynthlib-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3415359e5123ccc3b933867aeccf8430a955d59bfbc6c3a66a24ffe1d7197412
MD5 84a9c8f63d4607528ccdbc7fcad4f35d
BLAKE2b-256 6ea9a976c8be05ff8436bccfffc961aa995951a1006f7f09a7d3452d13ec0d02

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