Code Samples - Quefumas/gensound GitHub Wiki
Code sample collection
This is a growing collection of miscellaneous code snippets that were made for fun or for testing purposes, and could perhaps help new users (or just be fun play with). Some of them may be somewhat outdated though.
Detuned chord progression
from gensound import Sine, mix, Reverse, FadeIn, FadeOut
fades = FadeIn(0.01e3)*FadeOut(0.01e3)
step = 2e3
s = mix([Sine(f, step)*fades for f in ("G", "C5", "Eb5")])
s |= mix([Sine(f, step)*fades for f in ("A", "C5", "E5")])
s |= mix([Sine(f, step)*fades for f in ("Ab", "C5", "F5")])
s |= mix([Sine(f, step/3)*fades for f in ("G#", "C#5", "E5")])
s |= mix([Sine(f, step/3)*fades for f in ("G#-33", "C#5-33", "E5-33")])
s |= mix([Sine(f, step/3)*fades for f in ("G#-66", "C#5-66", "E5-66")])
s |= mix([Sine(f, step)*fades for f in ("G", "C5", "Eb5")])
s[1] = s*Reverse()
s.play()
3-voice Loop
from gensound import Square, Signal
sig = Square # try Sine, Triangle or Sawtooth too
t = 0.5e3 # beat duration
v1 = sig("C3 Eb F G F Eb "*10, duration=t)
v2 = sig("Eb4=3 Bb "*10, duration=t)
v3 = sig("G4=2 A D, "*10, duration=t)
s = Signal()
s[0] = v2
s[1] = v3
s += 0.5*v1
s.play()