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 <functional>
9#include <memory>
10namespace Scenario
11{
12class IntervalModel;
13class ScenarioDocumentModel;
14class ScenarioDocumentPresenter;
15class ScenarioApplicationPlugin;
16class TransportActions;
17}
18namespace Transport
19{
20class TransportInterface;
21}
22namespace Execution
23{
24using TransportInterface = Transport::TransportInterface;
25struct Context;
26class Clock;
27class BaseScenarioElement;
28using exec_setup_fun
29 = std::function<void(const Execution::Context&, Execution::BaseScenarioElement&)>;
30class SCORE_PLUGIN_ENGINE_EXPORT ExecutionController : public QObject
31{
32public:
35
36 TransportInterface& transport() const noexcept;
37 void init_transport();
38
39 TimeVal execution_time() const;
40
41 // Transport interface requests actual change to the execution.
42 // Source can be either a GUI interaction, or a control from elsewhere,
43 // e.g. JACK transport
44 void on_record(::TimeVal t);
45 void on_transport(TimeVal t);
46 void on_begin_scrub(TimeVal t);
47 void on_scrub(TimeVal t);
48 void on_end_scrub(TimeVal t);
49
50 // User requests playback to the transport interface from the local tree
51 void request_play_from_localtree(bool);
52 void request_play_global_from_localtree(bool);
53 void request_transport_from_localtree(TimeVal);
54 void request_stop_from_localtree();
55 void request_reinitialize_from_localtree();
56
57 // User requests playback to the transport interface from the GUI
58 void request_play_from_here(TimeVal t);
59 void request_play_global(bool);
60 void request_play_local(bool);
61 void request_play_interval(
62 Scenario::IntervalModel&, exec_setup_fun setup = {},
63 ::TimeVal t = ::TimeVal::zero());
64 void request_stop_interval(Scenario::IntervalModel&);
65 void request_stop();
66
67 void request_begin_scrub(TimeVal t);
68 void request_scrub(TimeVal t);
69 void request_end_scrub(TimeVal t);
70
71private:
72 // If the transport interface answers: these functions will "press" the Play, etc...
73 // buttons programmatically to put them in the right state, and start the playback
74 void trigger_play();
75 void trigger_pause();
76 void trigger_stop();
77 void trigger_reinitialize();
78
79 void on_play_global(bool b);
80 void on_play_local(bool b);
81
82 void play_interval(
83 Scenario::IntervalModel&, exec_setup_fun setup = {},
84 ::TimeVal t = ::TimeVal::zero());
85
86 void stop_interval(Scenario::IntervalModel&);
87 void ensure_audio_engine();
88
89 void on_play_local(bool, ::TimeVal t);
90 void on_pause();
91 void on_stop();
92
96 void on_reinitialize();
97
98 void stop_clock();
99 void send_end_state();
100 void reset_after_stop();
101 void reset_edition();
102
103private:
104 Scenario::ScenarioDocumentModel* currentScenarioModel();
105 Scenario::ScenarioDocumentPresenter* currentScenarioPresenter();
106 score::Document* currentDocument() const;
107 std::unique_ptr<Execution::Clock> makeClock(const Execution::Context&);
108
109 const score::GUIApplicationContext& context;
112 std::unique_ptr<Execution::Clock> m_clock;
113 Transport::TransportInterface* m_transport{};
114
115 struct IntervalToPlay
116 {
117 Scenario::IntervalModel& interval;
118 exec_setup_fun setup;
119 ::TimeVal t;
120 };
121 std::vector<IntervalToPlay> m_intervalsToPlay;
122
123 bool m_playing{false};
124 bool m_paused{false};
125 bool m_requestLocalPlay{};
126};
127}
Definition ExecutionController.hpp:31
Definition IntervalModel.hpp:50
Definition ScenarioApplicationPlugin.hpp:42
Definition ScenarioDocumentModel.hpp:29
The ScenarioDocumentPresenter class.
Definition ScenarioDocumentPresenter.hpp:58
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 ProcessComponent.cpp:14
Main plug-in of score.
Definition score-plugin-dataflow/Dataflow/PortItem.hpp:13
Definition ExecutionContext.hpp:196
Definition TimeValue.hpp:21
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15