An event to signal different actions related to visual tracking effects during score playback.
- Warning
- This event is sent to your application from the Lomse sound thread. For processing it, do not retain control: generate an application event, place it on the application events loop, and return control to Lomse.
The EventVisualTracking event, derived from EventPlayback, signals the need to do several actions related to visual tracking effects during score playback. It contains a list of sub-events and affected objects:
- k_highlight_on. Add highlight to a note/rest.
- k_highlight_off. Remove highlight from a note/rest.
- k_end_of_visual_tracking. End of score playback. Remove all visual tracking effects.
- k_move_tempo_line. Advance visual tempo line to next beat.
For handling all events related to score playback it is very important to return control to Lomse as soon as possible. This is because, currently, Lomse does not implement an event subsystem with its own thread. Instead Lomse sends events to your application by invoking a callback. This implies that your application code for handling the event is processed by the Lomse sound thread. As this thread is dealing with sound generation, your application must return control to Lomse as soon as possible, so that the sound thread can continue processing sound events. Otherwise, sound can be stalled! The suggested way for handling EventVisualTracking events is to generate an application event and to enqueue it in the application events system.
For instance, in an application written using the wxWidgets framework you could have a global method for receiving all Lomse events, convert them in application events, and return control to Lomse:
void MainFrame::on_lomse_event(SpEventInfo pEvent)
{
DocumentWindow* pCanvas = get_active_document_window();
switch (pEvent->get_event_type())
{
{
if (pCanvas)
{
static_pointer_cast<EventVisualTracking>(pEvent) );
MyVisualTrackingEvent event(pEv);
::wxPostEvent(pCanvas, event);
}
break;
}
...
Later, your application will just process the application event as convenient. The recommended action is to use the Interactor for requesting to process the event and update the rendering bitmap. For instance:
void DocumentWindow::on_visual_tracking(MyVisualTrackingEvent& event)
{
WpInteractor wpInteractor = pEv->get_interactor();
if (SpInteractor sp = wpInteractor.lock())
sp->on_visual_tracking(pEv);
}