Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
session.h
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19#include "definitions_cxx.hpp"
20#include "gui/colour/colour.h"
21#include "playback/mode/playback_mode.h"
22
23class InstrumentClip;
24class Clip;
26class ModelStack;
27enum class LaunchStatus;
28
29#define SECTION_OUT_OF_RANGE 254
30#define REALLY_OUT_OF_RANGE 255
31#define LAUNCH_EXCLUSIVE -2
32#define LAUNCH_NON_EXCLUSIVE -1
33#define LAUNCH_REPEAT_INFINITELY 0
34#define LAUNCH_REPEAT_ONCE 1
35
36class Session final : public PlaybackMode {
37public:
38 Session();
39
40 void armAllClipsToStop(int32_t afterNumRepeats);
41 void armNextSection(int32_t oldSection, int32_t numRepetitions = -1);
42 void doLaunch(bool isFillLaunch);
43 void scheduleLaunchTiming(int64_t atTickCount, int32_t numRepeatsUntil, int32_t armedLaunchLengthForOneRepeat);
44 int32_t getNumSixteenthNotesRemainingTilLaunch();
45 void scheduleFillEvent(Clip* clip, int64_t atTickCount);
46 void cancelAllLaunchScheduling();
47 void launchSchedulingMightNeedCancelling();
48 void reSyncClipToSongTicks(Clip* clip);
49 void reSyncClip(ModelStackWithTimelineCounter* modelStack, bool mustSetPosToSomething = false,
50 bool mayResumeClip = true) override;
51 void userWantsToUnsoloClip(Clip* clip, bool forceLateStart, int32_t buttonPressLatency);
52 void toggleClipStatus(Clip* clip, int32_t* clipIndex, bool doInstant, int32_t buttonPressLatency);
53 void soloClipAction(Clip* clip, int32_t buttonPressLatency);
54 void armSection(uint8_t section, int32_t buttonPressLatency);
55 void armingChanged();
56 void userWantsToArmClipsToStartOrSolo(uint8_t section, Clip* clip, bool stopAllOtherClips,
57 bool forceLateStart = false, bool allowLateStart = true,
58 int32_t numRepeatsTilLaunch = 1, bool allowSubdividedQuantization = true,
59 ArmState armState = ArmState::ON_NORMAL);
60 LaunchStatus investigateSyncedLaunch(Clip* waitForClip, uint32_t* currentPosWithinQuantization,
61 uint32_t* quantization, uint32_t longestStartingClipLength,
62 bool allowSubdividedQuantization);
63 bool armForSongSwap();
64 bool armForSwitchToArrangement();
65 void armClipsToStartOrSoloWithQuantization(uint32_t pos, uint32_t quantization, uint8_t section,
66 bool stopAllOtherClips, Clip* clip, bool forceLateStart,
67 bool allowLateStart, int32_t numRepeatsTilLaunch,
68 ArmState armState = ArmState::ON_NORMAL);
69 void armClipToStartOrSoloUsingQuantization(Clip* thisClip, bool doLateStart, uint32_t pos,
70 ArmState armState = ArmState::ON_NORMAL,
71 bool mustUnarmOtherClipsWithSameOutput = true);
72 void cancelAllArming();
73 void armClipLowLevel(Clip* loopableToArm, ArmState armState, bool mustUnarmOtherClipsWithSameOutput = true);
74 int32_t userWantsToArmNextSection(int32_t numRepetitions = -1);
75 int32_t getCurrentSection();
76 bool areAnyClipsArmed();
77 void unsoloClip(Clip* clip);
78 void soloClipRightNow(ModelStackWithTimelineCounter* modelStack);
79 bool deletingClipWhichCouldBeAbandonedOverdub(Clip* clip);
80 void scheduleOverdubToStartRecording(Clip* overdub, Clip* clipAbove);
81 void justAbortedSomeLinearRecording();
82
83 // PlaybackMode implementation
84 void setupPlayback() override;
85 bool endPlayback() override; // Returns whether to do an instant song swap
86 void doTickForward(int32_t posIncrement) override;
87 void resetPlayPos(int32_t newPos, bool doingComplete = true, int32_t buttonPressLatency = 0) override;
88 void resyncToSongTicks(Song* song) override;
89 void reversionDone() override;
90 bool isOutputAvailable(Output* output) override;
91 bool considerLaunchEvent(int32_t numTicksBeingIncremented) override; // Returns whether Song was swapped
92 void stopOutputRecordingAtLoopEnd() override;
93 int32_t getPosAtWhichClipWillCut(ModelStackWithTimelineCounter const* modelStack) override;
94 bool willClipContinuePlayingAtEnd(ModelStackWithTimelineCounter const* modelStack) override;
95 bool willClipLoopAtSomePoint(ModelStackWithTimelineCounter const* modelStack) override;
96 bool wantsToDoTempolessRecord(int32_t newPos) override;
97
98 uint8_t lastSectionArmed; // 255 means none. 254 means the action was switch-off-all-sections
99 uint32_t timeLastSectionPlayed;
100
101 int64_t launchEventAtSwungTickCount;
102 int16_t numRepeatsTilLaunch;
103 int32_t currentArmedLaunchLengthForOneRepeat;
104 bool switchToArrangementAtLaunchEvent;
105
106private:
107 bool giveClipOpportunityToBeginLinearRecording(Clip* clip, int32_t clipIndex, int32_t buttonPressLatency);
108 void armClipToStopAction(Clip* clip);
109 void cancelArmingForClip(Clip* clip, int32_t* clipIndex);
110 void armSectionWhenNeitherClockActive(ModelStack* modelStack, int32_t section, bool stopAllOtherClips);
111 void armClipsAlongWithExistingLaunching(ArmState armState, uint8_t section, Clip* clip);
112 void armClipsWithNothingToSyncTo(uint8_t section, Clip* clip);
113 void scheduleFillClip(Clip* clip);
114 void scheduleFillClips(uint8_t section);
115};
116
117extern Session session;
118extern const deluge::gui::colours::Colour defaultClipSectionColours[];
Definition clip.h:46
Definition instrument_clip.h:48
Definition model_stack.h:129
Definition model_stack.h:123
Definition output.h:81
Definition session.h:36
void doLaunch(bool isFillLaunch)
Definition session.cpp:270
void scheduleFillClips(uint8_t section)
Definition session.cpp:1924
void scheduleFillClip(Clip *clip)
Definition session.cpp:1856
Definition song.h:104