Home

Awesome

cxxmidi

C++ MIDI library.

ci codecov

Key features

Design

Simple example

#include <cxxmidi/file.hpp>
#include <cxxmidi/output/default.hpp>
#include <cxxmidi/player/synchronous.hpp>

int main(int /*argc*/, char** /*argv*/) {
  cxxmidi::output::Default output;
  for (size_t i = 0; i < output.GetPortCount(); i++)
    std::cout << i << ": " << output.GetPortName(i) << std::endl;
  output.OpenPort(1);

  cxxmidi::File file("music/chopin.mid");

  cxxmidi::player::Synchronous player(&output);
  player.SetFile(&file);

  player.SetCallbackHeartbeat(
      [&]() { std::cout << player.CurrentTimePos().count() << std::endl; });

  player.Play();
}

More examples

How to use

To use library clone the repo and copy include directory into your project. Use of some cxxmidi classes requires external libraries linkage.

ClassRequired external library
cxxmidi::output::Alsalibasound
cxxmidi::output::Windowswinmm.lib

How to build tests and examples

mkdir build
cd build
cmake ..
make

cpplint suppressions

cpplint suppressions in the code are marked:

// NOLINT(${checkName}) ${mark}
MarkRelated check nameReason for suppression
CPP11_INCLUDESbuild/c++11[build/c++11] [5] is reported when parsing include directive of unapproved C++11 header file (like chrono, thread or mutex). These files have custom implementations in Chrome, but not in this project.
INCLUDE_NO_DIRbuild/include_subdir[build/include_subdir] [4] is reported if no directory name is present in include directive, but it is common in Qt code to skip it. This exception is allowed only in examples code.
SIGNAL_SLOT_SPECIFIER[whitespace/indent][whitespace/indent] [3] is reported when parsing Qt signal/slot specifiers.

cppcheck suppressions

cppcheck suppressions in the code are marked:

// cppcheck-suppress ${checkName} ${mark}
MarkRelated check nameReason for suppression
RAIIunreadVariable(style) Variable '...' is assigned a value that is never used. is reported for RAII objects like mutexes.
LIB_FUNCunusedFunction(style) The function '...' is never used. is reported for library functions.

License