Loading...
Searching...
No Matches
ExecutionController.hpp
1#pragma once
2#include <Process/TimeValue.hpp>
3
4#include <score/plugins/application/GUIApplicationPlugin.hpp>
5
6#include <score_plugin_engine_export.h>
7
8#include <verdigris>
9
10#include <functional>
11#include <memory>
12namespace Scenario
13{
14class IntervalModel;
15class ScenarioDocumentModel;
16class ScenarioDocumentPresenter;
17class ScenarioApplicationPlugin;
18class TransportActions;
19}
20namespace Transport
21{
22class TransportInterface;
23}
24namespace Execution
25{
26using TransportInterface = Transport::TransportInterface;
27struct Context;
28class Clock;
29class BaseScenarioElement;
30using exec_setup_fun
31 = std::function<void(const Execution::Context&, Execution::BaseScenarioElement&)>;
32class SCORE_PLUGIN_ENGINE_EXPORT ExecutionController : public QObject
33{
34 W_OBJECT(ExecutionController)
35public:
38
39 void playStarted() E_SIGNAL(SCORE_PLUGIN_ENGINE_EXPORT, playStarted)
40 void playStopped() E_SIGNAL(SCORE_PLUGIN_ENGINE_EXPORT, playStopped)
41
42 TransportInterface& transport() const noexcept;
43 void init_transport();
44
45 TimeVal execution_time() const;
46
47 // Transport interface requests actual change to the execution.
48 // Source can be either a GUI interaction, or a control from elsewhere,
49 // e.g. JACK transport
50 void on_record(::TimeVal t);
51 void on_transport(TimeVal t);
52 void on_begin_scrub(TimeVal t);
53 void on_scrub(TimeVal t);
54 void on_end_scrub(TimeVal t);
55
56 // User requests playback to the transport interface from the local tree
57 void request_play_from_localtree(bool);
58 void request_play_global_from_localtree(bool);
59 void request_transport_from_localtree(TimeVal);
60 void request_stop_from_localtree();
61 void request_reinitialize_from_localtree();
62
63 // User requests playback to the transport interface from the GUI
64 void request_play_from_here(TimeVal t);
66 void request_play_from_here(Scenario::IntervalModel& itv, TimeVal t);
67 void request_play_global(bool);
68 void request_play_local(bool);
69 void request_play_interval(
70 Scenario::IntervalModel&, exec_setup_fun setup = {},
71 ::TimeVal t = ::TimeVal::zero());
72 void request_stop_interval(Scenario::IntervalModel&);
73 void request_stop();
74
75 void request_begin_scrub(TimeVal t);
76 void request_scrub(TimeVal t);
77 void request_end_scrub(TimeVal t);
78
79private:
80 // If the transport interface answers: these functions will "press" the Play, etc...
81 // buttons programmatically to put them in the right state, and start the playback
82 void trigger_play();
83 void trigger_pause();
84 void trigger_stop();
85 void trigger_reinitialize();
86
87 void on_audioSettingsChanged();
88 void on_play_global(bool b);
89 void on_play_local(bool b);
90
91 void play_interval(
92 Scenario::IntervalModel&, exec_setup_fun setup = {},
93 ::TimeVal t = ::TimeVal::zero());
94
95 void stop_interval(Scenario::IntervalModel&);
96 void ensure_audio_engine();
97
98 void on_play_local(bool, ::TimeVal t);
99 void on_pause();
100 void on_stop();
101
105 void on_reinitialize();
106
107 void stop_clock();
108 void send_end_state();
109 void reset_after_stop();
112 void reset_edition(Scenario::IntervalModel& base);
113
114private:
115 Scenario::ScenarioDocumentModel* currentScenarioModel();
116 Scenario::ScenarioDocumentPresenter* currentScenarioPresenter();
117 score::Document* currentDocument() const;
118 std::unique_ptr<Execution::Clock> makeClock(const Execution::Context&);
119
120 const score::GUIApplicationContext& context;
123 std::unique_ptr<Execution::Clock> m_clock;
124 Transport::TransportInterface* m_transport{};
125
126 struct IntervalToPlay
127 {
128 Scenario::IntervalModel& interval;
129 exec_setup_fun setup;
130 ::TimeVal t;
131 };
132 std::vector<IntervalToPlay> m_intervalsToPlay;
133
134 bool m_playing{false};
135 bool m_paused{false};
136 bool m_requestLocalPlay{};
137};
138}
Definition ExecutionController.hpp:33
Definition IntervalModel.hpp:50
Definition ScenarioApplicationPlugin.hpp:42
Definition ScenarioDocumentModel.hpp:29
The ScenarioDocumentPresenter class.
Definition ScenarioDocumentPresenter.hpp:60
Definition TransportActions.hpp:18
Definition TransportInterface.hpp:20
The Document class is the central part of the software.
Definition Document.hpp:51
Components used for the execution of a score.
Definition PortTap.cpp:24
Main plug-in of score.
Definition ConnectionsList.hpp:22
Definition ExecutionContext.hpp:208
Definition TimeValue.hpp:21
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15