Skip to main content

A Python library for interpreting the GoldenPond DSLs for making musical chord progressions and rhythmic musical lines.

Project description

GoldenPond Library

This is the Python version of the GoldenPond Library.

https://github.com/interstar/golden-pond

Quick Start

from goldenpond import GoldenData, Mode, TimeManipulator, MidiInstrumentContext

# Create a GoldenData instance
data = GoldenData()
data.root = 48  # C3
data.mode = 1  # Minor mode (0=major, 1=minor, 2=harmonic minor, 3=melodic minor)
data.chordSequence = "71,76,72,-75,71,76,72,-75i,77,73,76,<12,77ii,>12,71,96,74ii,75"
data.stutter = 0  # No stuttering
data.bpm = 120
data.chordDuration = 4

# Add lines with different patterns and instrument contexts
data.addLine("5/8 c 1", MidiInstrumentContext(0, 64, 0.8, 0))  # Chords on channel 0
data.addLine("7/12 > 2", MidiInstrumentContext(1, 80, 0.5, 12))  # Arpeggio on channel 1
data.addLine("4/8 1 4", MidiInstrumentContext(2, 90, 0.8, -12))  # Bass on channel 2

# Create TimeManipulator and line generators
tm = TimeManipulator().setPPQ(96).setChordDuration(data.chordDuration).setBPM(data.bpm)
generators = data.createLineGenerators(tm)

# Generate notes from each line
chords = generators[0].generateNotes(0)  # First line (chords)
arp = generators[1].generateNotes(0)     # Second line (arpeggio)
bass = generators[2].generateNotes(0)    # Third line (bass)

# Print chord notes with formatted floats
print("First 20 Chord notes:")
for note in chords[:20]:
    print(f"Note[midi: {note.getMidiNoteValue()}, startTime: {note.getStartTime():.1f}, length: {note.getLength():.1f}]")

# Print first arp note details with formatted floats
first_note = arp[0]
print("\nFirst Note from Arpeggio")
print(f"Getting individual fields: midi={first_note.getMidiNoteValue()}, "
      f"startTime={first_note.getStartTime():.1f}, length={first_note.getLength():.1f}")

# Print a summary of the data
print("\nGoldenData Summary:")
print(data.toString())

GoldenPond is a library for creating musical patterns using a simple text-based language. It helps you define chord progressions and rhythmic patterns (like arpeggios and basslines) that follow music theory rules.

Understanding the Example Code

Let's break down what the example code does:

  1. Setting Up the Musical Data

    data = GoldenData()
    data.root = 48  # C3
    data.mode = 1   # Minor mode
    data.chordSequence = "71,76,72,-75,71,76,72,-75i,77,73,76,<12,77ii,>12,71,96,74ii,75"
    data.bpm = 120
    data.chordDuration = 4
    

    This creates a musical piece in C minor at 120 BPM, with each chord lasting 4 beats.

  2. Defining Musical Lines

    data.addLine("5/8 c 1", MidiInstrumentContext(0, 64, 0.8, 0))  # Chords
    data.addLine("7/12 > 2", MidiInstrumentContext(1, 80, 0.5, 12))  # Arpeggio
    data.addLine("4/8 1 4", MidiInstrumentContext(2, 90, 0.8, -12))  # Bass
    

    Each line defines a different musical part:

    • First line: Full chords playing 5 notes in 8 steps
    • Second line: Ascending arpeggios playing 7 notes in 12 steps
    • Third line: Bass notes playing 4 notes in 8 steps
  3. Generating Notes

    tm = TimeManipulator().setPPQ(96).setChordDuration(data.chordDuration).setBPM(data.bpm)
    generators = data.createLineGenerators(tm)
    chords = generators[0].generateNotes(0)
    

    This creates the actual musical notes with proper timing.

  4. Accessing Note Data

    print(f"Note[midi: {note.getMidiNoteValue()}, startTime: {note.getStartTime():.1f}, length: {note.getLength():.1f}]")
    

    Each note contains:

    • midi: The MIDI note number (pitch)
    • startTime: When the note starts (in beats)
    • length: How long the note lasts (in beats)

What You Can Do With This

GoldenPond doesn't play music directly - it creates a data structure that you can use to:

  • Generate MIDI files (see the midi_example.py in the repository)
  • Create music in your own application
  • Analyze musical patterns
  • Experiment with different chord progressions and rhythms

For more details about the chord and rhythm languages, visit the GoldenPond website.

Technical Note

The GoldenPond library is written in Haxe and transpiled to Python. The source repository contains the original Haxe code and build scripts.

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

goldenpond-0.5.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

goldenpond-0.5.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file goldenpond-0.5.0.tar.gz.

File metadata

  • Download URL: goldenpond-0.5.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for goldenpond-0.5.0.tar.gz
Algorithm Hash digest
SHA256 1086886a5dd8d94a48f1b6bb9a427f7c34d92107f9d2062e0fad8f4208846742
MD5 bbaa53d37d0acc5c6890c757218728d2
BLAKE2b-256 51b205a91716dd87d3785becf8bf742f6fa7b2105970060e327f8d9e2ccee0c1

See more details on using hashes here.

File details

Details for the file goldenpond-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: goldenpond-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for goldenpond-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e30f35fd19128c3f5f99a07623a3bb74ea0d3d3039b2f80926b0b48d8fe767ef
MD5 f88128312b10ec847f0eec3a310d264c
BLAKE2b-256 c13f82b6826d8af1f36397e6b6dd61e0de03b2989aa3d268cdf0567354bf6b83

See more details on using hashes here.

Supported by

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