GithubHelp home page GithubHelp logo

blatoo / pysynth Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cuu508/pysynth

0.0 2.0 0.0 31.13 MB

Several simple music synthesizers in Python 3. Input from ABC or MIDI files is also supported.

Home Page: http://mdoege.github.io/PySynth/

Python 100.00%

pysynth's Introduction

Overview

PySynth is a simple music synthesizer written in Python 3. The goal is not to produce many different sounds, but to have scripts that can turn ABC notation or MIDI files into a WAV file without too much tinkering.

The current release of the synthesizer can only play one note at a time. (Although successive notes can overlap in PySynth B and S, but not A.) However, two output files can be mixed together to get stereo sound.

The latest git version of PySynth also works in Python 2.

Synthesizer scripts

Synth Synthesis method Approximate timbre Note decay Needs NumPy?
A additive (3 sine waves) flute, organ, piano variable (depends on note length) no
B additive (5 sine waves) acoustic piano medium yes
C subtractive (sawtooth wave) bowed string, analog synth pad none no
D subtractive (square wave) woodwind, analog synth lead none no
E FM/phase modulation (6 sine waves) DX7 Rhodes piano medium yes
P subtractive (white noise) untuned percussion hit very fast no
S Karplus-Strong (physical modeling) plucked string, guitar, koto fast yes
beeper additive Nokia phone ringtone none no
samp sampler Salamander Grand Piano medium yes

Installation

Linux

Clone the repository:

git clone [email protected]:mdoege/PySynth.git

or

git clone https://github.com/mdoege/PySynth.git

Enter the directory (cd PySynth) and run

python3 setup.py install

Sample usage

Basic usage:

import pysynth as ps
test = (('c', 4), ('e', 4), ('g', 4),
		('c5', -2), ('e6', 8), ('d#6', 2))
ps.make_wav(test, fn = "test.wav")

More advanced usage:

import pysynth_b as psb # a, b, e, and s variants available

''' (note, duration)
Note name (a to g), then optionally a '#' for sharp or
'b' for flat, then optionally the octave (defaults to 4).
An asterisk at the end means to play the note a little 
louder.  Duration: 4 is a quarter note, -4 is a dotted 
quarter note, etc.'''
song = (
  ('c', 4), ('c*', 4), ('eb', 4), 
  ('g#', 4),  ('g*', 2), ('g5', 4),
  ('g5*', 4), ('r', 4), ('e5', 16),
  ('f5', 16),  ('e5', 16),  ('d5', 16),
  ('e5*', 4) 
)

# Beats per minute (bpm) is really quarters per minute here
psb.make_wav(song, fn = "danube.wav", leg_stac = .7, bpm = 180)

Read ABC file and output WAV:

python3 read_abc.py straw.abc

Documentation

More documentation and examples at the PySynth homepage.

pysynth's People

Contributors

jitanus avatar mdoege avatar nategeorge avatar pranavrc avatar tatsuyah avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.