Coder Social home page Coder Social logo

tim2000 / libremidi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from celtera/libremidi

0.0 0.0 0.0 11.32 MB

A modern C++ MIDI real-time & file I/O library. Supports Windows, macOS, Linux and WebMIDI.

License: Other

C++ 96.13% CMake 3.87%

libremidi's Introduction

libremidi

Build status

libremidi is a cross-platform C++20 library for real-time and MIDI file input and output.

This is a fork / rewrite based on two libraries:

Additionnally, for MIDI 2 parsing support we use cmidi2!

Changelog

Since v4.2

  • More robust MIDI 2.0 support.
    • On macOS through CoreMIDI (input / output, requires macOS 11+).
    • On Linux through ALSA sequencer API (input / output, requires kernel 6.5+ and latest libasound).
    • The API can be used through MIDI 1 or MIDI 2 affordances, e. g. one can send UMP packets to a MIDI 1 API, they will get converted automatically.
    • More backends to come, in particular with the new Windows MIDI Services started here!
    • Sysex handling on MIDI 2.0 is the responsibility of the user of the library, which simplifies the design immensely and allows the library to be used in stricter real-time contexts (as an UMP message has a fixed size, unlike MIDI 1 sysex which required potentially unbounded dynamic allocations with the previous design).
    • See midi_echo.cpp for a complete example.
  • Linux: libasound and udev are now entirely loaded at run-time through dlopen. This is necessary for making apps that will run on older Linux versions which do not have the ALSA UMP APIs yet. Note that to make an app which supports MIDI 2 on recent Linuxes and still runs on older ones, you will need to use the latest ALSA library headers as part of your build on an older distribution, by building alsa-lib yourself (as the old distributions with an old glibc that you want to build against to make compatible software of course also ship an old libasound which won't have the UMP API...).

Since v4

  • Experimental MIDI 2.0 support.
  • A neat configuration system which enables to pass options to the underlying backends.
  • Possibility to share the contexts across inputs and outputs to avoid creating multiple clients in e.g. JACK.
  • Hotplug support for all the backends!
  • Reworked port opening API which now uses handles instead of port indices to increase robustness in the face of disconnection / reconnection of MIDI devices.
  • Integer timestamps everywhere, and in nanoseconds. Additionnally, it is now possible to choose different timestamping methods (e.g. relative, absolute monotonic clock...).
  • Experimental API to allow to poll manually in ALSA (Sequencer and Raw), in order to give more control to the user and enable processing events on any kind of Linux event-loop.
  • Increase the checks done by the MIDI parser.
  • Internally it's pretty much a complete rewrite. Standard threading primitives are now used, as well as modern Linux facilities for polling control (eventfd, timerfd). Most of the code has been refactored.
  • Ability to set a fixed message size for zero-allocation scenarios, with -DLIBREMIDI_SLIM_MESSAGE=<NBytes> (in CMake or directly to the compiler)

Since v3

  • Allow to pass span when available (C++20) or (uint8_t* bytes, std::size_t size) pairs whenever possible to reduce copying.

Since v1

  • The library can be used header-only, as explained in the docs
  • Callbacks are passed by std::function and generally simplified.
  • Ability to use boost::small_vector to pass midi bytes instead of std::vector to reduce allocations.
  • Less indirections, virtuals and memory allocations.
  • Simplify usage of some functions, use C++ return style everywhere.
  • Use of standard C++ snake_case.
  • Simplification of exceptions.
  • Passes clean through clang-tidy, clang analyzer, GCC -Wall -Wextra, ASAN, UBSAN etc etc.
  • Support chunking of output data (only supported on raw ALSA backend so far).

New & improved backends

  • JACK support on Windows.
  • JACK support through weakjack to allow runtime loading of JACK.
  • UWP MIDI support on Windows
  • Emscripten support to run on a web browser with WebMIDI.
  • Raw ALSA support in addition to the existing ALSA sequencer support.

Roadmap

  • Migrate to std::expected instead of exceptions for error handling.
  • Finish MIDI 2 implementations, provide helpers, etc.
  • More tests and compliance checks
  • Work even more towards this library being a zero-cost abstraction on top of native MIDI APIs
  • Rethink some design issues with the original RtMidi, for instance the way port numbers work is not reliable
  • Refactor duplicated code across backends

They use this library

  • ossia.io: libremidi is used for every MIDI operation.

libremidi's People

Contributors

bratner avatar cacodemon345 avatar chdiesch avatar cpyarger avatar curve avatar dimitre avatar hyperlan-git avatar ivanhawkes avatar jcelerier avatar neilpang avatar stmpf avatar tmwsnrx avatar yurivict avatar yurkoy avatar

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.