lenmus / lomse

A C++ library for rendering, editing and playing back music scores.
MIT License
120 stars 28 forks source link

[REQUEST] C# bindings #65

Open jamescauwelier opened 7 years ago

jamescauwelier commented 7 years ago

I just started with C# development, so unless I am unaware of how to do this I think I cannot use Lomse directly in a C# project. Therefore I would like to request a C# wrapper be provided for this and maybe other languages (in the future).

I have no knowledge of C++ but am willing to contribute if I receive some help. Otherwise I fear I'd be loosing a lot of time and be stuck all the time. SWIG seems to automate the process somewhat, so maybe that's an option to consider?

cecilios commented 7 years ago

I neither have knowledge of C# nor of creating a wrapper for it. But I'm willing to help to create this wrapper. My first impression of SWIG is that it can solve the problem without much work, just defining an interface file with the headers.

My only concern is that, probably, not all lomse header files should be included in the interface, as most of the methods and classes are not intended for a 'normal' use of the library.

The problem, then is to define the public API and this is not easy. The API for just displaying scores, playing then, and printing is currently identified. The API for edition is also quite defined. But the API for direct creation and manipulation of the Lomse internal models is not yet defined (and I'm not sure if this should be allowed, but can be useful in some scenarios).

I'm going to study a little about SWIG and building a wrapper for C#.

jamescauwelier commented 7 years ago

Great news! How about a little experiment with a well defined part then instead of tackling it all at once? I am mostly interested in displaying and playing scores. If you give me enough pointers I might be able to help as this is relatively urgent for me. I gladly invest some of the time your library saves me to give back to the community.

jamescauwelier commented 7 years ago

Also, I definitely support your idea of only exposing what is necessary.

cecilios commented 7 years ago

You say that this is wrapper relatively urgent for you. I will try to help to achieve this wrapper as soon as possible.

But, I would like to be sure that you are aware that Lomse is still a work in progress. Currently, simple scores can be displayed (by 'simple' I mean scores with few notation symbols, mainly scores with just notes, rests slurs and ties). Accents, dynamics marks and other notation is supported but layout and automatic positioning of these symbols is not yet as good as it should be. More features can be added, normally with few effort, unless they require to develop algorithms to avoid layout conflicts. Playback is also available but currently does not support repetitions.

I'm willing to help by giving priority to Lomse features that could be needed. But please ensure that Lomse could satisfy your needs before investing much work on this, specially if your project has deadlines.

As you say that you are mostly interested in displaying and playing scores, I suggest that first experiment with the C# wrapper could be the interface for displaying scores. For this, if you would like to start experimenting, the necessary include files are:

#include <lomse_doorway.h>
#include <lomse_document.h>
#include <lomse_graphic_view.h>
#include <lomse_interactor.h>
#include <lomse_presenter.h>
#include <lomse_events.h>

Meanwhile, I'm going to try to get access to a Windows machine and study a little more about SWIG and about C# wrappers.

jamescauwelier commented 7 years ago

At the moment I need only simple scores but that could change if my prototype gets me some funding. There's very little libraries around for music notation or they're in a language I can't use or have requirements that I can't satisfy (e.g. HTML canvas in js libraries).

On the other hand it seems crazy to start making my own and duplicating the effort.

Initially I started with Lomse in an attempt to verify if it can satisfy my needs, but that is taking more time than I thought it would. For a prototype I could create something simple myself and when I have more resources investigate if I can join your project in order to provide wrappers and make the project itself more mature. But I think we need to postpone that decision given my deadlines.

cecilios commented 7 years ago

Yes! It woud be a lot of work to start making your own solution for displaying music scores, unless you have plenty of time or a good full time pay development team! Dealing with music scores is much hard that one can imagine. Layout algorithms can become incredible complex. If you are in a hurry, better try to find something already built. As your requirement exclude Java, perhaps any of these projects could satisfy your needs:

Anyway, I will continue studying this idea of a C# wrapper for developing a C# Lomse sample.

jamescauwelier commented 7 years ago

Nr. 2 and 3 are both quite expensive for commercial use although the demo is not really commercial. I've seen them in my search and their documentation is very lacking unfortunately.

Verovio is new to me, so I'll check it out.