11namespace tracktion {
inline namespace engine
15 : state (v), edit (sl.edit), sceneList (sl)
17 assert (v.hasType (IDs::SCENE));
20 name.
referTo (state, IDs::name, um);
21 colour.
referTo (state, IDs::colour, um);
28 notifyListenersOfDeletion();
38 return TRANS(
"Scene");
46 if (i == IDs::name || i == IDs::colour)
52 : scenesState (scenesState_), edit (e)
68void SceneWatcher::checkForScenes()
80SceneWatcher::RecordingState SceneWatcher::getRecordingState (ClipSlot& slot)
82 auto dest = slot.getInputDestination();
84 if (dest && dest->input.isRecording (dest->targetID))
86 auto epc = dest->input.edit.getTransport().getCurrentPlaybackContext();
87 const auto currentTime = epc ? epc->getUnloopedPosition() : dest->input.edit.getTransport().getPosition();
89 if (currentTime < dest->input.getPunchInTime (dest->targetID))
90 return RecordingState::pending;
92 return RecordingState::recording;
94 return RecordingState::none;
97void SceneWatcher::timerCallback()
102 auto itr = lastStates.
find (key);
104 if (itr == lastStates.
end())
106 lastStates[key] = { callback, p, q, r };
107 listeners.call ([trackIdx, slotIdx] (Listener& l) { l.slotUpdated (trackIdx, slotIdx); });
109 else if (itr->second.playState != p || itr->second.queueState != q || itr->second.recordingState != r)
111 itr->second.lastSeen = callback;
112 itr->second.playState = p;
113 itr->second.queueState = q;
114 itr->second.recordingState = r;
115 listeners.call ([trackIdx, slotIdx] (Listener& l) { l.slotUpdated (trackIdx, slotIdx); });
119 itr->second.lastSeen = callback;
129 for (
auto slot : at->getClipSlotList().getClipSlots())
131 if (
auto r = getRecordingState (*slot); r != RecordingState::none)
133 update (trackIdx, slotIdx, LaunchHandle::PlayState::stopped, {}, r);
135 else if (
auto c = slot->getClip())
137 if (
auto lh = c->getLaunchHandle())
139 auto p = lh->getPlayingStatus();
140 auto q = lh->getQueuedStatus();
142 update (trackIdx, slotIdx, p, q, r);
152 for (
auto itr = lastStates.
cbegin(); itr != lastStates.
cend();)
154 if (itr->second.lastSeen != callback)
156 listeners.call ([itr] (Listener& l) { l.slotUpdated (itr->first.first, itr->first.second); });
157 lastStates.
erase (itr++);
170 if (p == scenesState && c.hasType (IDs::SCENE))
176 if (p == scenesState && c.hasType (IDs::SCENE))
188 assert (parent.hasType (IDs::SCENES));
205 for (
int i = size(); i < numScenes; ++i)
208 assert (objects.size() >= numScenes);
211 at->getClipSlotList().ensureNumberOfSlots (objects.size());
219 at->getClipSlotList().insertSlot (idx);
227 const int index = parent.indexOf (scene.state);
232 auto& csl = at->getClipSlotList();
233 auto cs = csl.getClipSlots()[index];
236 if (
auto clip = cs->getClip())
237 clip->removeFromParent();
239 csl.deleteSlot (*csl.getClipSlots()[index]);
246 return v.hasType (IDs::SCENE);
251 return new Scene (v, *
this);
254void SceneList::deleteObject (Scene* scene)
259void SceneList::newObjectAdded (Scene*)
263void SceneList::objectRemoved (Scene*)
267void SceneList::objectOrderChanged()
int indexOf(ParameterType elementToLookFor) const
void referTo(ValueTree &tree, const Identifier &property, UndoManager *um)
void stopTimer() noexcept
void startTimerHz(int timerFrequencyHz) noexcept
bool isTimerRunning() const noexcept
int getNumChildren() const noexcept
void addListener(Listener *listener)
The Tracktion Edit class!
juce::UndoManager & getUndoManager() noexcept
Returns the juce::UndoManager used for this Edit.
Represents the Scenes in an Edit.
void deleteScene(Scene &)
Deletes a specific Scene.
juce::Array< Scene * > getScenes()
Returns the Scenes in the Edit.
void ensureNumberOfScenes(int numScenes)
Adds Scenes to ensure numScenes are preset in the list.
Scene * insertScene(int index)
Inserts a new scene with the given index.
Edit & edit
The Edit this SceneList belongs to.
~SceneList() override
Destructor.
SceneList(const juce::ValueTree &, Edit &)
Creates a SceneList for an Edit with a given state.
void removeListener(Listener *)
Removes a previously added Listener.
SceneWatcher(const juce::ValueTree &scenesState, Edit &)
Creates a SceneWatcher.
void addListener(Listener *)
Adds a Listener.
A Scene is a collection of ClipSlots across tracks.
~Scene() override
Destructor.
Scene(const juce::ValueTree &, SceneList &)
Creates a Scene for a given state.
juce::String getSelectableDescription() override
Subclasses must return a description of what they are.
virtual void changed()
This should be called to send a change notification to any SelectableListeners that are registered wi...
#define TRANS(stringLiteral)
juce::Array< AudioTrack * > getAudioTracks(const Edit &edit)
Returns all the AudioTracks in an Edit.