Giter Club home page Giter Club logo

xsdcxx-musicxml's Introduction

XSDCXX based MusicXML bindings for C++

xsdcxx-musicxml is a MusicXML binding for C++11 based on xsdcxx. The bulk of the source code is automatically generated from the MusicXML W3C XML Schema Definition (XSD). Parsing, manipulation, and serialization of MusicXML documents is supported.

This library handles both, partwise and timewise MusicXML documents in a uniform way. Client code is free to work with either of the two object models, and MusicXML documents are automatically converted to the requested format during parsing.

auto timewise = musicxml::parse<musicxml::score_timewise>(std::cin, "-");
for (auto &measure: timewise.measure()) {
  for (auto &part: measure.part()) {
    std::clog << measure.number() << ": " << part.id()->part_name()
              << std::endl;
    //...
  }
}
musicxml::serialize(std::cout, timewise);

or

auto partwise = musicxml::parse<musicxml::score_partwise>(std::cin, "-");
for (auto &part: partwise.part()) {
  for (auto &measure: part.measure()) {
    std::clog << part.id()->part_name() << ": " << measure.number()
              << std::endl;
    //...
  }
}
musicxml::serialize(std::cout, partwise);

Alternatively, if you want to save to a different format as you have worked with, you can use the musicxml::convert function to flip formats:

// Serialize a score-partwise document.
musicxml::serialize(std::cout, musicxml::convert(timewise));

Both, musicxml::score_partwise::part_type::measure_type and musicxml::score_timewise::measure_type::part_type use boost::variant to store the different allowed element types in a heterogeneous container. This container can be accessed and set with the music_data() accessors, and its type is available as member type music_data_sequence.

IDREF attributes are configured to point directly to the referenced element type(s). Some IDREF's are optional though, so be sure to not dereference those unconditionally.

Building

CMake and XSDCXX are required to build this library.

See generate.cpp, partiwse.cpp and timewise.cpp for very simple usage examples.

To use this library in your project,

#include "xsdcxx-musicxml/musicxml.hpp"

and link with the xsdcxx-musicxml library. If you prefer static linking, use xsdcxx-musicxml-static.

You can also use the CMake ADD_SUBDIRECTORY command to directly include this library as a subproject in your CMake based project.

Parent project

This library is being developed as a sub-project of BMC, the Braille Music Compiler.

xsdcxx-musicxml's People

Contributors

mlang avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  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.