Skip to main content

a python music engine, that can make music using code

Project description

pymusik

A production-grade Python library for modular music synthesis, algorithmic composition, and offline rendering.

built for programmers, researchers, and audio engineers who want to create music entirely through code.

Core Features

  • Sample-Accurate DSP: NumPy-powered synthesis engine for deterministic, high-quality audio.
  • Declarative Composition: Expressive API for notes, scales, chords, and patterns.
  • Modular Instruments: Procedural synths, physical modeling pianos, and drum synthesis.
  • Professional Output: Direct rendering to WAV (32-bit float/16-bit PCM) and MIDI export.

Technical Documentation

Core Components

Class Description Key Parameters
Note Single musical event pitch, duration (beats), velocity (0-1)
Scale Musical scale generator root, scale_type (major, minor, phrygian, etc.)
Chord Harmonic collection root, chord_type (maj7, min7, etc.), octave
Pattern Sequence of events elements, loop, length_beats
Song Global composition name, bpm, sample_rate, duration_beats

Synthesis Engine

Module Components Description
oscillators Sine, Saw, Square, Noise Mathematical waveform generators with phase maintenance.
envelopes ADSR Attack, Decay, Sustain, Release curves.
filters LowPass Butterworth filters for spectrum shaping.
effects Distortion, Delay, Chorus Signal processing for grit, space, and width.

Included Instruments

Instrument Type Characteristics
SynthInstrument Subtractive Flexible oscillators + ADSR + LPF.
PianoInstrument Physical Model Karplus-Strong string synthesis.
DrumInstrument Procedural Mathematical kick, snare, and hi-hat synthesis.
PhonkCowbell Procedural Iconic Memphis-style detuned square cowbells.
Bass808 Hybrid Low-frequency sine fundamental with harmonic distortion.
AcidBass Resonant Sawtooth with filter envelope sweeps (303-style).
ProDrums High-Fi Saturated kicks and snares for professional impact.

Quick Start

1. Installation

pip install pymusik

2. Basic Usage

from pymusik.core.pitch import Note
from pymusik.composition.pattern import Pattern
from pymusik.instruments.piano import PianoInstrument
from pymusik.engine.audio_graph import Song

# Initialize song
song = Song(bpm=120)

# Create a piano melody
piano = song.create_track("Piano", PianoInstrument())
melody = Pattern(["C4", "E4", "G4", "B4"], loop=True, length_beats=4.0)
piano.set_pattern(melody)

# Render
song.render("output.wav")

3. Advanced Phonk Demo (808s & Cowbells)

from pymusik.instruments.phonk import PhonkCowbell, Bass808
# ... setup song ...
bell = song.create_track("Cowbell", PhonkCowbell())
bass = song.create_track("808", Bass808())
# ... add patterns ...
song.render("phonk_drift.wav")

4. Pro Hi-Fi Mixing (Sidechaining & Saturation)

# Enable sidechain ducking on any track
bass_track.sidechain = True 

# The Renderer automatically applies:
# - Beat-synced volume ducking
# - Master soft-saturation and limiting
song.render("pro_mix.wav")

Project Structure

pymusik/
├── core/          # Pitch, Time, Events
├── composition/   # Pattern, Chord, Progression
├── synthesis/     # Oscillators, Envelopes, Filters
├── instruments/   # Synth, Piano, Drums, Phonk
├── effects/       # Distortion, Reverb
├── engine/        # Renderer, AudioGraph
└── output/        # WAV, MIDI Export

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymusik-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymusik-0.1.0-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file pymusik-0.1.0.tar.gz.

File metadata

  • Download URL: pymusik-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pymusik-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3bece7a6095964e575d76edcf0456aca1f9f0117da07b0a02850bc6cfdebfe55
MD5 1dd398063d30496fa76e648be2caf68a
BLAKE2b-256 ed420861f2a2c5a482211860b993b0884e3c25ae4f69f4b89ffcfc3bcf74665c

See more details on using hashes here.

File details

Details for the file pymusik-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymusik-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pymusik-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d7121e22f132424ce378747ca45c3bb0836be08d06536460edb9b4a2a857e09
MD5 3a0be37bc985d7b48090125d2066cebc
BLAKE2b-256 aa934f9dd8708d346bef643c2a959e82da000aeedf4bb569f34dc8b239cc058f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page