isobar

repository·master·Indexed 19 days ago

https://github.com/ideoforms/isobar

A Python library for algorithmic composition, generative music, and sonification. isobar uses a hierarchical model of Timelines, Patterns, and Events to schedule musical data. It supports a wide range of pattern generators—including core mathematical operators, structured sequences, stochastic chance patterns, and tonal mapping tools—and can output to MIDI, MIDI files, OSC, FluidSynth, SignalFlow, and SuperCollider.

Tokens
13.6K
Snippets
44
Records
74
Agent score
63%

What's inside isobar

  1. Overview of supported event types

    master

    Isobar supports three primary categories of events:

    1. Note events: Trigger discrete MIDI notes. They typically include properties for duration and amplitude.
    2. Control events: Handle MIDI messages such as control change, program change, and pitchwheel. These can be used to apply quasi-continuous control curves.
    3. Action events: Allow you to call arbitrary Python functions at scheduled times.
  2. Understand isobar's capabilities and limitations

    master

    Capabilities

    • Event Triggering: Send MIDI, OSC, SocketIO, or trigger Python functions.
    • Real-time & Offline: Trigger events in real-time or generate patterns for serialization into .mid files for use in a DAW.
    • Synchronization: Synchronize to or from external devices using MIDI clock sync or Ableton Link.
    • MIDI Processing: Load existing patterns from MIDI files for manipulation.

    Limitations

    • No Audio Generation: isobar does not generate audio itself. It is a sequencing and control engine that must be connected to an external output device (like a synthesizer or DAW) responsible for sound synthesis.
  3. Explore isobar output devices and I/O options

    master

    isobar supports several different types of output devices for sending and receiving events. Depending on your workflow, you can target hardware or software via:

    • MIDI: Send/receive live MIDI notes, control, and clock events to external hardware or software hosts (like a DAW).
    • MIDI file: Generate and save sequences directly to .mid files.
    • OpenSoundControl (OSC): Send events over the network using the OSC protocol.
    • SignalFlow: Trigger events within the SignalFlow synthesis engine.
    • SuperCollider: Send events to a SuperCollider synthesis server.
    • FluidSynth: Trigger notes in the FluidSynth software synthesizer.
  4. Overview of isobar core concepts

    master

    isobar is a Python library for algorithmic composition and generative music. It provides a framework for sequencing and triggering events (MIDI, OSC, SocketIO, or Python functions) to be used in real-time or serialized as MIDI files.

    Key Mental Model:

    1. Timeline: The central scheduler that handles timing and triggers events. It can run on its own internal clock or synchronize with external MIDI clocks or Ableton Link.
    2. Events: The data packets sent or received. An event is typically a dictionary of properties, such as { "note": 60, "amplitude": 127 }.
    3. Patterns: Generators used to define the properties of events. Patterns produce sequences of values (fixed, random, or statistical) and can be composed (e.g., using one pattern to transform another).
    4. Devices: The interfaces used to send or receive events, such as MIDI or OSC outputs.
  5. Use Warp patterns for tempo modulation

    master

    Warp patterns allow you to modulate the timeline tempo:

    • PWarp: Requests a new target warp value from a pattern every length beats.
    • PWSine: A sinusoidal warp with a period of length beats and an amplitude of +/-<amp>.
    • PWRallantando: An exponential deceleration to <amp> times the current tempo over length beats.
  6. How isobar works: Timelines, Patterns, and Events

    master

    isobar is built around a hierarchical model for algorithmic composition:

    1. Timeline: The central engine that schedules events at a specific tempo. It can control its own tempo or sync to an external clock. Events are sent to an OutputDevice (by default, the system's default MIDI output).
    2. Patterns: These are templates used to generate values. Patterns can represent note sequences, control events, program changes, or arbitrary data via lambda functions. They can be combined using mathematical operators or transformed using specialized pattern classes.
    3. Events: When a Timeline schedules a pattern, it generates Events. An event contains properties (like note, duration, or amplitude) derived from the assigned Patterns.

    Workflow Summary: Patterns $\rightarrow$ Timeline.schedule() $\rightarrow$ Events $\rightarrow$ OutputDevice (MIDI/OSC).

  7. Use Markov patterns for probabilistic sequences

    master

    Markov patterns use Markov chains to generate sequences based on probabilities:

    • PMarkov: A first-order Markov chain generator.
    • MarkovLearner: A class that learns a Markovian sequence by sequentially registering new values.
    • MarkovGrapher: A helper class used to graph the structure of a PMarkov object.
  8. Use Chance patterns for stochastic generation

    master

    Chance patterns (subclasses of PStochasticPattern) introduce randomness into your sequences. Common patterns include:

    • PWhite: White noise between min and max.
    • PBrown: Brownian noise.
    • PCoin: Returns 0 or 1 based on a probability.
    • PRandomWalk: A random walk around a list.
    • PChoice: Picks a random element from values, optionally weighted by weights.
    • PSample: Picks multiple random elements from values, optionally weighted by weights.
    • PShuffle: Returns a shuffled list.
    • PSkip: Skips events with a probability of 1 - play.
    • PFlipFlop: Flips a binary bit with a given probability.
    • PRandomExponential: Random uniform on an exponential curve between min and max.
  9. Identify event types by dictionary keys

    master

    When passing a dictionary to Timeline.schedule(), the presence of specific keys determines the event type:

    • Note events: Identified by the presence of a note or degree key.
    • Control events: Identified by the presence of a control or program_change key.
    • Action events: Identified by the presence of an action key.
  10. Use Scalar patterns for data transformation

    master

    Scalar patterns transform or analyze input patterns to produce single values:

    • PChanged: Returns 1 if the input pattern value has changed, 0 otherwise.
    • PDiff: Returns the difference between the current and previous values of an input pattern.
    • PSkipIf: Returns input if skip is false; otherwise returns None.
    • PNormalise: Adaptively normalises input to the range [0..1] over a linear scale.
    • PMap: Applies an arbitrary function to an input pattern.
    • PMapEnumerated: Applies an arbitrary function to an input, passing a counter.
    • PScaleLinLin: Maps input from a linear range [a, b] to a linear range [c, d].
    • PScaleLinExp: Maps input from a linear range [a, b] to an exponential range [c, d].
    • PRound: Rounds input to N decimal places.
    • PScalar: Reduces tuples and lists into single scalar values.
    • PWrap: Wraps input note values within a specified [min, max] range.
    • PIndexOf: Finds the index of items from a pattern within a provided list.