Permalink
Browse files

Run examples from anywhere, updates to Makefile

  • Loading branch information...
hecanjog committed May 12, 2018
1 parent d2b1c3f commit 62c0c8dae15c1968166985a8200a9d012383e22a
View
@@ -1,3 +1,5 @@
.PHONY: test examples build
test:
python -m unittest discover -s tests -p 'test_*.py' -v
@@ -6,5 +8,11 @@ clean:
rm -rf pippi/*.c
rm -rf pippi/*.so
examples:
ls examples/*.py | xargs -n 1 -P `nproc --all` python
mix: examples
sox examples/*.wav example_mix.wav
build:
python setup.py develop
View
@@ -1,6 +1,6 @@
# Pippi: Computer music with python
v2.0.0 - Beta 1
v2.0.0 - Beta 2 (In Development)
## Installation and setup
@@ -70,11 +70,22 @@ Please let me know if you run into problems!
## Run the multi snare bounce example
cd examples
python multi_snare_bounce.py
python examples/multi_snare_bounce.py
Which will produce a WAV file named `multi_snare_bounce_example.wav` in the examples directory.
## Run every example
make examples
Which will run every example, creating files in the examples directory.
## Make an examples mix
make mix
Render every example and stitch them into a single audio file with `sox`.
## Now what?
There are more examples, give em a whirl, and try your own.
@@ -86,6 +97,12 @@ There are more examples, give em a whirl, and try your own.
## Release Notes
### 2.0.0 - Beta 2 (In Development)
#### Bugfixes
- Examples can be run from anywhere
### 2.0.0 - Beta 1
#### Features
View
@@ -1,13 +1,16 @@
import random
from pippi import dsp, graph
import os
PATH = os.path.dirname(os.path.realpath(__file__))
buflength = 5
out = dsp.buffer(length=buflength)
sounds = [
dsp.read('sounds/snare.wav'),
dsp.read('sounds/boing.wav'),
dsp.read('sounds/hat.wav'),
dsp.read('%s/sounds/snare.wav' % PATH),
dsp.read('%s/sounds/boing.wav' % PATH),
dsp.read('%s/sounds/hat.wav' % PATH),
]
numsounds = random.randint(3, 5)
@@ -22,4 +25,4 @@
out.dub(sound, start)
graph.waveform(out, 'draw_waveform_example.png', width=600, height=300)
graph.waveform(out, '%s/draw_waveform_example.png' % PATH, width=600, height=300)
View
@@ -1,7 +1,9 @@
from pippi import dsp, fx, graph
import os
snd = dsp.read('examples/sounds/harpc2.wav')
snd = snd.cut(0.4, 0.5)
PATH = os.path.dirname(os.path.realpath(__file__))
snd = dsp.read('%s/sounds/harpc2.wav' % PATH)
snd = fx.go(snd,
factor=200,
minclip=0.125,
@@ -11,5 +13,5 @@
maxlength=0.04
)
snd.write('fxgo.wav')
graph.waveform(snd, 'bit-fxgo.png')
snd.write('%s/fxgo.wav' % PATH)
graph.waveform(snd, '%s/fxgo.png' % PATH)
@@ -1,11 +1,14 @@
from pippi import dsp, rhythm
import random
import os
PATH = os.path.dirname(os.path.realpath(__file__))
# Create an empty buffer to dub sounds into
out = dsp.buffer()
# Load a snare drum sample from the `sounds` directory
snare = dsp.read('sounds/snare.wav')
snare = dsp.read('%s/sounds/snare.wav' % PATH)
# Make a random number of passes dubbing into the
# output buffer. On each pass...
@@ -56,4 +59,4 @@
out.dub(hit, pos)
# Write the sound to disk
out.write('multi_snare_bounce_example.wav')
out.write('%s/multi_snare_bounce_example.wav' % PATH)
@@ -1,10 +1,12 @@
import random
import time
from pippi import dsp, oscs, tune, wavetables
import os
PATH = os.path.dirname(os.path.realpath(__file__))
start_time = time.time()
tlength = 200
tlength = 20
out = dsp.buffer(length=tlength)
pos = 0
count = 0
@@ -101,7 +103,6 @@ def get_freqs(count):
reps = random.choice([1,2,3,4,8])
dist = random.choice(blens) / reps
print('Swell %s, pos %s, reps %s, length %s' % (count, pos, reps, length))
for _ in range(reps):
freq = freqs[(count2 // random.randint(1,3)) % len(freqs)] * 2**random.randint(0, 3)
amp = random.triangular(0.05, 0.15)
@@ -113,7 +114,7 @@ def get_freqs(count):
count += 1
out.write('osc2d_out.wav')
out.write('%s/osc2d_out.wav' % PATH)
elapsed_time = time.time() - start_time
print('Render time: %s seconds' % round(elapsed_time, 2))
View
@@ -1,7 +1,9 @@
import random
import time
from pippi import dsp, oscs, tune
import os
PATH = os.path.dirname(os.path.realpath(__file__))
start_time = time.time()
out = dsp.buffer(length=40)
@@ -34,7 +36,7 @@
out.dub(note, pos)
out.write('pulsar_synth.wav')
out.write('%s/pulsar_synth.wav' % PATH)
elapsed_time = time.time() - start_time
print('Render time: %s seconds' % round(elapsed_time, 2))
print('Output length: %s seconds' % out.dur)
@@ -1,9 +1,12 @@
import random
import time
from pippi import dsp, sampler, tune, rhythm
import os
PATH = os.path.dirname(os.path.realpath(__file__))
start_time = time.time()
samp = sampler.Sampler('sounds/harpc2.wav', 'c2')
samp = sampler.Sampler('%s/sounds/harpc2.wav' % PATH, 'c2')
out = dsp.buffer(length=32)
chords = ['iii', 'vi', 'ii', 'V']
@@ -32,7 +35,7 @@ def arp(i):
pos += 1
out.write('sampler_example.wav')
out.write('%s/sampler_example.wav' % PATH)
elapsed_time = time.time() - start_time
print('Render time: %s seconds' % round(elapsed_time, 2))
print('Output length: %s seconds' % round(len(out)/44100, 2))
@@ -1,5 +1,8 @@
import random
from pippi import dsp, oscs
import os
PATH = os.path.dirname(os.path.realpath(__file__))
# Create a list of random values, padded
# with zeros on either end to use as the
@@ -13,4 +16,4 @@
out = osc.play(3)
# Write the audio to a soundfile
out.write('simple_custom_wavetable.wav')
out.write('%s/simple_custom_wavetable.wav' % PATH)
@@ -1,12 +1,14 @@
import time
from pippi import dsp
import os
PATH = os.path.dirname(os.path.realpath(__file__))
start_time = time.time()
# Load some boinging into a SoundBuffer. Or:
# from pippi.soundbuffer import SoundBuffer
# snd = SoundBuffer(filename='sounds/boing.wav')
snd = dsp.read('sounds/boing.wav')
snd = dsp.read('%s/sounds/boing.wav' % PATH)
# Returns an empty SoundBuffer instance that
# we can dub our grains into. Or:
@@ -39,7 +41,7 @@
recordhead += i * 0.01 + 0.01
# Write the output buffer to a WAV file
out.write('simple_grains.wav')
out.write('%s/simple_grains.wav' % PATH)
elapsed_time = time.time() - start_time
print('Render time: %s seconds' % round(elapsed_time, 2))
print('Output length: %s seconds' % round(out.dur, 2))
View
@@ -2,6 +2,9 @@
from pippi import dsp
from pippi.oscs import Osc
import os
PATH = os.path.dirname(os.path.realpath(__file__))
# Create a wavetable osc with a randomly
# selected waveform type
@@ -14,4 +17,4 @@
out = osc.play(length) * 0.5
# Write the output buffer to a WAV file
out.write('simple_osc.wav')
out.write('%s/simple_osc.wav' % PATH)
@@ -1,13 +1,16 @@
from pippi import dsp, rhythm
import random
import os
PATH = os.path.dirname(os.path.realpath(__file__))
out = dsp.buffer()
snare = dsp.read('sounds/snare.wav')
snare = dsp.read('%s/sounds/snare.wav' % PATH)
pattern = rhythm.curve(numbeats=64, wintype=dsp.SINE, length=44100 * 4)
for onset in pattern:
out.dub(snare * random.random(), onset/out.samplerate)
out.write('simple_snare_bounce.wav')
out.write('%s/simple_snare_bounce.wav' % PATH)
@@ -1,7 +1,10 @@
from pippi import dsp, grains, interpolation
import random
import os
snd = dsp.read('sounds/linus.wav')
PATH = os.path.dirname(os.path.realpath(__file__))
snd = dsp.read('%s/sounds/linus.wav' % PATH)
def makecloud(density):
return grains.GrainCloud(snd * 0.125,
@@ -27,4 +30,4 @@ def makecloud(density):
for cloud in clouds:
out.dub(cloud)
out.write('swarmy_graincloud.wav')
out.write('%s/swarmy_graincloud.wav' % PATH)
View
@@ -1,7 +1,9 @@
import random
import time
from pippi import dsp, oscs, tune
import os
PATH = os.path.dirname(os.path.realpath(__file__))
start_time = time.time()
def make_wavetable():
@@ -36,7 +38,7 @@ def make_wavetable():
dubhead += chordlength - (chordlength * 0.1)
out.write('synth_chords.wav')
out.write('%s/synth_chords.wav' % PATH)
elapsed_time = time.time() - start_time
print('Render time: %s seconds' % round(elapsed_time, 2))
print('Output length: %s seconds' % round(out.dur, 2))
Oops, something went wrong.

0 comments on commit 62c0c8d

Please sign in to comment.