Skip to main content

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 info song.sunvox --modules

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

# List all patterns
pysunvox info song.sunvox --patterns

# Scan and analyze all songs in a directory
pysunvox songs /path/to/songs

# Scan recursively
pysunvox songs /path/to/songs -r

# Play a project
pysunvox play song.sunvox

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

# Show version information
pysunvox info --version

CLI Commands

Command Description
info <file> Show project metadata (name, BPM, TPL, duration, counts)
info <file> -m/--modules List all modules with type, name, and flags
info <file> -M/--module <id> Show detailed module info including controllers
info <file> -p/--patterns List all patterns with tracks, lines, and position
info --version Show pysunvox and SunVox library versions
songs <dir> [-r] Scan and analyze all songs in a directory
play <file> Play a project (-d duration, -v volume, -l start line)

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

Metadata

Release files for pysunvox 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for pysunvox 0.1.1
File
pysunvox-0.1.1-cp314-cp314-macosx_15_0_arm64.whl CPython 3.14 CPython 3.14 macOS 15.0+ ARM64 Details
pysunvox-0.1.1-cp313-cp313-macosx_15_0_arm64.whl CPython 3.13 CPython 3.13 macOS 15.0+ ARM64 Details
pysunvox-0.1.1-cp312-cp312-macosx_15_0_arm64.whl CPython 3.12 CPython 3.12 macOS 15.0+ ARM64 Details
pysunvox-0.1.1-cp311-cp311-macosx_15_0_arm64.whl CPython 3.11 CPython 3.11 macOS 15.0+ ARM64 Details
pysunvox-0.1.1-cp310-cp310-macosx_15_0_arm64.whl CPython 3.10 CPython 3.10 macOS 15.0+ ARM64 Details

Total release size: 3.3 MB

Release files / pysunvox-0.1.1-cp314-cp314-macosx_15_0_arm64.whl

Download URL pysunvox-0.1.1-cp314-cp314-macosx_15_0_arm64.whl
Size 652.5 kB
Tags CPython 3.14 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
85cddb2e9ead68d60b6c37fda9069cb6616bdef5a8dce397a1fca311cd860496
BLAKE2b-256 checksum
How to use checksums
bcfc994f043c654b71fb6fbfb8fd5b8b97b1287f02a8788b4c1dc9c6d2ba207d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / pysunvox-0.1.1-cp313-cp313-macosx_15_0_arm64.whl

Download URL pysunvox-0.1.1-cp313-cp313-macosx_15_0_arm64.whl
Size 651.6 kB
Tags CPython 3.13 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
56a57051745efa48e99ab1af29625c0d5a78cf826b473747569b3e6af3b29d6d
BLAKE2b-256 checksum
How to use checksums
9a7a9e186b1067d1f4493e285f937fc1cfdf45f86bdf6ce414263921fbccbefb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / pysunvox-0.1.1-cp312-cp312-macosx_15_0_arm64.whl

Download URL pysunvox-0.1.1-cp312-cp312-macosx_15_0_arm64.whl
Size 652.1 kB
Tags CPython 3.12 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
567fee833c0ff7c901cc9c3c0dd951df7eee389c4373f49d3e49db965dd236e2
BLAKE2b-256 checksum
How to use checksums
31b05bad515ce347e3a73299a221227770e8e89397ededf24ada0b898b058cf4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / pysunvox-0.1.1-cp311-cp311-macosx_15_0_arm64.whl

Download URL pysunvox-0.1.1-cp311-cp311-macosx_15_0_arm64.whl
Size 650.6 kB
Tags CPython 3.11 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
2095e2248fc6b7c74194b51c7c1f645009cfe67d8869d4ba36a6571630e2fc1d
BLAKE2b-256 checksum
How to use checksums
26195e4071616b27d6c3e3c52901aae94a48eb4b8af8207008a1530674187231
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / pysunvox-0.1.1-cp310-cp310-macosx_15_0_arm64.whl

Download URL pysunvox-0.1.1-cp310-cp310-macosx_15_0_arm64.whl
Size 651.0 kB
Tags CPython 3.10 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
177fd426061fa809d75ff2745d8bbc008c114a35e338cd3f8265fdfb6258cf2f
BLAKE2b-256 checksum
How to use checksums
ecf08a73fc202ee608583d59bea61799946b5c5480f63bbaf2e0e3d2a93bb174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Security for pysunvox 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

5 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page