# Author: Martin McBride # Created: 2016-01-08 # Copyright (C) 2016, Martin McBride # License: MIT # Website sympl.org/pysound try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.wavetable import sine_wave from pysound.wavetable import square_wave from pysound.soundfile import write_wav # # Create a tremolo effect # amp = sine_wave(frequency=10, amplitude=0.1, offset = 0.8) wave = square_wave(frequency=400, amplitude=amp) write_wav(source=wave, filename='tremolo.wav')
from pysound.wavetable import saw_wave from pysound.soundfile import write_wav wave = saw_wave(frequency=400, amplitude=1) write_wav(source=wave, filename='saw-wave.wav')
# Created: 2016-06-12 # Copyright (C) 2016, Martin McBride # License: MIT # Website sympl.org/pysound try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.sequencers import sample_and_hold from pysound.wavetable import sine_wave from pysound.wavetable import square_wave from pysound.soundfile import write_wav # # use sample and hold to vary frequency # params = {'duration': 10} lfo = sine_wave(frequency=7, offset=500, amplitude=100, **params) trigger = square_wave(frequency=2.596, **params) freq = sample_and_hold(source=lfo, trigger=trigger, **params) out = sine_wave(frequency=freq, **params) write_wav(source=out, filename='sample-hold.wav')
# Author: Martin McBride # Created: 2016-01-08 # Copyright (C) 2016, Martin McBride # License: MIT # Website sympl.org/pysound try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.wavetable import square_wave from pysound.soundfile import write_wav # # Create a simple square wave # wave = square_wave(frequency=400) write_wav(source=wave, filename='square-wave.wav')
from pysound.wavetable import sine_wave from pysound.envelopes import attack_decay from pysound.music import Notes from pysound.soundfile import write_wav # # Simple instrument # def instrument(freq): wave = sine_wave(frequency=freq, duration=0.5, amplitude=0.5); return wave; # # Create a sequence # seq = [ (instrument(Notes.C4), 0), (instrument(Notes.D4), 0.5), (instrument(Notes.E4), 1.0), (instrument(Notes.F4), 1.5), (instrument(Notes.G4), 2.0), (instrument(Notes.A4), 2.5), (instrument(Notes.B4), 3.0), (instrument(Notes.C5), 3.5), ] wave = sequencer(inputs=seq) write_wav(source=wave, filename='scale.wav')
# Author: Martin McBride # Created: 2016-06-12 # Copyright (C) 2016, Martin McBride # License: MIT # Website sympl.org/pysound try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.soundfile import write_wav from pysound.wavetable import saw_wave from pysound.envelopes import attack_decay # # Create an attack/decay envelope # wave = saw_wave(frequency=400) out = attack_decay(duration = 0.3, attack_time= 0.01, source=wave) write_wav(source=out, filename='attack-decay.wav')
from pysound.mixers import adder from pysound.music import Notes from pysound.soundfile import write_wav # # Simple instrument # def instrument(freq1, freq2, freq3): wave = adder(sources=[ sine_wave(frequency=freq1, duration=2, amplitude=0.3), sine_wave(frequency=freq2, duration=2, amplitude=0.3), sine_wave(frequency=freq3, duration=2, amplitude=0.3), ], duration=2) return wave; # # Create a sequence # seq = [ (instrument(Notes.C4, Notes.E4, Notes.G4), 0), (instrument(Notes.A3, Notes.C4, Notes.E4), 2), (instrument(Notes.F3, Notes.A3, Notes.C4), 4), (instrument(Notes.D4, Notes.F4, Notes.A4), 6), ] wave = sequencer(inputs=seq) write_wav(source=wave, filename='chords.wav')
# Author: Martin McBride # Created: 2016-01-08 # Copyright (C) 2016, Martin McBride # License: MIT # Website sympl.org/pysound try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.soundfile import write_wav from pysound.wavetable import sine_wave from pysound.mixers import modulator # # Mix the signals # wave1 = sine_wave(frequency=400) wave2 = sine_wave(frequency=10) wave = modulator(sources=[wave1, wave2]) write_wav(source=wave, filename='modulator.wav')
# Author: Martin McBride # Created: 2016-06-12 # Copyright (C) 2016, Martin McBride # License: MIT # Website sympl.org/pysound try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.soundfile import write_wav from pysound.wavetable import sine_wave from pysound.envelopes import ramp from pysound.music import Notes # # Create a ramp envelope and a ramp frequency # freq = ramp(start=Notes.A4, end=Notes.A3) wave = sine_wave(frequency=freq) out = ramp(source=wave) write_wav(source=out, filename='ramp.wav')
try: import pysound except ImportError: # if pysound is not installed append parent dir of __file__ to sys.path import sys, os sys.path.insert(0, os.path.abspath(os.path.split(os.path.abspath(__file__))[0]+'/..')) from pysound.sequencers import sequencer from pysound.wavetable import square_wave from pysound.music import Notes from pysound.soundfile import write_wav # # Create a sequence # w1 = square_wave(frequency=Notes.A4, duration=1, amplitude=0.5) w2 = square_wave(frequency=Notes.C4, duration=1, amplitude=0.5) w3 = square_wave(frequency=Notes.E4, duration=1, amplitude=0.5) seq = [ (w1, 0), (w2, 1), (w3, 1.5), (w1, 2) ] wave = sequencer(inputs=seq) write_wav(source=wave, filename='sequencer.wav')