Lomse library. API documentation
0.30.0
|
#include <lomse_doorway.h>
LomseDoorway is the main interface with the Lomse library. This class represent the gate between Lomse and your application:
Public Member Functions | |
LomseDoorway (std::ostream *logStream=nullptr, std::ostream *forensicLogStream=nullptr) | |
Library initialization and configuration | |
void | init_library (int pixel_format, int ppi, std::ostream &reporter=std::cout) |
void | set_notify_callback (void *pThis, void(*pt2Func)(void *, SpEventInfo)) |
void | set_request_callback (void *pThis, void(*pt2Func)(void *, Request *)) |
void | set_default_fonts_path (const std::string &fontsPath) |
double | get_screen_ppi () |
int | get_pixel_format () |
Document creation methods | |
Presenter * | new_document (int viewType, Drawer *screenDrawer=nullptr, Drawer *printDrawer=nullptr) |
Presenter * | new_document (int viewType, const std::string &source, int format, std::ostream &reporter=std::cout, Drawer *screenDrawer=nullptr, Drawer *printDrawer=nullptr) |
Presenter * | open_document (int viewType, const std::string &filename, std::ostream &reporter=std::cout, Drawer *screenDrawer=nullptr, Drawer *printDrawer=nullptr) |
Presenter * | open_document (int viewType, LdpReader &reader, std::ostream &reporter=std::cout, Drawer *screenDrawer=nullptr, Drawer *printDrawer=nullptr) |
Playback related methods | |
void | set_global_metronome_and_replace_local (Metronome *pMtr) |
Library information | |
std::string | get_version_string () |
std::string | get_version_long_string () |
std::string | get_build_date () |
int | get_version_major () |
int | get_version_minor () |
int | get_version_patch () |
Other methods | |
MusicXmlOptions * | get_musicxml_options () |
LibraryScope * | get_library_scope () |
|
explicit |
Constructor. Your application should create only one instance of LomseDoorway and its life scope should be as long as your application need to use Lomse.
std::string LomseDoorway::get_build_date | ( | ) |
Returns the build date and time of the Lomse library. The string is twenty characters long and looks like "12-Feb-2016 17:54:03". Date and time are separated by one space. Date is in format dd-mm-yyyy and time in format hh:mm:ss. Day, hour, minutes and seconds are always padded with zero if only one digit e.g., "02-Mar-2016 07:54:03"
|
inline |
Get the pointer to an object of class LibraryScope. This object gives access to all Lomse global functions and information.
MusicXmlOptions* LomseDoorway::get_musicxml_options | ( | ) |
Returns the current options object with the settings to use for dealing and fixing errors and malformed MusicXML files. The import options can be changed multiple times, whenever it is needed. For example:
|
inline |
Returns settings for rendering bitmap format. This is the value set when method init_library() was called. The meaning of the returned value is given by enum EPixelFormat.
|
inline |
Returns settings for rendering bitmap resolution. This is the value set when method init_library() was called.
std::string LomseDoorway::get_version_long_string | ( | ) |
Returns Lomse version and build information as string. e.g., "0.17.20+aaf5e23"
int LomseDoorway::get_version_major | ( | ) |
Returns Lomse major version as integer number. For instance, if version string is "0.17.20" this method will return 0.
int LomseDoorway::get_version_minor | ( | ) |
Returns Lomse minor version as integer number. For instance, if version string is "0.17.20" this method will return 17.
int LomseDoorway::get_version_patch | ( | ) |
Returns Lomse patch version as integer number. For instance, if version string is "0.17.20" this method will return 20.
std::string LomseDoorway::get_version_string | ( | ) |
Returns Lomse version as string "major.minor.patch" e.g., "0.17.20"
void LomseDoorway::init_library | ( | int | pixel_format, |
int | ppi, | ||
std::ostream & | reporter = std::cout |
||
) |
Before using the library, method init_library() should be invoked for initializing the library and providing the necessary information. As Lomse renders scores and documents on a bitmap it is necessary to inform Lomse about the required bitmap properties. Also, you can set an ostream to be used by Lomse for reporting errors.
Initialization is not required if your application will not use Lomse to render scores in bitmaps, e.g.: uses it only for playback or only renders SVG code. In these cases any values for pixel format and resolution will be valid and so, default values are enough and you will not have to invoke this method.
pixel_format | A value from the global enumeration type EPixelFormat |
ppi | The display resolution in pixels per inch (e.g. 96). Lomse uses vectorial graphics for all, typography included and, thus, screen resolution is no required and your application can always scale the image to as much resolution as you like. The real resolution is determined by the provided bitmap size (pixels) to be used as rendering buffer. Nevertheless, Lomse requires a screen resolution value to adjust internal scaling factors so that when the user scale is set to 1.0 (100%) the document get displayed on the screen at real size. If this is not a requirement for your application, any value can be used (e.g. 72 or 96). |
reporter | The ostream to be used by Lomse for reporting errors. By default, all errors will be send to cout. |
For instance, assume we are writing an application for Linux to display scores on screen:
Presenter* LomseDoorway::new_document | ( | int | viewType, |
Drawer * | screenDrawer = nullptr , |
||
Drawer * | printDrawer = nullptr |
||
) |
Create a new empty document, as well as a View for rendering it and all additional components (Interactor, Presenter, etc.) necessary for managing this document and interacting with it. Optionally, default BitmapDrawer objects used by Lomse can be replaced by any Drawer objects created by your application.
viewType | The view type that will be used for rendering this document. |
screenDrawer | The Drawer to use as main drawer. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
printDrawer | The Drawer to use for printing. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
Presenter* LomseDoorway::new_document | ( | int | viewType, |
const std::string & | source, | ||
int | format, | ||
std::ostream & | reporter = std::cout , |
||
Drawer * | screenDrawer = nullptr , |
||
Drawer * | printDrawer = nullptr |
||
) |
Create a new document initialized with the passed content. Also creates a View for rendering it as well as all additional components (Interactor, Presenter, etc.) necessary for managing this document and interacting with it. Optionally, default BitmapDrawer objects used by Lomse can be replaced by any Drawer objects created by your application.
viewType | The view type that will be used for rendering this document. |
source | A string with the content for the document to create. |
format | A value specifying the format for the source content. Valid values are defined in Document class. Valid values are:
|
reporter | The ostream to be used for reporting any errors. By default, all errors will be send to cout. |
screenDrawer | The Drawer to use as main drawer. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
printDrawer | The Drawer to use for printing. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
Presenter* LomseDoorway::open_document | ( | int | viewType, |
const std::string & | filename, | ||
std::ostream & | reporter = std::cout , |
||
Drawer * | screenDrawer = nullptr , |
||
Drawer * | printDrawer = nullptr |
||
) |
Open a document. Its content is read from a file. Also creates a View for rendering it as well as all additional components (Interactor, Presenter, etc.) necessary for managing this document and interacting with it. Optionally, default BitmapDrawer objects used by Lomse can be replaced by any Drawer objects created by your application. Optionally, default BitmapDrawer objects used by Lomse can be replaced by any Drawer objects created by your application.
viewType | The view type that will be used for rendering this document. |
filename | A string with the absolute path to the file containing the document. |
reporter | The ostream to be used for reporting any errors. By default, all errors will be send to cout. |
screenDrawer | The Drawer to use as main drawer. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
printDrawer | The Drawer to use for printing. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
Presenter* LomseDoorway::open_document | ( | int | viewType, |
LdpReader & | reader, | ||
std::ostream & | reporter = std::cout , |
||
Drawer * | screenDrawer = nullptr , |
||
Drawer * | printDrawer = nullptr |
||
) |
Open a document. Its content is provided by an LdpReader object. Also creates a View for rendering it as well as all additional components (Interactor, Presenter, etc.) necessary for managing this document and interacting with it. Optionally, default BitmapDrawer objects used by Lomse can be replaced by any Drawer objects created by your application.
viewType | The view type that will be used for rendering this document. |
reader | An object of class LdpReader that will be used for reading the content of the document. |
reporter | The ostream to be used for reporting any errors. By default, all errors will be send to cout. |
screenDrawer | The Drawer to use as main drawer. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
printDrawer | The Drawer to use for printing. Ownership of this Drawer is transferred to the View. You must not delete it. If not specified or nullptr a BitmapDrawer will be used. |
void LomseDoorway::set_default_fonts_path | ( | const std::string & | fontsPath | ) |
Method set_default_fonts_path() is used for informing Lomse about the path in which additional fonts are installed. Default fonts used by Lomse are located in folders known by Lomse, but Lomse has no knowledge about where the additional fonts the user would like to use are located. They are probably in the folder used by the operating system for fonts. But as Lomse is platform independent, currently it has no knowledge about operating system folders for fonts. Therefore, applications using additional fonts other than Lomse default fonts should use this method for informing Lomse about the path for the fonts.
fontsPath | Absolute path to the fonts folder in which Lomse will look for fonts other than Lomse default fonts. Please note that Lomse will not look into sub-folders in the passed path. |
void LomseDoorway::set_global_metronome_and_replace_local | ( | Metronome * | pMtr | ) |
This method is used for informing Lomse about the metronome control to use to determine tempo in playback. By default, Lomse takes metronome settings from ?. But your application can specify another metronome control, normally a global metronome for the all your application.
pMtr | Pointer to the Metronome object to be used. |
void LomseDoorway::set_notify_callback | ( | void * | pThis, |
void(*)(void *, SpEventInfo) | pt2Func | ||
) |
This method is used by for informing Lomse about the callback method that Lomse should invoke when having to communicate an event to your application.
pThis | A pointer to the instance of object that will receive the notifications. |
pt2Func | A pointer to the method in previous object that Lomse will invoke when an event is generated in Lomse. |
For example, to prepare our application for handling visual tracking events during score playback we could define a callback method:
And inform lomse about it. We do it at lomse initialization:
void LomseDoorway::set_request_callback | ( | void * | pThis, |
void(*)(void *, Request *) | pt2Func | ||
) |
This method is used by for informing Lomse about the callback method that Lomse should invoke when having to request information to your application. See Request, RequestDynamic, RequestFont
pThis | A pointer to the instance of object that will receive the notifications. |
pt2Func | A pointer to the method in previous object that Lomse will invoke when a requests is generated in Lomse. |
See How Lomse callbacks work for an explanation of Lomse callbacks and its parameters.
For example:
And inform lomse about it. We do it at lomse initialization: