84class InstrumentClipView final :
public ClipView,
public InstrumentClipMinder {
87 bool opened()
override;
88 void focusRegained()
override;
89 void displayOrLanguageChanged()
override;
93 ActionResult buttonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine)
override;
95 ActionResult timerCallback()
override;
96 ActionResult handleScaleButtonAction(
bool on,
bool inCardRoutine);
97 bool handleInstrumentChange(OutputType outputType);
101 ActionResult padAction(int32_t x, int32_t y, int32_t velocity)
override;
102 ActionResult potentiallyRandomizeDrumSamples();
103 ActionResult potentiallyRandomizeDrumSample(
Kit* kit,
Drum* drum,
char* chosenFilename);
104 ActionResult commandEnterNoteVelocityEditor(int32_t x, int32_t y);
105 ActionResult commandLearnMutePad(int32_t y, int32_t velocity);
106 ActionResult commandLearnAuditionPad(
InstrumentClip* clip,
Output* output, OutputType outputType, int32_t yDisplay,
108 ActionResult commandSaveKitRow(
InstrumentClip* clip,
Output* output, OutputType outputType, int32_t yDisplay);
109 ActionResult commandActivateSongMacro(int32_t y, int32_t velocity);
133 ActionResult commandTransposeKey(int32_t offset,
bool inCardRoutine);
134 void commandTransposeScreen(int32_t offset,
bool inOctave);
135 void commandShiftColour(int32_t offset);
136 ActionResult scrollVertical(int32_t scrollAmount,
bool inCardRoutine,
bool draggingNoteRow =
false,
138 ActionResult scrollVertical_limit(int32_t scrollAmount,
bool inCardRoutine,
bool draggingNoteRow,
140 bool preventOverScrolling, int32_t& noteRowToShiftI, int32_t& noteRowToSwapWithI);
141 void scrollVertical_potentiallySwitchOffAuditionedNotes(
bool draggingNoteRow,
145 void scrollVertical_dragSelectedNoteRow(
InstrumentClip* clip,
Output* output,
bool isKit, int32_t noteRowToShiftI,
146 int32_t noteRowToSwapWithI);
147 void scrollVertical_potentiallySwitchOnAuditionedNotes(
bool draggingNoteRow,
150 bool isKit,
bool inSoundEditor,
bool currentClipIsActive,
151 bool renderDisplay,
bool updateDrumSelection);
153 bool keepYNoteOverride =
false);
154 void nudgeHeldNotesBySemitone(int32_t offset);
158 void editPadAction(
bool state, uint8_t yDisplay, uint8_t xDisplay, uint32_t xZoom);
159 void mutePadPress(uint8_t yDisplay);
160 bool ensureNoteRowExistsForYDisplay(uint8_t yDisplay);
161 void recalculateColours();
162 void recalculateColour(uint8_t yDisplay);
163 void reassessAllAuditionStatus();
164 void reassessAuditionStatus(uint8_t yDisplay);
165 uint8_t getVelocityForAudition(uint8_t yDisplay, uint32_t* sampleSyncLength);
166 uint8_t getNumNoteRowsAuditioning();
167 uint8_t oneNoteAuditioning();
168 void offsetNoteCodeAction(int32_t newOffset);
169 int32_t getYVisualFromYDisplay(int32_t yDisplay);
170 int32_t getYVisualWithinOctaveFromYDisplay(int32_t yDisplay);
171 ActionResult auditionPadAction(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown);
172 void potentiallyUpdateMultiRangeMenu(int32_t velocity, int32_t yDisplay,
Instrument* instrument);
173 void potentiallyRecordAuditionPadAction(
bool clipIsActiveOnInstrument, int32_t velocity, int32_t yDisplay,
177 void recordNoteOnEarly(int32_t velocity, int32_t yDisplay,
Instrument* instrument,
bool isKit,
179 void recordNoteOn(int32_t velocity, int32_t yDisplay,
Instrument* instrument,
182 NoteRow* getNoteRowOnActiveClip(int32_t yDisplay,
Instrument* instrument,
bool clipIsActiveOnInstrument,
184 void potentiallyRefreshNoteRowMenu();
185 bool startAuditioningRow(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown,
bool isKit,
186 NoteRow* noteRowOnActiveClip,
Drum* drum,
bool displayNoteCode =
true);
188 bool changeRowSelection =
true);
189 void enterScaleMode(uint8_t yDisplay = 255);
190 void exitScaleMode();
191 void drawMuteSquare(
NoteRow* thisNoteRow,
RGB thisImage[], uint8_t thisOccupancyMask[]);
192 void cutAuditionedNotesToOne();
193 ActionResult horizontalEncoderAction(int32_t offset)
override;
194 void fillOffScreenImageStores();
195 void graphicsRoutine()
override;
197 void drawAuditionSquare(uint8_t yDisplay,
RGB thisImage[]);
198 void flashDefaultRootNote();
199 void selectEncoderAction(int8_t offset)
override;
200 void doubleClipLengthAction();
201 void setSelectedDrum(
Drum* drum,
bool shouldRedrawStuff =
true,
Kit* selectedKit =
nullptr,
202 bool shouldSendMidiFeedback =
true);
203 bool isDrumAuditioned(
Drum* drum);
204 int32_t setupForEnteringScaleMode(int32_t newRootNote = 2147483647, int32_t yDisplay = (kDisplayHeight / 2));
205 int32_t setupForExitingScaleMode();
206 void setupChangingOfRootNote(int32_t newRootNote, int32_t yDisplay = (kDisplayHeight / 2));
208 void cancelAllAuditioning();
209 void modEncoderButtonAction(uint8_t whichModEncoder,
bool on)
override;
211 void drawDrumName(
Drum* drum,
bool justPopUp =
false);
212 void notifyPlaybackBegun()
override;
213 void openedInBackground();
214 bool renderMainPads(uint32_t whichRows,
RGB image[][kDisplayWidth + kSideBarWidth],
215 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
bool drawUndefinedArea =
true)
override;
216 void performActualRender(uint32_t whichRows,
RGB* image, uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
217 int32_t xScroll, uint32_t xZoom, int32_t renderWidth, int32_t imageWidth,
218 bool drawUndefinedArea =
true);
219 bool renderSidebar(uint32_t whichRows,
RGB image[][kDisplayWidth + kSideBarWidth],
220 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth])
override;
222 void playbackEnded()
override;
223 void scrollFinished()
override;
224 void clipNeedsReRendering(
Clip* clip)
override;
225 void modEncoderAction(int32_t whichModEncoder, int32_t offset)
override;
227 void reportMPEInitialValuesForNoteEditing(
ModelStackWithNoteRow* modelStack, int16_t
const* mpeValues);
228 void reportMPEValueForNoteEditing(int32_t expressionDimension, int32_t value);
230 void dontDeleteNotesOnDepress();
233 void tempoEncoderAction(int8_t offset,
bool encoderButtonPressed,
bool shiftButtonPressed);
234 ActionResult commandStopQuantize(int32_t y);
236 void sendAuditionNote(
bool on, uint8_t yDisplay, uint8_t velocity, uint32_t sampleSyncLength);
240 uint32_t getSquareWidth(int32_t square, int32_t effectiveLength);
241 void drawNoteCode(uint8_t yDisplay);
242 bool createNewInstrument(OutputType instrumentType,
bool is_fm =
false);
243 bool changeOutputType(OutputType newOutputType);
245 void someAuditioningHasEnded(
bool recalculateLastAuditionedNoteOnScreen);
246 bool getAffectEntire()
override;
247 void checkIfAllEditPadPressesEnded(
bool mayRenderSidebar =
true);
248 void endEditPadPress(uint8_t i);
249 void endAllEditPadPresses();
250 void copyAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
251 void pasteAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
255 InstrumentClipMinder::renderOLED(canvas);
258 CopiedParamAutomation copiedParamAutomation{};
260 bool auditioningSilently{};
262 bool fileBrowserShouldNotPreview{};
264 int16_t mpeValuesAtHighestPressure[MPE_RECORD_LENGTH_FOR_NOTE_EDITING][kNumExpressionDimensions]{};
265 int16_t mpeMostRecentPressure{};
266 uint32_t mpeRecordLastUpdateTime{};
269 EditPadPress editPadPresses[kEditPadPressBufferSize];
270 uint8_t lastAuditionedVelocityOnScreen[kDisplayHeight]{};
273 uint8_t auditionPadIsPressed[kDisplayHeight]{};
274 uint8_t numEditPadPressesPerNoteRowOnScreen[kDisplayHeight]{};
275 uint8_t lastAuditionedYDisplay{};
276 uint8_t numEditPadPresses;
277 uint32_t timeLastEditPadPress;
278 uint32_t timeFirstEditPadPress{};
281 uint32_t timeHorizontalKnobLastReleased{};
282 bool shouldIgnoreVerticalScrollKnobActionIfNotAlsoPressedForThisNotePress{};
283 bool shouldIgnoreHorizontalScrollKnobActionIfNotAlsoPressedForThisNotePress{};
286 bool editedAnyPerNoteRowStuffSinceAuditioningBegan{};
290 UIType
getUIType()
override {
return UIType::INSTRUMENT_CLIP; }
294 bool enterNoteEditor();
296 void exitNoteEditor();
297 void handleNoteEditorEditPadAction(int32_t x, int32_t y, int32_t on);
298 void deselectNoteAndGoUpOneLevel();
299 ActionResult handleNoteEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
300 ActionResult handleNoteEditorHorizontalEncoderAction(int32_t offset);
301 ActionResult handleNoteEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
303 SquareInfo gridSquareInfo[kDisplayHeight][kDisplayWidth]{};
309 void adjustVelocity(int32_t velocityChange,
bool display_value =
true);
310 void updateVelocityValue(int32_t& velocityValue, int32_t newVelocity);
311 void displayVelocity(int32_t velocityValue, int32_t velocityChange);
312 void popupVelocity(
char const* displayString);
314 void handleProbabilityOrIteranceEditing(int8_t offset,
bool editNoteRow);
315 void adjustNoteProbabilityWithOffset(int32_t offset);
316 void adjustNoteIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
317 void adjustNoteIteranceWithFinalValue(
Iterance finalValue);
318 void adjustNoteFillWithOffset(int32_t offset);
319 Note* getLeftMostNotePressed();
320 void adjustNoteParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
321 int32_t parameterMinValue, int32_t parameterMaxValue,
322 bool allowTogglingBetweenPresetsAndCustom =
true);
325 void editNoteRepeat(int32_t offset);
328 void pulseSelectedNote();
331 bool enterNoteRowEditor();
332 void exitNoteRowEditor();
333 bool handleNoteRowEditorPadAction(int32_t x, int32_t y, int32_t on);
334 bool handleNoteRowEditorMainPadAction(int32_t x, int32_t y, int32_t on);
335 void handleNoteRowEditorAuditionPadAction(int32_t y);
336 void copyNotesToFile(
Serializer& writer,
bool selectedDrumOnly =
false);
337 Error pasteNotesFromFile(
Deserializer& reader,
bool overwriteExisting,
bool noScaling,
bool previewOnly,
338 bool selectedDrumOnly);
339 void patternPreview();
341 ActionResult handleNoteRowEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
342 ActionResult handleNoteRowEditorHorizontalEncoderAction(int32_t offset);
343 ActionResult handleNoteRowEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
346 int32_t setNoteRowProbabilityWithOffset(int32_t offset);
347 int32_t setNoteRowIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
348 int32_t setNoteRowIteranceWithFinalValue(
Iterance finalValue);
349 int32_t setNoteRowFillWithOffset(int32_t offset);
350 int32_t setNoteRowParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
351 int32_t parameterMinValue, int32_t parameterMaxValue,
352 bool allowTogglingBetweenPresetsAndCustom =
true);
356 void commandEuclidean(int32_t offset);
358 void editNoteRowLength(int32_t offset);
359 void rotateNoteRowHorizontally(int32_t offset);
364 void blinkSelectedNoteRow(int32_t whichMainRows = 0);
365 void resetSelectedNoteRowBlinking();
367 bool noteRowBlinking;
369 const char* getFillString(uint8_t fill);
377 bool doneAnyNudgingSinceFirstEditPadPress{};
378 bool offsettingNudgeNumberDisplay{};
380 uint8_t flashScaleModeLedErrorCount{};
382 Drum* drumForNewNoteRow{};
383 uint8_t yDisplayOfNewNoteRow{};
385 int32_t quantizeAmount{};
386 uint32_t timeSongButtonPressed{};
389 bool sessionMacroSidebarActive{};
391 std::array<RGB, kDisplayHeight> rowColour;
392 std::array<RGB, kDisplayHeight> rowTailColour;
393 std::array<RGB, kDisplayHeight> rowBlurColour;
396 void nudgeNotes(int32_t offset);
397 void displayProbability(uint8_t probability,
bool prevBase);
398 void displayIterance(Iterance iterance);
399 void displayFill(uint8_t mode);
404 ModelStackWithNoteRow* get_note_edit_row(ModelStackWithTimelineCounter* model_stack,
const EditPadPress& target);
405 friend class NoteLockEditor;
406 EditPadPress remembered_notes[kEditPadPressBufferSize]{};
407 int32_t remembered_note_row_ids[kEditPadPressBufferSize]{};
408 int32_t remembered_note_count = 0;
411 void render_selected_note_pulse(uint32_t which_rows, RGB image[][kDisplayWidth + kSideBarWidth]);
412 void render_selected_square_pulse(int32_t selection_index, uint32_t which_rows,
413 RGB image[][kDisplayWidth + kSideBarWidth], uint32_t* pulsed_columns);
414 void stopSelectedNotePulsing();
415 int32_t note_pulse_progress = 1;
416 bool note_pulse_increasing =
true;
417 RGB note_pulse_base_colours[kDisplayHeight][kDisplayWidth]{};
418 bool updating_note_pulse_directly =
false;
421 void copyNotes(Serializer* writer,
bool selectedDrumOnly =
false);
422 void pasteNotes(
bool overwriteExisting =
true,
bool pasteFromFile =
false,
bool noScaling =
false,
423 bool previewOnly =
false,
bool selectedDrumOnly =
false);
424 void deleteCopiedNoteRows();
425 CopiedNoteRow* firstCopiedNoteRow;
426 int32_t copiedScreenWidth{};
427 ScaleType copiedScaleType{};
428 int16_t copiedYNoteOfBottomRow{};
430 void rotateNoteRowHorizontally(ModelStackWithNoteRow* modelStack, int32_t offset, int32_t yDisplay,
431 bool shouldDisplayDirectionEvenIfNoNoteRow =
false);
433 Drum* getNextDrum(Drum* oldDrum,
bool mayBeNone =
false);
434 Drum* flipThroughAvailableDrums(int32_t newOffset, Drum* drum,
bool mayBeNone =
false);
435 NoteRow* getOrCreateEmptyNoteRowForKit(ModelStackWithTimelineCounter* modelStack, int32_t yDisplay,
436 int32_t* getIndex =
nullptr);
437 void createDrumForAuditionedNoteRow(DrumType drumType);
438 bool isRowAuditionedByInstrument(int32_t yDisplay);
441 void commandQuantizeNotes(int8_t offset, NudgeMode nudgeMode);
442 void commandStartQuantize(int8_t offset, NudgeMode nudgeMode);
443 void silenceAllAuditions();
446 Drum* getAuditionedDrum(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown, Instrument* instrument,
447 ModelStackWithTimelineCounter* modelStackWithTimelineCounter,
448 ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip);
449 void recordNoteOff(int32_t yDisplay, ModelStackWithNoteRow* modelStackWithNoteRowOnCurrentClip);
450 int32_t getVelocityToSound(int32_t velocity);