Skip to main content

Python bindings for the SunVox modular synthesizer library

Project description

pysunvox

Python bindings for the SunVox modular synthesizer library.

Features

  • High-level Pythonic API with context managers, properties, and type hints
  • Low-level 1:1 wrappers of the C sv_* functions
  • Full access to modules, controllers, patterns, and playback
  • Thread-safe slot locking

Installation

pip install pysunvox

Quick Start

import time
from pysunvox import SunVox

with SunVox(sample_rate=44100) as sv:
    with sv.open_slot(0) as slot:
        slot.load("song.sunvox")
        print(f"Song: {slot.name}, BPM: {slot.bpm}")
        slot.volume = 256
        slot.play_from_beginning()
        time.sleep(10)
        slot.stop()

Command-Line Interface

pysunvox provides a CLI for common operations:

# Show help
pysunvox --help

# Display project information
pysunvox info song.sunvox

# List all modules in a project
pysunvox modules song.sunvox

# Show detailed module info (including controllers)
pysunvox module song.sunvox 1

# List all patterns
pysunvox patterns song.sunvox

# Play a project
pysunvox play song.sunvox

# Play with options
pysunvox play song.sunvox --duration 30 --volume 200 --line 0

# Show version information
pysunvox version

CLI Commands

Command Description
info <file> Show project metadata (name, BPM, TPL, duration, counts)
modules <file> List all modules with type, name, and flags
module <file> <id> Show detailed module info including controllers
patterns <file> List all patterns with tracks, lines, and position
play <file> Play a project (-d duration, -v volume, -l start line)
version Show pysunvox and SunVox library versions

API Overview

High-Level API

The high-level API provides Pythonic classes with context managers:

from pysunvox import SunVox, Slot, Module, Pattern

# Initialize engine and open a slot
with SunVox(sample_rate=44100) as sv:
    with sv.open_slot(0) as slot:
        # Load and play a project
        slot.load("project.sunvox")
        slot.play()

        # Access song properties
        print(f"BPM: {slot.bpm}, TPL: {slot.tpl}")
        print(f"Length: {slot.length_lines} lines")

        # Work with modules
        for i in range(slot.num_modules):
            module = slot.get_module(i)
            if module.exists:
                print(f"Module {i}: {module.name} ({module.type})")

        # Create modules (requires lock)
        with slot.lock():
            synth = slot.new_module("Generator", "MySynth", x=256, y=256)
            synth.connect_to(0)  # Connect to Output

        # Access module controllers
        ctl = synth.get_controller(0)
        print(f"{ctl.name}: {ctl.value} (range: {ctl.min_value}-{ctl.max_value})")
        ctl.value = 128

        # Work with patterns
        with slot.lock():
            pattern = slot.new_pattern("MyPattern", tracks=4, lines=32)
            pattern.set_event(track=0, line=0, note=60, vel=128, module=synth.num + 1)

        # Save the project
        slot.save("modified.sunvox")

Low-Level API

Direct access to sv_* functions via the _core module:

from pysunvox import _core

# Initialize
_core.init(None, 44100, 2, 0)
_core.open_slot(0)

# Load and play
_core.load(0, "song.sunvox")
_core.play_from_beginning(0)

# Query state
print(f"BPM: {_core.get_song_bpm(0)}")
print(f"Current line: {_core.get_current_line(0)}")

# Cleanup
_core.stop(0)
_core.close_slot(0)
_core.deinit()

Constants

from pysunvox import (
    # Note commands
    NOTECMD_NOTE_OFF,
    NOTECMD_ALL_NOTES_OFF,
    NOTECMD_PLAY,
    NOTECMD_STOP,

    # Init flags
    SV_INIT_FLAG_NO_DEBUG_OUTPUT,
    SV_INIT_FLAG_OFFLINE,
    SV_INIT_FLAG_AUDIO_FLOAT32,

    # Module flags
    SV_MODULE_FLAG_EXISTS,
    SV_MODULE_FLAG_GENERATOR,
    SV_MODULE_FLAG_EFFECT,
)

Supported Platforms

Pre-built wheels are available for:

  • macOS: x86_64, arm64
  • Linux: x86_64, aarch64 (glibc only, no musl/Alpine)
  • Windows: AMD64

Python versions: 3.10, 3.11, 3.12, 3.13

Building from Source

Requires the SunVox library for developers.

# Install dependencies and build
make sync
make build

# Run tests
make test

# Build wheel with bundled library
make wheel

# Clean build artifacts
make clean

License / Credits

All rights for SunVox and its developer library reserved to its author, Alexander Zolotov.

See: https://warmplace.ru

Powered by SunVox (modular synth & tracker) Copyright (c) 2008 - 2024, Alexander Zolotov nightradio@gmail.com, WarmPlace.ru

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pysunvox-0.1.0-cp314-cp314-macosx_15_0_arm64.whl (652.4 kB view details)

Uploaded CPython 3.14macOS 15.0+ ARM64

pysunvox-0.1.0-cp313-cp313-macosx_15_0_arm64.whl (651.5 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pysunvox-0.1.0-cp312-cp312-macosx_15_0_arm64.whl (652.0 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pysunvox-0.1.0-cp311-cp311-macosx_15_0_arm64.whl (650.6 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

pysunvox-0.1.0-cp310-cp310-macosx_15_0_arm64.whl (650.9 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

File details

Details for the file pysunvox-0.1.0-cp314-cp314-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pysunvox-0.1.0-cp314-cp314-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 fb7b3018c92f0cab6c3a67a9621fa94433aac160826f9ceffa039a1abf9e5066
MD5 93e7405ae5772dbafd20e293045bd0d0
BLAKE2b-256 5ee2d830edf6bed3955fdac74b8dac7d2e6c1bb4f922dbee6ac24ad6db8342d1

See more details on using hashes here.

File details

Details for the file pysunvox-0.1.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pysunvox-0.1.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4c70b57f3d562de7da09d4c630d17a3574aec077ccbef8f17af7fd5278f8dff6
MD5 72de8a77ea8aca05e0a4144b07343a77
BLAKE2b-256 1355dc9561070d46d7a5160f72da0da187bd8c7e0c12a14e16704f6638b87776

See more details on using hashes here.

File details

Details for the file pysunvox-0.1.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pysunvox-0.1.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9f941dc62ee1d19fbf16f138bed9ec18449eeaf1366e9d347ae1f0ba618a7da0
MD5 7a356bb545c6c48a51cc5c996104cfe7
BLAKE2b-256 a2ac75e6095576d9e0feedc0496cd800799acca584a499922ec0d71f71a64bbf

See more details on using hashes here.

File details

Details for the file pysunvox-0.1.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pysunvox-0.1.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 9fb89119414935913a68a561899debc4c8f56a3243decf422aaa9801ba642992
MD5 8572c1166eb3ced79f9d3283b4f2d460
BLAKE2b-256 3546a65997a24965f5168ca4df1a2df7fd1b31fbff972436280393c56e599cb6

See more details on using hashes here.

File details

Details for the file pysunvox-0.1.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pysunvox-0.1.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 90fde178a4efb0ec81742ffd81695bea4e617035e3d21f289f8fafc6685a4325
MD5 7e6f54a0e2267064b849e974936416cc
BLAKE2b-256 768057cc550d7bfcb957f11eedfdb66c8422afb3f30dfe55b2507619f0aeccbb

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