71class InstrumentClipView final :
public ClipView,
public InstrumentClipMinder {
74 bool opened()
override;
75 void focusRegained()
override;
76 void displayOrLanguageChanged()
final;
80 ActionResult buttonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine)
override;
81 ActionResult handleScaleButtonAction(
bool on,
bool inCardRoutine);
85 ActionResult padAction(int32_t x, int32_t y, int32_t velocity)
override;
86 ActionResult potentiallyRandomizeDrumSamples();
87 ActionResult potentiallyRandomizeDrumSample(
Kit* kit,
Drum* drum,
char* chosenFilename);
107 uint8_t getEditPadPressXDisplayOnScreen(uint8_t yDisplay);
108 void editPadAction(
bool state, uint8_t yDisplay, uint8_t xDisplay, uint32_t xZoom);
109 void mutePadPress(uint8_t yDisplay);
110 bool ensureNoteRowExistsForYDisplay(uint8_t yDisplay);
111 void recalculateColours();
112 void recalculateColour(uint8_t yDisplay);
113 ActionResult scrollVertical(int32_t scrollAmount,
bool inCardRoutine,
bool shiftingNoteRow =
false);
114 void reassessAllAuditionStatus();
115 void reassessAuditionStatus(uint8_t yDisplay);
116 uint8_t getVelocityForAudition(uint8_t yDisplay, uint32_t* sampleSyncLength);
117 uint8_t getNumNoteRowsAuditioning();
118 uint8_t oneNoteAuditioning();
119 void offsetNoteCodeAction(int32_t newOffset);
120 int32_t getYVisualFromYDisplay(int32_t yDisplay);
121 int32_t getYVisualWithinOctaveFromYDisplay(int32_t yDisplay);
122 ActionResult auditionPadAction(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown);
123 void potentiallyRefreshNoteRowMenu();
124 void enterScaleMode(uint8_t yDisplay = 255);
125 void exitScaleMode();
126 void drawMuteSquare(
NoteRow* thisNoteRow,
RGB thisImage[], uint8_t thisOccupancyMask[]);
127 void cutAuditionedNotesToOne();
128 ActionResult verticalEncoderAction(int32_t offset,
bool inCardRoutine)
override;
129 ActionResult horizontalEncoderAction(int32_t offset)
override;
130 void fillOffScreenImageStores();
131 void graphicsRoutine()
override;
133 void drawAuditionSquare(uint8_t yDisplay,
RGB thisImage[]);
134 void flashDefaultRootNote();
135 void selectEncoderAction(int8_t offset)
override;
136 void doubleClipLengthAction();
137 void setSelectedDrum(
Drum* drum,
bool shouldRedrawStuff =
true,
Kit* selectedKit =
nullptr,
138 bool shouldSendMidiFeedback =
true);
139 bool isDrumAuditioned(
Drum* drum);
140 int32_t setupForEnteringScaleMode(int32_t newRootNote = 2147483647, int32_t yDisplay = (kDisplayHeight / 2));
141 int32_t setupForExitingScaleMode();
142 void setupChangingOfRootNote(int32_t newRootNote, int32_t yDisplay = (kDisplayHeight / 2));
144 void cancelAllAuditioning();
145 void modEncoderButtonAction(uint8_t whichModEncoder,
bool on)
override;
147 void tellMatrixDriverWhichRowsContainSomethingZoomable()
override;
148 void drawDrumName(
Drum* drum,
bool justPopUp =
false);
150 void notifyPlaybackBegun()
override;
151 void openedInBackground();
152 bool renderMainPads(uint32_t whichRows,
RGB image[][kDisplayWidth + kSideBarWidth],
153 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
bool drawUndefinedArea =
true)
override;
154 void performActualRender(uint32_t whichRows,
RGB* image, uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
155 int32_t xScroll, uint32_t xZoom, int32_t renderWidth, int32_t imageWidth,
156 bool drawUndefinedArea =
true);
157 bool renderSidebar(uint32_t whichRows,
RGB image[][kDisplayWidth + kSideBarWidth],
158 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth])
override;
160 void playbackEnded()
override;
161 void scrollFinished()
override;
162 void clipNeedsReRendering(
Clip* clip)
override;
163 void modEncoderAction(int32_t whichModEncoder, int32_t offset)
override;
165 void reportMPEInitialValuesForNoteEditing(
ModelStackWithNoteRow* modelStack, int16_t
const* mpeValues);
166 void reportMPEValueForNoteEditing(int32_t expressionDimension, int32_t value);
168 void dontDeleteNotesOnDepress();
170 void tempoEncoderAction(int8_t offset,
bool encoderButtonPressed,
bool shiftButtonPressed);
171 void sendAuditionNote(
bool on, uint8_t yDisplay, uint8_t velocity, uint32_t sampleSyncLength);
175 uint32_t getSquareWidth(int32_t square, int32_t effectiveLength);
176 void drawNoteCode(uint8_t yDisplay);
177 void createNewInstrument(OutputType instrumentType,
bool is_fm =
false);
178 void changeOutputType(OutputType newOutputType);
180 void someAuditioningHasEnded(
bool recalculateLastAuditionedNoteOnScreen);
181 bool getAffectEntire()
override;
182 void checkIfAllEditPadPressesEnded(
bool mayRenderSidebar =
true);
183 void endEditPadPress(uint8_t i);
184 void endAllEditPadPresses();
185 void copyAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
186 void pasteAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
190 InstrumentClipMinder::renderOLED(canvas);
193 CopiedParamAutomation copiedParamAutomation;
195 bool auditioningSilently;
197 bool fileBrowserShouldNotPreview;
199 int16_t mpeValuesAtHighestPressure[MPE_RECORD_LENGTH_FOR_NOTE_EDITING][kNumExpressionDimensions];
200 int16_t mpeMostRecentPressure;
201 uint32_t mpeRecordLastUpdateTime;
204 EditPadPress editPadPresses[kEditPadPressBufferSize];
205 uint8_t lastAuditionedVelocityOnScreen[kDisplayHeight];
206 uint8_t auditionPadIsPressed[kDisplayHeight];
207 uint8_t numEditPadPressesPerNoteRowOnScreen[kDisplayHeight];
208 uint8_t lastAuditionedYDisplay;
209 uint8_t numEditPadPresses;
210 uint32_t timeLastEditPadPress;
211 uint32_t timeFirstEditPadPress;
214 uint32_t timeHorizontalKnobLastReleased;
215 bool shouldIgnoreVerticalScrollKnobActionIfNotAlsoPressedForThisNotePress;
216 bool shouldIgnoreHorizontalScrollKnobActionIfNotAlsoPressedForThisNotePress;
219 bool editedAnyPerNoteRowStuffSinceAuditioningBegan;
223 UIType getUIType()
override {
return UIType::INSTRUMENT_CLIP; }
226 bool enterNoteEditor();
227 void exitNoteEditor();
228 void handleNoteEditorEditPadAction(int32_t x, int32_t y, int32_t on);
229 void deselectNoteAndGoUpOneLevel();
230 ActionResult handleNoteEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
231 ActionResult handleNoteEditorHorizontalEncoderAction(int32_t offset);
232 ActionResult handleNoteEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
234 SquareInfo gridSquareInfo[kDisplayHeight][kDisplayWidth];
235 int32_t lastSelectedNoteXDisplay;
236 int32_t lastSelectedNoteYDisplay;
239 void adjustVelocity(int32_t velocityChange);
240 void updateVelocityValue(int32_t& velocityValue, int32_t newVelocity);
241 void displayVelocity(int32_t velocityValue, int32_t velocityChange);
242 void popupVelocity(
char const* displayString);
244 void handleProbabilityOrIteranceEditing(int8_t offset,
bool editNoteRow);
245 void adjustNoteProbabilityWithOffset(int32_t offset);
246 void adjustNoteIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
247 void adjustNoteIteranceWithFinalValue(Iterance finalValue);
248 void adjustNoteFillWithOffset(int32_t offset);
249 Note* getLeftMostNotePressed();
250 void adjustNoteParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
251 int32_t parameterMinValue, int32_t parameterMaxValue,
252 bool allowTogglingBetweenPresetsAndCustom =
true);
255 void editNoteRepeat(int32_t offset);
258 void blinkSelectedNote(int32_t whichMainRows = 0);
259 void resetSelectedNoteBlinking();
262 bool enterNoteRowEditor();
263 void exitNoteRowEditor();
264 bool handleNoteRowEditorPadAction(int32_t x, int32_t y, int32_t on);
265 bool handleNoteRowEditorMainPadAction(int32_t x, int32_t y, int32_t on);
266 void handleNoteRowEditorAuditionPadAction(int32_t y);
267 void copyNotesToFile(Serializer& writer,
bool selectedDrumOnly =
false);
268 Error pasteNotesFromFile(Deserializer& reader,
bool overwriteExisting,
bool noScaling,
bool previewOnly,
269 bool selectedDrumOnly);
270 void patternPreview();
272 ActionResult handleNoteRowEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
273 ActionResult handleNoteRowEditorHorizontalEncoderAction(int32_t offset);
274 ActionResult handleNoteRowEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
277 int32_t setNoteRowProbabilityWithOffset(int32_t offset);
278 int32_t setNoteRowIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
279 int32_t setNoteRowIteranceWithFinalValue(Iterance finalValue);
280 int32_t setNoteRowFillWithOffset(int32_t offset);
281 int32_t setNoteRowParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
282 int32_t parameterMinValue, int32_t parameterMaxValue,
283 bool allowTogglingBetweenPresetsAndCustom =
true);
285 ModelStackWithNoteRow* createNoteRowForYDisplay(ModelStackWithTimelineCounter* modelStack, int32_t yDisplay);
286 ModelStackWithNoteRow* getOrCreateNoteRowForYDisplay(ModelStackWithTimelineCounter* modelStack, int32_t yDisplay);
287 void editNumEuclideanEvents(ModelStackWithNoteRow* modelStack, int32_t offset, int32_t yDisplay);
288 void editNoteRowLength(int32_t offset);
289 void rotateNoteRowHorizontally(int32_t offset);
290 void editNoteRowLength(ModelStackWithNoteRow* modelStack, int32_t offset, int32_t yDisplay);
291 void noteRowChanged(InstrumentClip* clip, NoteRow* noteRow)
override;
294 void blinkSelectedNoteRow(int32_t whichMainRows = 0);
295 void resetSelectedNoteRowBlinking();
297 bool noteRowBlinking;
299 const char* getFillString(uint8_t fill);
302 void enterDrumCreator(ModelStackWithNoteRow* modelStack,
bool doRecording =
false);
305 bool doneAnyNudgingSinceFirstEditPadPress;
306 bool offsettingNudgeNumberDisplay;
308 uint8_t flashScaleModeLedErrorCount;
312 Drum* drumForNewNoteRow;
313 uint8_t yDisplayOfNewNoteRow;
315 int32_t quantizeAmount;
316 uint32_t timeSongButtonPressed;
318 std::array<RGB, kDisplayHeight> rowColour;
319 std::array<RGB, kDisplayHeight> rowTailColour;
320 std::array<RGB, kDisplayHeight> rowBlurColour;
323 void nudgeNotes(int32_t offset);
324 void displayProbability(uint8_t probability,
bool prevBase);
325 void displayIterance(Iterance iterance);
328 void copyNotes(Serializer* writer,
bool selectedDrumOnly =
false);
329 void pasteNotes(
bool overwriteExisting =
true,
bool pasteFromFile =
false,
bool noScaling =
false,
330 bool previewOnly =
false,
bool selectedDrumOnly =
false);
331 void deleteCopiedNoteRows();
332 CopiedNoteRow* firstCopiedNoteRow;
333 int32_t copiedScreenWidth;
334 ScaleType copiedScaleType;
335 int16_t copiedYNoteOfBottomRow;
337 void rotateNoteRowHorizontally(ModelStackWithNoteRow* modelStack, int32_t offset, int32_t yDisplay,
338 bool shouldDisplayDirectionEvenIfNoNoteRow =
false);
340 Drum* getNextDrum(Drum* oldDrum,
bool mayBeNone =
false);
341 Drum* flipThroughAvailableDrums(int32_t newOffset, Drum* drum,
bool mayBeNone =
false);
342 NoteRow* getOrCreateEmptyNoteRowForKit(ModelStackWithTimelineCounter* modelStack, int32_t yDisplay,
343 int32_t* getIndex =
nullptr);
344 void createDrumForAuditionedNoteRow(DrumType drumType);
345 bool isRowAuditionedByInstrument(int32_t yDisplay);
348 void commandQuantizeNotes(int8_t offset, NudgeMode nudgeMode);
349 void commandStartQuantize(int8_t offset, NudgeMode nudgeMode);
350 ActionResult commandStopQuantize(int32_t y);
351 void silenceAllAuditions();
354 Drum* getAuditionedDrum(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown, Instrument* instrument,
355 ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
356 ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip);
357 void potentiallyUpdateMultiRangeMenu(int32_t velocity, int32_t yDisplay, Instrument* instrument);
358 void recordNoteOnEarly(int32_t velocity, int32_t yDisplay, Instrument* instrument,
bool isKit,
359 ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip, Drum* drum);
360 void recordNoteOn(int32_t velocity, int32_t yDisplay, Instrument* instrument,
361 ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
362 ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip);
363 void recordNoteOff(int32_t yDisplay, ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip);
364 NoteRow* getNoteRowOnActiveClip(int32_t yDisplay, Instrument* instrument,
bool clipIsActiveOnInstrument,
365 ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip, Drum* drum);
366 int32_t getVelocityToSound(int32_t velocity);
367 bool startAuditioningRow(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown,
bool isKit,
368 NoteRow* noteRowOnActiveClip, Drum* drum);
369 void finishAuditioningRow(int32_t yDisplay, ModelStackWithNoteRow* modelStack, NoteRow* noteRowOnActiveClip);