Architecture

midis2jam2 uses Compose Multiplatform for the main UI, and jMonkeyEngine for the 3D graphics.

flowchart LR
    subgraph midis2jam2
        compose[Compose Multiplatform]
        exec[Execution.kt]
        jme[jMonkeyEngine]

        compose --> exec
        exec --> jme
        exec --> compose
        jme --> exec
    end

The general user sequence for playing a MIDI file is as follows:

sequenceDiagram
    participant User
    participant Application
    participant MIDI File
    participant MIDI Device
    participant Soundbank
    participant JME

    User->>Application: Open
    activate Application
    User->> Application: Select a MIDI file directory
    Application->>MIDI File: Fetch files
    activate MIDI File
    MIDI File->>Application: Return selected file
    deactivate MIDI File
    User->> Application: Search MIDI files by instrument
    Application->>MIDI File: Search files
    activate MIDI File
    MIDI File->>Application: Return searched files
    deactivate MIDI File
    User->>Application: Select a MIDI device
    Application->>MIDI Device: Fetch devices
    activate MIDI Device
    MIDI Device->>Application: Return selected device
    deactivate MIDI Device
    User->>Application: Select "Gervill"
    Application->>Soundbank: Choose a soundbank
    activate Soundbank
    Soundbank->>Application: Return selected soundbank
    deactivate Soundbank
    User->>Application: Presses play
    Application->>JME: Open
    activate JME
    JME->>JME: Start process

“Start process” is further broken down:

sequenceDiagram
    participant User
    participant Application
    participant MidiSystem
    participant Sequencer
    participant Sequence
    participant Synthesizer
    participant Soundbank
    participant MidiDevice
    participant JME

    User->>Application: "Play" button pressed
    MidiSystem ->> Sequence: Get sequence
    activate MidiSystem
    activate Sequence
    Sequence ->> Application: Return sequence
    MidiSystem ->> MidiDevice: Get MIDI device
    activate MidiDevice
    MidiDevice ->> Application: Return MIDI device


    MidiSystem ->> Synthesizer: Get synthesizer
    activate Synthesizer
    Synthesizer ->> Synthesizer: Open synthesizer

    MidiSystem ->> Soundbank: Get soundbank
    activate Soundbank
    Soundbank ->> Synthesizer: Load soundbank
    deactivate Soundbank

    MidiSystem ->> Sequencer: Get sequencer
    activate Sequencer
    Sequencer -->> Synthesizer: Connect to synthesizer
    Synthesizer -->> Synthesizer: Open synthesizer
    Sequencer -->> MidiDevice: Connect to MIDI device
    MidiDevice -->> MidiDevice: Open MIDI device

    Sequencer ->> Sequencer: Open sequencer


    deactivate MidiSystem

    Application ->> JME: Start JME application
    activate JME
    JME ->> JME: Animation
    JME ->> Sequencer: Stop sequencer
    deactivate Sequencer
    JME -->> MidiDevice: Close MIDI device
    deactivate MidiDevice
    deactivate Sequence
    JME -->> Synthesizer: Close synthesizer
    deactivate Synthesizer