LibMEI is a C++ library for reading and writing MEI files

Related tags

Audio libmei
Overview

LibMEI

Build Status

LibMEI is a C++ library for reading and writing MEI files

It is developed by the Distributed Digital Music Archives and Libraries Lab at the Schulich School of Music at McGill University, Montréal, Canada

License

LibMEI is released under the MIT license.

Compilation & Usage

We provide an XCode project for OSX and a cmake script for Linux.

To build on Linux, simply

mkdir build; cd build
cmake ..
make
sudo make install

To use libmei, include

#include 

We provide two sample applications to demonstrate use. util/readmei.cpp is a trivial example of reading and writing MEI, and making a change to the document structure. util/mxmltomei contains a tool to convert between MusicXML and MEI. This tool is still in active development.

More detailed information about compilation and use is available at the libmei wiki: https://github.com/DDMAL/libmei/wiki

Python

LibMEI ships with Python bindings using the Boost-Python framework. More information about installing and using these bindings can be found in Installing the Python bindings

Customization

One of the most useful features of the MEI specification is the ability to generate custom schemas (in RelaxNG, DTD or W3C Schema) containing only the music notation features that you require. For example, there is no need to validate documents written in mensural notation against the Common Music Notation features of MEI. Also, MEI allows you to define new customizations for musical features that may not be covered under the core specification. These are features inherited from the TEI project, and you can read more about them on the ODD Overview Page or in our paper about MEI and LibMEI.

LibMEI ships with tools that allow you to easily work with these customizations to limit or expand the functionality. In the tools directory we include a Python script, parseschema2.py that will generate custom code for you in either C++ or Python. (Other languages may be added as well, if requested).

You can read more about customization and custom compiliation on our wiki pages.

Contributions

We welcome bug reports, feature requests, and patches to the libmei project page: https://github.com/DDMAL/libmei

Comments
  • Update Manuscript generation to work with sibmei

    Update Manuscript generation to work with sibmei

    To avoid the need of conflict resolution with merging commits one by one, this pull request supersedes #111, #112, #116 and #117.

    This includes changes that were made to the libmei shipping with sibmei. For example, the RemoveChild() method was added with 24f5b43 in 2015, but was never added to the libmei generator.

    Goal is that we can generate libmei for sibmei without having to manually merge changes every time.

    opened by th-we 10
  • Building Python Bindings: Python.h not found in src/_libmei.cpp

    Building Python Bindings: Python.h not found in src/_libmei.cpp

    Hi,

    I have just tried to build the Python bindings after succesfully having compiled and installed libmei.

    I followed the instructions on https://github.com/DDMAL/libmei/wiki/Installing-the-Python-bindings

    :~/gitreps/libmei/python$ python setup.py build
    running build
    running build_py
    running egg_info
    writing pymei.egg-info/PKG-INFO
    writing top-level names to pymei.egg-info/top_level.txt
    writing dependency_links to pymei.egg-info/dependency_links.txt
    reading manifest file 'pymei.egg-info/SOURCES.txt'
    writing manifest file 'pymei.egg-info/SOURCES.txt'
    running build_ext
    building 'pymei/_libmei' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c src/_libmei.cpp -o build/temp.linux-x86_64-2.7/src/_libmei.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
    src/_libmei.cpp:24:20: fatal error: Python.h: No such file or directory
     #include "Python.h"
                        ^
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    
    
    

    It doesn't find Python.h. Where would that file be located?

    I use Python 2.7.

    Thx.

    Cross-platform Documentation 
    opened by tobiasschweizer 10
  • itemList not registered

    itemList not registered

    I get the following runtime error while importing an MEI that has an itemList element: That element name itemList was not registered with the factory and could not be created.

    opened by zolaemil 5
  • Python object lists

    Python object lists

    Python lists of MeiElement/MeiAttribute objects do not play well with the python bindings of the C++ functions.

    for example:

    attrs = nc.getAttributes()
    
    # manipulate the array somehow
    attrs.pop()
    
    nc.setAttributes(attrs)
    

    Results in:

    MeiElement.setAttributes(MeiElement, list)
    did not match C++ signature:
        setAttributes(mei::MeiElement {lvalue}, std::vector<mei::MeiAttribute*, std::allocator<mei::MeiAttribute*> >)
    
    Python Bindings 
    opened by gburlet 5
  • Make GoogleTest optional on Linux

    Make GoogleTest optional on Linux

    Currently the CMake script assumes that the GoogleTest framework is installed, and will fail if not. We should remove this as a dependency and make it optional to run the tests.

    Cross-platform 
    opened by ahankinson 5
  • Python Bindings: -lboost_python-mt not found (already checked troubleshooting)

    Python Bindings: -lboost_python-mt not found (already checked troubleshooting)

    This issue happened using either python2 or python3. Using the libmei code from the develop branch (and from the previous release, the 2.0.0 version) when I do python setup.py build I got the message:

    Library not found for -lboost_python-mt

    Even though I did export CFLAGS="-F /Library/Frameworks -I /usr/local/include -L /usr/local/lib" to tell the system where lboost_python-mt is, as indicated in the Troubleshooting section of the python bindings in the wiki.

    opened by martha-thomae 4
  • Changes to parseschema2.py

    Changes to parseschema2.py

    refs #88

    A few small changes should be made to parseschema2:

    1. Print out diagnostic information if any of the languages put in using the -l flag are not supported.

    1.1) @AFFogarty also wants the -l flag to no longer be case sensitive so -l Python and -l python and -l PyThOn would work identically.

    1.2) Change the --help flag to show that you can do multiple languages at the same time.

    1. In the case where neither -sl OR [compiled] are present in the invocation (such as python parseschema2.py -l cpp), the warning message defaults to a message about -sl if the user has input other parameters. This is an edge case for misuse, but I think the default should be a message about the [compiled] parameter if it's missing. @ahankinson can correct me if he thinks otherwise.
    Feature Requests Working with XML 
    opened by ahwitz 4
  • Lookback Methods

    Lookback Methods

    Filed here so I don't forget:

    Now that we have a flattened representation, it's also possible to do "lookback" methods. For example, we tell a note to find its layer, measure, and staff number by starting at the note and working backwards through the list until we find the first previous occurrence of that element.

    This has the advantage of being outside of the normal hierarchy, so we can search for things that aren't normally related to that element. For example, if we want to find the system # that a note is on, we can look back until we find the first sb element. Since sb is normally a milestone (i.e., <sb />) element, the note has no direct relationship to it.

    This will likely be a class of methods, since most objects will have different things they want to look back to find. For example, rests, notes, clefs, etc. will want to access measures, layers, systems, staffs, sections, etc., while staffDefs will want to find out if they're a member of a staffGrp.

    We may also want to add an extra optional parameter for checking if it's also an ancestor. Imagine if we had:

    ...
    <staffGrp>
          <staffDef />
          <staffDef />
    </staffGrp>
    <staffDef />
     ...
    

    If we don't check for ancestry, then the last <staffDef> would be mistakenly included in the previous <staffGrp>.

    For implementation, we may need a number of methods to support this.

    int pos MeiElement->positionInDocument(); 
    returns the element's position in the flattened document representation vector
    
    MeiElement* el MeiDocument->lookBack(int startpos, string elname);
    returns the first MeiElement* matching elname, starting at startpos and working backwards.
    
    MeiElement* el MeiDocument->lookBack(int startpos, string elName, bool isAncestor);
    returns the first MeiElement* matching elName, but allows the user to specify if they want to include (or exclude) only matches 
    that are ancestors of the found element.
    

    This would then be implemented at the Mei Element Object level, e.g.,

    MeiElement* el staffDef->getStaffGrp() {
        int pos = staffDef->positionInDocument();
        MeiElement* staffGrp = staffDef->getDocument()->lookBack(pos, "staffGrp", True);
        return staffGrp;
    }
    
    opened by ahankinson 4
  • Store ID Map in an ordered form

    Store ID Map in an ordered form

    Currently, MeiDocument stores ids and pointers to elements in a weakly-ordered map (alphabetical ordering by key). This makes it very difficult to do operations like "get me all elements that occur between ID A and ID B".

    Possible solutions:

    1. Store the ID map in some sort of ordered form (2D array?)
    2. Store a map and an ordered vector as a lookup table. "Get me all elements between A and B" would slice the vector, and then retrieve all IDs between A and B from the ID Map.

    Use case: Retrieving all elements between a startid and endid.

    opened by ahankinson 4
  • Add an MeiDocument pointer to all MeiElements

    Add an MeiDocument pointer to all MeiElements

    An element should know what document it belongs to. This has been started in the branch element-doc-link. These things should work:

    • If an element is added as a child and neither element is attached to a document, nothing happens.
    • If the parent element belongs to a document, the child element should be linked to the same document
    • If an element tree is added to a document (MeiDocument::setRootElement), all elements should have their document pointer updated
    • When an element gets its document set, it should tell the document what its id is. The document then stores a map<string, MeiElement> for getElementById lookups
    opened by alastair 4
  • automatically generate ids

    automatically generate ids

    If IDs are required, we should give the ability to automatically generate one. Either on construction of the element, or with a generateId() method. This needs to work in with reading an xml file with existing ids.

    Core MEI Functionality 
    opened by alastair 4
  • Add build instructions for OSX without XCode

    Add build instructions for OSX without XCode

    I was able to install libmei without XCode using the following commands:

    git clone https://github.com/DDMAL/libmei.git
    cd libmei
    mkdir build && cd build
    brew install cmake
    brew install ossp-uuid
    cmake .. -DCMAKE_FIND_FRAMEWORK=LAST
    make
    make install
    

    This could be useful to others who don't normally use XCode. It might also help to streamline the creation of a Homebrew package.

    opened by xavriley 1
  • memory leak from setRootElement

    memory leak from setRootElement

    I am seeing a memory leak with the simplest example document:

    test.cpp:

    #include <mei/mei.h>
    #include <mei/shared.h>
    
    int main(){
        mei::MeiDocument *doc = new mei::MeiDocument();
        mei::Mei *mei = new mei::Mei();
        doc->setRootElement(mei);
        delete doc;
    }
    

    I compile with this command:

    clang++ -Wall -Werror -Wextra -Wpedantic -lmei -O1 -g -fsanitize=address -fno-omit-frame-pointer -o test test.cpp
    

    This is the output from clang about the memory leak:

    
    =================================================================
    ==16660==ERROR: LeakSanitizer: detected memory leaks
    
    Direct leak of 80 byte(s) in 1 object(s) allocated from:
        #0 0x4fd927 in operator new(unsigned long) (/[dir]/test+0x4fd927)
        #1 0x7fd379584aa8 in mei::MeiDocument::setRootElement(mei::MeiElement*) (/usr/local/lib/libmei.so+0xf3aa8)
        #2 0x50065e in main /[dir]/test.cpp:7:10
        #3 0x7fd378f9e55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
    
    Direct leak of 80 byte(s) in 1 object(s) allocated from:
        #0 0x4fd927 in operator new(unsigned long) (/[dir[/test+0x4fd927)
        #1 0x7fd379584b4e in mei::MeiDocument::setRootElement(mei::MeiElement*) (/usr/local/lib/libmei.so+0xf3b4e)
        #2 0x50065e in main /[dir]/test.cpp:7:10
        #3 0x7fd378f9e55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)
    
    Indirect leak of 37 byte(s) in 1 object(s) allocated from:
        #0 0x4fd927 in operator new(unsigned long) (/[dir]/test+0x4fd927)
        #1 0x7fd3793b7181 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) (/lib64/libstdc++.so.6+0x145181)
    
    SUMMARY: AddressSanitizer: 197 byte(s) leaked in 3 allocation(s).
    
    opened by andrewacashner 2
  • Remove unused ManuScript code that does not work any more

    Remove unused ManuScript code that does not work any more

    This unused code won't work any more because the surrounding code has evolved away from it. Specifically, MEIFlattened is no longer a SparseArray and can not be used in the way these function use it.

    opened by th-we 1
  • No errors on deprecated warnings

    No errors on deprecated warnings

    Since some features are deprecated (and more possibly will be eventually), keep errors on warnings (-Werror) but also add an exception to just warn on deprecation (-Wno-error=deprecated) rather than fail.

    This keeps deprecation warnings visible and also causes more serious warnings (like uninitialized variables/pointers) to error.

    This addresses issue #110.

    opened by JRegimbal 0
Releases(3.1.0)
  • 3.1.0(Jun 15, 2018)

    This is mainly to get the master branch in sync with thedevelop branch. develop has been ahead for a while and the last commit on master was not stable.

    We decided that since develop is working and passing all the tests, it is a good time for sync'ing and creating a new release.

    @deepio integrated travis-ci so unit tests are running automatically now.

    The master branch is blocked, so any progress in develop can be tested automatically and merged to master through pull requests.

    Source code(tar.gz)
    Source code(zip)
  • 3.0.0(Jan 11, 2017)

  • v2.0.0(May 13, 2015)

    This release features a new XML parser, PugiXML, which deprecates the old dependency on libxml2. PugiXML is distributed with libmei now, so no further dependencies are needed (except on Linux, where libuuid is still required).

    As well, several notable feature additions and bug fixes are included:

    • strict and lax importer modes are supported. Importing a MEI file in lax mode that features elements that were not included in a schema will no longer raise an exception. Rather, it will log a warning and import the element as a raw MeiElement object
    • Python bindings are compatible with Python 3.

    Thanks to @lpugin and @ifkarp for helping to prepare this release.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Dec 18, 2014)

Owner
Distributed Digital Music Archives and Libraries Lab
Distributed Digital Music Archives and Libraries Lab
A C library for reading and writing sound files containing sampled audio data.

libsndfile libsndfile is a C library for reading and writing files containing sampled audio data. Authors The libsndfile project was originally develo

null 1.1k Dec 1, 2022
🎵 Music notation engraving library for MEI with MusicXML and Humdrum support and various toolkits (JavaScript, Python)

Verovio is a fast, portable and lightweight library for engraving Music Encoding Initiative (MEI) digital scores into SVG images. Verovio also contain

RISM Switzerland 513 Nov 28, 2022
A C library to read standard MIDI files.

A C library to read standard MIDI files.

Philip Bennefall 21 Nov 1, 2022
A very simple example showing how to play mp3 files on the ESP32

ESP32 MP3 Player This repo contains a simple demonstration of how to play an MP3 file on the ESP32. You can configure the output to be either an I2S d

atomic14 35 Nov 30, 2022
straightforward CLI tool for spectral analysis of sound files

dowser dowser is (presently) a quick and simple low-level utility for performing spectral analysis of sound files. usage dowser

ezra buchla 14 Oct 26, 2022
Library and command line backend for the Raspberry Pi OPL3 emulator and midi player

About this repository This repository holds the source code for the pioplemidi backend. You can compile it if you only want to use the library or the

iAmInAction 2 Dec 2, 2021
C++ library for audio and music analysis, description and synthesis, including Python bindings

Essentia Essentia is an open-source C++ library for audio analysis and audio-based music information retrieval released under the Affero GPL license.

Music Technology Group - Universitat Pompeu Fabra 2.2k Dec 5, 2022
C library for cross-platform real-time audio input and output

libsoundio C library providing cross-platform audio input and output. The API is suitable for real-time software such as digital audio workstations as

Andrew Kelley 1.6k Dec 2, 2022
C++ Audio and Music DSP Library

_____ _____ ___ __ _ _____ __ __ __ ____ ____ / \\_ \\ \/ / |/ \| | | | \_ \/ \ | Y Y \/ /_ \> <| | Y Y \ | |_|

Mick Grierson 1.4k Nov 26, 2022
Single file audio playback and capture library written in C.

A single file library for audio playback and capture. Example - Documentation - Supported Platforms - Backends - Major Features - Building - Unofficia

David Reid 2.5k Nov 25, 2022
a library for audio and music analysis

aubio is a library to label music and sounds. It listens to audio signals and attempts to detect events. For instance, when a drum is hit, at which frequency is a note, or at what tempo is a rhythmic melody.

aubio 2.8k Nov 29, 2022
SSMLSDL - Simple Sound Manipulation Library, Based on SDL and LIBWAV.

SSM-lib SSMLSDL - Simple Sound Manipulation Library, Based on SDL and LIBWAV. This library is open source and free software. It's aims to provide YOU,

UtoECat 1 Jan 20, 2022
Xan's NFS Music Player - Custom music player replacement and a BASS library interface for NFS.

Xan's NFS Music Player This is a custom music player replacement and a BASS library interface for NFS. FEATURES Custom playlist generation - put any n

Lovro Pleše 15 Nov 23, 2022
Single file C library for decoding MPEG1 Video and MP2 Audio

PL_MPEG - MPEG1 Video decoder, MP2 Audio decoder, MPEG-PS demuxer Single-file MIT licensed library for C/C++ See pl_mpeg.h for the documentation. Why?

Dominic Szablewski 598 Nov 30, 2022
A simple and easy-to-use audio library based on miniaudio

raudio A simple and easy-to-use audio library based on miniaudio raudio forks from raylib.audio module to become an standalone library. Actually, it w

Ray 61 Oct 5, 2022
C library for audio noise reduction and other spectral effects

libspecbleach C library for audio noise reduction and other spectral effects Background This library is based on the algorithms that were used in nois

Luciano Dato 42 Nov 18, 2022
Minimalistic MP3 decoder single header library

minimp3 Minimalistic, single-header library for decoding MP3. minimp3 is designed to be small, fast (with SSE and NEON support), and accurate (ISO con

Lion 1.2k Dec 5, 2022
highly efficient sound library for the Gameboy Advance

The Apex Audio System (AAS) is a sound library for the GBA. It includes a highly efficient mixer, MOD playing routines and support for up to 16 channels. It is designed for developers using a GCC-based development environment. AAS uses RAW, WAV or *tracker 1-16 channel MOD files as input.

Ties Stuij 33 Nov 28, 2022
A lightweight music DSP library.

Soundpipe Soundpipe is a lightweight music DSP library written in C. It aims to provide a set of high-quality DSP modules for composers, sound designe

Paul Batchelor 102 Dec 14, 2021