Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux/ALSA Native MIDI backend #637

Open
wants to merge 9 commits into
base: SDL2
Choose a base branch
from

Commits on Sep 20, 2024

  1. native_midi: Initial stubs for ALSA module

    This does not do anything yet, but does set up the necessary build
    changes so that we will link against the libasound library.
    fragglet committed Sep 20, 2024
    Configuration menu
    Copy the full SHA
    2418042 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cd39fbe View commit details
    Browse the repository at this point in the history

Commits on Sep 24, 2024

  1. native_midi: Open ALSA device, start thread

    We don't write any MIDI data to the sequencer yet but this sets up the
    basic foundations. For now, the playback thread just exits immediately,
    so `playmus` completes successfully.
    fragglet committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    7840957 View commit details
    Browse the repository at this point in the history
  2. native_midi: Connect to ALSA destination port

    We try various different ports that are usually the "default"; we need
    to provide a mechanism to specify it explicitly but for now this will
    do. These are the same "default" ports that DOSbox's ALSA code tries.
    fragglet committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    0aaa89d View commit details
    Browse the repository at this point in the history
  3. native_midi: Initial conversion of MIDI events

    This converts all the common MIDI events to the ALSA event types. The
    converted events are not yet sent to ALSA.
    fragglet committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    1d627cd View commit details
    Browse the repository at this point in the history
  4. native_midi: Send events to destination

    With this change in place the module actually works! There's more still
    to finish but this is actually usable.
    fragglet committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    85bc9bd View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5c10308 View commit details
    Browse the repository at this point in the history
  6. native_midi: Send reset messages on track stop

    The ALSA device we're sending messages to will continue playing them
    even if the program quits, and we don't want to leave notes hanging. So
    when stopping the current track, send the "notes all off" and "reset all
    controllers" messages to every channel, and also send an ALSA reset
    event as well for good measure (the Timidity++ daemon seems to respond
    to it)
    fragglet committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    fe25166 View commit details
    Browse the repository at this point in the history
  7. native_midi: Use non-blocking mode and polling

    When stopping a song we must wait for the playback thread to terminate.
    However, the thread may currently be doing a blocking write of some MIDI
    events and we don't actually know how long this may take to complete.
    
    Instead, we can use non-blocking mode and the poll() system call. This
    allows us to sleep when the output event buffer is full, but also allows
    us to wake it back up when it's time for the song to stop. We accomplish
    this by creating a pipe that we close on shutdown.
    fragglet committed Sep 24, 2024
    Configuration menu
    Copy the full SHA
    274d4f6 View commit details
    Browse the repository at this point in the history