• This repository has been archived on 11/Dec/2021
  • Stars
    star
    182
  • Rank 211,154 (Top 5 %)
  • Language
    Python
  • License
    GNU Lesser Genera...
  • Created almost 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

python sample mixer and sequencer, waveform synthesizer, and sound playback engine

Latest Version

Software sound synthesizer (FM/PWM oscillators), sound file streaming and conversion, and sound playback and mixing engine.

This software has been created by Irmen de Jong ([email protected]), and is distributed under the LGPL 3.0 software license (see 'LICENSE').

Pypi: synthplayer

requires Python 3.6 or newer.

PROJECT IS ARCHIVED - NO BUG FIXES OR IMPROVEMENTS WILL BE MADE

synthplayer.synth

A waveform synthesizer that can generate different wave form samples: sine, triangle, sawtooth, square, pulse wave, harmonics and white noise. It also supports Frequency Modulation, Pulse-width modulation, and ADSR envelopes using LFOs.

For efficiency reasons, the oscillators and filters return their waveform values in small chunks/lists instead of per individual value. When running the synthesizer with pypy the speedup is remarkable over the older version (that used single value generators).

Synth Waveforms overview

Synth GUI screenshot

synthplayer.playback

Sound playback engine. Supports multiple sound APIs, efficient sequential streaming or real-time mixing of shorter sound clips. The streaming is implemented via Python generators where the main generator essentially produces mixed sample fragments. These are written to an audio stream of one of the supported audio libraries. Synthplayer will detect them in this order:

No errors, but hearing no sound?

If you see no errors but hear nothing, you may need to manually configure the correct output audio device. On some systems, the portaudio system audio library seems to report a wrong default output audio device. In this case, you may get an IOError (describing the problem). You can also get another error (or no sound output at all, without any errors at all...) If this happens, you can manually configure the output audio device that should be used:

Either set the PY_SYNTHPLAYER_AUDIO_DEVICE environment variable to the correct device number, or set the synthplayer.playback.default_audio_device parameter at the start of your code. (The environment variable has priority over the code parameter)

To find the correct device number you can use the query_devices method or type python -m sounddevice.

synthplayer.sample

Contains the Sample class that represents a digitized sound clip. It provides a set of simple sound manipulation methods such as changing the amplitude, fading in/out, and format conversions.

synthplayer.streaming

Provides various classes to stream audio data with. Uses ffmpeg or oggdec to read/stream many different sound formats.

Example program: jukebox.box

This is a jukebox like party sound player that allows to prepare a playlist, fade from a track to the next from the list, and insert random soundbytes for added fun. The songs are queried from a backend audio file database server program.

Example program: trackmixer

You assemble rhythm samples into bars and patterns, which are then mixed. Samples have to be in .wav format but can be anything that the Python wave module understands. The 'track' files are in a simple .ini format and can be edited with any text editor. Most of the file should be self explanatory but here are a few tips:

  • Song bpm means beats per minute, which translates in how many bars are played per minute. If you put one kick/bass drum trigger in one bar, it exactly hits the specified number of beats per minute.
  • Song ticks means how many ticks (or triggers) are in one bar. More ticks means more resolution. Nice for fast hi-hats.
  • A bar is a sequence of instrument ticks (or triggers) where '.' means nothing is played at that instant, and another character such as 'x' means that the sample is played at that instant.
  • you can separate bars with whitespace for easier readability
  • pattern names are prefixed with pattern. when writing their section (ini file limitation, you can't nest things)
  • patterns can contain one or more bars per instrument (so you can have long and short patterns). However inside a pattern every instrument has to have the same number of bars.

Here is a very simple example of a track file:

[paths]
# where to find the sample files
samples = samples/

[samples]
# list your samples here
kick7 = biab_kick_7.wav
snare2 = biab_sn_2.wav
snare10 = biab_sn_10.wav
hihat2 = biab_hat_2.wav
hihat4 = biab_hat_4.wav

[song]
# basic song parameters and pattern sequence
bpm = 128
ticks = 4
patterns = pat1 pat2 pat1 pat2 outro

[pattern.pat1]
hihat2     = x.x. x.x. x.x. x.x.
snare2     = .... x... .... x...
kick7      = x... x... x... x...

[pattern.pat2]
hihat4     = x.x. x.x. x.x. x.x.
snare10    = .... .... x... x...

[pattern.outro]
hihat2     = x.x. x.x. 
hihat4     = .... x...
kick7      = .... x...

invoking the mixer

To simply mix and stream your track file to your speakers use the following command:

python trackmixer.py mytrack.ini

To load your track file and start the interactive command line interface:

python trackmixer.py -i mytrack.ini

...then type help to see what commands are available.

A few example tracks are provided, try them out! (pre-mixed output can be found in the example_mixes folder)

  • track1.ini - a short jungle-ish fragment
  • track2.ini - a somewhat longer classic rhythm loop, I guess it's in 4/4 time
  • track3.ini - an experiment with a few liquid drum'n'bass type patterns

More Repositories

1

Pyro4

Pyro 4.x - Python remote objects
Python
715
star
2

Pyro5

Pyro 5 - Python remote objects
Python
302
star
3

Pyrolite

Java and .NET client interface for Pyro5 protocol
Java
177
star
4

pyminiaudio

python interface to the miniaudio audio playback, recording, decoding and conversion library
C
159
star
5

Tale

Interactive fiction (text adventure) and Mud framework
Python
142
star
6

prog8

high level programming language and compiler targeting 6502 machines such as the C-64 and CommanderX16
Kotlin
142
star
7

pyc64

Commodore-64 simulator in pure Python
Python
80
star
8

pickle

Java and .NET implementation of Python's pickle serialization protocol
C#
76
star
9

Serpent

serializer for literal Python expressions, also .NET and Java
Java
49
star
10

bouldercaves

Boulder Caves - a Boulder Dash (tm) clone in pure python (including level editor)
Python
34
star
11

64tass

64tass - cross assembler for 6502 etc. microprocessors - by soci/singular - [git clone from the original sourceforge repo]
C
30
star
12

cx16shell

Command line shell for the Commander X16
Lua
12
star
13

binaryen-interfaces

non-C programming language interfaces to the Binaryen library
Kotlin
11
star
14

cx16assem

File-based 65c02 assembler for Commander-X16
Lua
9
star
15

ksim65

Kotlin 6502/65C02 microprocessor simulator
Assembly
8
star
16

raycaster

Ray caster engine in Python and Kotlin/JVM
Kotlin
7
star
17

pylibxmplite

Python library that provides libxmp-lite mod file decoding
C
6
star
18

rocketsimulator

python rocket landing simulation game just using tkinter
Python
5
star
19

Pyro3

Pyro 3.x (old version - unmaintained - use Pyro4 instead)
Python
4
star
20

cx16imageviewer

multi file format (iff, pcx, bmp, koala) image viewer for Commander X16
Lua
3
star
21

text-elite

python and cleand up ansi-c versions of text elite
C
2
star
22

ksim68k

m68k cpu simulator
Python
2
star
23

Elite-ships

3d model viewer for Elite's space ships
Python
2
star
24

cx16rockrunner

RockRunner - a Boulderdash(tm) clone for the Commander X16
Lua
1
star
25

mazes

some experiments with generating and solving mazes
Python
1
star
26

cx16kernel

custom CommanderX16 kernel rom
Assembly
1
star
27

cx16chess

Chess game for the Commander X16
Lua
1
star