Lomse library. API documentation
0.30.0
|
In summary:
Lomse has no knowledge about your platform native components, windows, or ways of doing things, such as how to produce sounds. Therefore, Lomse does not have methods for doing things such as creating windows or printing documents.
Lomse aims at not constraining your application. Lomse provides all the necessary services (i.e. for reading documents, rendering and editing them, and for playing back scores). But the interface with the user (i.e. the window on which the document is going to be rendered, or the sound engine for producing the sounds) must be provided by your application. Your application is responsible for the presentation and interaction layer. You can use Lomse in any context: interactive programs with a GUI, batch scripts for processing music scores, etc.
For understanding Lomse API you should know about a very few important classes and components described in the following sections.
LomseDoorway is the access point to the Lomse library and the main interface with the library. It must be used by your application at two points:
Details about Lomse initialization can be found in Lomse library initialization.
Class Document represents a document with any kind of content: music scores, texts, paragraphs, images, tables, lists, etc. Documents are created by invoking LomseDoorway::new_document() and LomseDoorway::open_document() methods.
Documents can be created from scratch or by importing scores from files in MusicXML format or in other currently supported formats (see File formats supported by Lomse).
When a Document is created, additional objects for marshaling the actions between your application and the Document are created. These additional objects are part of the Lomse Model-View-Controller (MVC) architecture. The main objects associated to a Document are:
All these issues are described in The Lomse Model-View-Controller.
Lomse is platform independent code and knows nothing about how to create a window or how to display a document on the screen. Lomse works by rendering the documents on a bitmap buffer, that is, on an array of consecutive memory bytes. This buffer can be any type of memory, such as a real bitmap, a window's buffer, etc. The simplest and usual way of rendering documents on a window is:
These operations are usually triggered by your application when handling some operating system events, such as window paint events.
The details and methods you have to use for displaying documents are described in Rendering documents overview.
As Lomse is platform independent code, it knows nothing about how to print in the operating system used by your application. Therefore, it is your application responsibility to implement printing. Lomse just offers some supporting methods so that implementing printing does not require much work. In fact, implementing printing in your application is just printing bitmaps.
The details and methods you have to use for printing are described in Printing documents overview.
Lomse export documents as strings in MusicXML format or LDP format. But currently Lomse does not include facilities for writing files (although this is planned for future). Therefore, for now it is responsibility of your application to save in a file the source code string provided by Lomse. See Saving and exporting documents.
Editing documents in Lomse is very simple: just invoke Interactor::exec_command() method and pass the command to execute, e.g. insert note or delete paragraph.
Lomse supports undo/redo operations and takes care of all the houskeeping for this. In your application just invoke:
Most edition commands require a reference point in the document. For this, Lomse maintains two objects: a Cursor and a set of selected objects (the SelectionSet object).
For moving the cursor to another position and for selecting or deselecting objects your application just issue specific edition commands, such as advance cursor, move cursor to start of score or select object.
And this is, basically, the document edition API. It is very simple and gives full freedom to your application for implementing the GUI as you'd like, or for not a having a GUI! For more details see Editing documents overview.
Lomse is platform independent code and cannot generate sounds for your specific platform. Therefore, lomse implements playback by generating real-time events and sending them to your application. It is responsibility of your application to handle these events and do whatever is needed, i.e. transform sound events into real sounds or doing whatever you would like with the sound events.
The details and classes you have to use for scores playback are described in Scores playback overview.