Giter VIP home page Giter VIP logo

diquencer's Introduction

diquencer

Simple MIDI sequencing library for Python designed for Elektron Digitakt.

Usage

The main features of diquencer are pattern changes and track mutes.

Initialization

Start with importing Sequencer class (which is the public API of diquencer):

from diquencer import Sequencer

then you can initialize it with the following optional arguments:

sequencer = Sequencer(
    midi_channel=1,
    start_callback=lambda: print("Called when the transport starts"),
    error_callback=lambda error: print(f"Something bad happened: {error}")
)
  • error argument of error_callback is an exception (it doesn't need to be handled though).
  • midi_channel value should be in the range from 1 to 16.

After initialization you can get available MIDI output ports and then select one:

>>> sequencer.output_ports
['IAC Driver Bus 1', 'Digitakt Elektron MIDI']
>>> sequencer.set_output_port('Digitakt Elektron MIDI')

then you should feed the sequencer with data:

sequence_data = {
    "tempo": 134,
    "sequence": [
        {
            "name": "Intro",
            "pattern": 9,
            "bank": "A",
            "length": 4,  # length of pattern in measures
            "repetitions": 2,
            "playing_tracks": [1, 3, 7]  # tracks that are NOT muted
        },
        {
            "name": "Outro",
            "pattern": 10,
            "bank": "A",
            "length": 4,
            "repetitions": 2,
            "playing_tracks": [2, 4, 8]
        }
    ]
}
sequencer.load_sequence(sequence_data)

Running the sequencer

You can start (and stop) the playback with:

>>> sequencer.start()
>>> sequencer.is_playing
True
>>> sequencer.stop()

By default start fuction is non-blocking (the actual sequencer runs in a separate thread). You can, however, make it blocking with an optional argument:

>>> sequencer.start(blocking=True)
>>> sequencer.is_playing
False  # already finished

During playback (in non-blocking mode) you can enquire the sequencer about its status:

>>> sequencer.position
'001.0.17'  # MEASURE.QUARTER_NOTE.PULSE
>>> sequencer.current_pattern.name
'Intro'
>>> sequencer.next_pattern.name
'Outro'

Playback may be started from any pattern you want:

>>> sequencer.set_start_pattern(1)
>>> sequencer.start()
>>> sequencer.current_pattern.name
'Outro'

the argument of set_start_pattern is the index (starting from 0) of pattern in sequence list (see sequence_data in previous section).

If you wish, you can change the output MIDI channel and port (changes will have an effect after the playback restarts):

sequencer.set_midi_channel(5)

diquencer's People

Contributors

dependabot[bot] avatar mcjlnrtwcz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

diquencer's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.