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);
82 bool handleInstrumentChange(OutputType outputType);
86 ActionResult padAction(int32_t x, int32_t y, int32_t velocity)
override;
87 ActionResult potentiallyRandomizeDrumSamples();
88 ActionResult potentiallyRandomizeDrumSample(
Kit* kit,
Drum* drum,
char* chosenFilename);
89 ActionResult commandEnterNoteVelocityEditor(int32_t x, int32_t y);
90 ActionResult commandLearnMutePad(int32_t y, int32_t velocity);
91 ActionResult commandLearnAuditionPad(
InstrumentClip* clip,
Output* output, OutputType outputType, int32_t yDisplay,
93 ActionResult commandSaveKitRow(
InstrumentClip* clip,
Output* output, OutputType outputType, int32_t yDisplay);
94 ActionResult commandActivateSongMacro(int32_t y, int32_t velocity);
116 ActionResult commandTransposeKey(int32_t offset,
bool inCardRoutine);
117 void commandShiftColour(int32_t offset);
118 ActionResult scrollVertical(int32_t scrollAmount,
bool inCardRoutine,
bool draggingNoteRow =
false,
120 ActionResult scrollVertical_limit(int32_t scrollAmount,
bool inCardRoutine,
bool draggingNoteRow,
122 bool preventOverScrolling, int32_t& noteRowToShiftI, int32_t& noteRowToSwapWithI);
123 void scrollVertical_potentiallySwitchOffAuditionedNotes(
bool draggingNoteRow,
127 void scrollVertical_dragSelectedNoteRow(
InstrumentClip* clip,
Output* output,
bool isKit, int32_t noteRowToShiftI,
128 int32_t noteRowToSwapWithI);
129 void scrollVertical_potentiallySwitchOnAuditionedNotes(
bool draggingNoteRow,
132 bool isKit,
bool inSoundEditor,
bool currentClipIsActive,
133 bool renderDisplay,
bool updateDrumSelection);
138 void editPadAction(
bool state, uint8_t yDisplay, uint8_t xDisplay, uint32_t xZoom);
139 void mutePadPress(uint8_t yDisplay);
140 bool ensureNoteRowExistsForYDisplay(uint8_t yDisplay);
141 void recalculateColours();
142 void recalculateColour(uint8_t yDisplay);
143 void reassessAllAuditionStatus();
144 void reassessAuditionStatus(uint8_t yDisplay);
145 uint8_t getVelocityForAudition(uint8_t yDisplay, uint32_t* sampleSyncLength);
146 uint8_t getNumNoteRowsAuditioning();
147 uint8_t oneNoteAuditioning();
148 void offsetNoteCodeAction(int32_t newOffset);
149 int32_t getYVisualFromYDisplay(int32_t yDisplay);
150 int32_t getYVisualWithinOctaveFromYDisplay(int32_t yDisplay);
151 ActionResult auditionPadAction(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown);
152 void potentiallyUpdateMultiRangeMenu(int32_t velocity, int32_t yDisplay,
Instrument* instrument);
153 void potentiallyRecordAuditionPadAction(
bool clipIsActiveOnInstrument, int32_t velocity, int32_t yDisplay,
157 void recordNoteOnEarly(int32_t velocity, int32_t yDisplay,
Instrument* instrument,
bool isKit,
159 void recordNoteOn(int32_t velocity, int32_t yDisplay,
Instrument* instrument,
162 NoteRow* getNoteRowOnActiveClip(int32_t yDisplay,
Instrument* instrument,
bool clipIsActiveOnInstrument,
164 void potentiallyRefreshNoteRowMenu();
165 bool startAuditioningRow(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown,
bool isKit,
166 NoteRow* noteRowOnActiveClip,
Drum* drum,
bool displayNoteCode =
true);
168 void enterScaleMode(uint8_t yDisplay = 255);
169 void exitScaleMode();
170 void drawMuteSquare(
NoteRow* thisNoteRow,
RGB thisImage[], uint8_t thisOccupancyMask[]);
171 void cutAuditionedNotesToOne();
172 ActionResult horizontalEncoderAction(int32_t offset)
override;
173 void fillOffScreenImageStores();
174 void graphicsRoutine()
override;
176 void drawAuditionSquare(uint8_t yDisplay,
RGB thisImage[]);
177 void flashDefaultRootNote();
178 void selectEncoderAction(int8_t offset)
override;
179 void doubleClipLengthAction();
180 void setSelectedDrum(
Drum* drum,
bool shouldRedrawStuff =
true,
Kit* selectedKit =
nullptr,
181 bool shouldSendMidiFeedback =
true);
182 bool isDrumAuditioned(
Drum* drum);
183 int32_t setupForEnteringScaleMode(int32_t newRootNote = 2147483647, int32_t yDisplay = (kDisplayHeight / 2));
184 int32_t setupForExitingScaleMode();
185 void setupChangingOfRootNote(int32_t newRootNote, int32_t yDisplay = (kDisplayHeight / 2));
187 void cancelAllAuditioning();
188 void modEncoderButtonAction(uint8_t whichModEncoder,
bool on)
override;
190 void tellMatrixDriverWhichRowsContainSomethingZoomable()
override;
191 void drawDrumName(
Drum* drum,
bool justPopUp =
false);
193 void notifyPlaybackBegun()
override;
194 void openedInBackground();
195 bool renderMainPads(uint32_t whichRows,
RGB image[][kDisplayWidth + kSideBarWidth],
196 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
bool drawUndefinedArea =
true)
override;
197 void performActualRender(uint32_t whichRows,
RGB* image, uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth],
198 int32_t xScroll, uint32_t xZoom, int32_t renderWidth, int32_t imageWidth,
199 bool drawUndefinedArea =
true);
200 bool renderSidebar(uint32_t whichRows,
RGB image[][kDisplayWidth + kSideBarWidth],
201 uint8_t occupancyMask[][kDisplayWidth + kSideBarWidth])
override;
203 void playbackEnded()
override;
204 void scrollFinished()
override;
205 void clipNeedsReRendering(
Clip* clip)
override;
206 void modEncoderAction(int32_t whichModEncoder, int32_t offset)
override;
208 void reportMPEInitialValuesForNoteEditing(
ModelStackWithNoteRow* modelStack, int16_t
const* mpeValues);
209 void reportMPEValueForNoteEditing(int32_t expressionDimension, int32_t value);
211 void dontDeleteNotesOnDepress();
214 void tempoEncoderAction(int8_t offset,
bool encoderButtonPressed,
bool shiftButtonPressed);
215 ActionResult commandStopQuantize(int32_t y);
217 void sendAuditionNote(
bool on, uint8_t yDisplay, uint8_t velocity, uint32_t sampleSyncLength);
221 uint32_t getSquareWidth(int32_t square, int32_t effectiveLength);
222 void drawNoteCode(uint8_t yDisplay);
223 bool createNewInstrument(OutputType instrumentType,
bool is_fm =
false);
224 bool changeOutputType(OutputType newOutputType);
226 void someAuditioningHasEnded(
bool recalculateLastAuditionedNoteOnScreen);
227 bool getAffectEntire()
override;
228 void checkIfAllEditPadPressesEnded(
bool mayRenderSidebar =
true);
229 void endEditPadPress(uint8_t i);
230 void endAllEditPadPresses();
231 void copyAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
232 void pasteAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
236 InstrumentClipMinder::renderOLED(canvas);
239 CopiedParamAutomation copiedParamAutomation;
241 bool auditioningSilently;
243 bool fileBrowserShouldNotPreview;
245 int16_t mpeValuesAtHighestPressure[MPE_RECORD_LENGTH_FOR_NOTE_EDITING][kNumExpressionDimensions];
246 int16_t mpeMostRecentPressure;
247 uint32_t mpeRecordLastUpdateTime;
250 EditPadPress editPadPresses[kEditPadPressBufferSize];
251 uint8_t lastAuditionedVelocityOnScreen[kDisplayHeight];
252 uint8_t auditionPadIsPressed[kDisplayHeight];
253 uint8_t numEditPadPressesPerNoteRowOnScreen[kDisplayHeight];
254 uint8_t lastAuditionedYDisplay;
255 uint8_t numEditPadPresses;
256 uint32_t timeLastEditPadPress;
257 uint32_t timeFirstEditPadPress;
260 uint32_t timeHorizontalKnobLastReleased;
261 bool shouldIgnoreVerticalScrollKnobActionIfNotAlsoPressedForThisNotePress;
262 bool shouldIgnoreHorizontalScrollKnobActionIfNotAlsoPressedForThisNotePress;
265 bool editedAnyPerNoteRowStuffSinceAuditioningBegan;
269 UIType
getUIType()
override {
return UIType::INSTRUMENT_CLIP; }
273 bool enterNoteEditor();
274 void exitNoteEditor();
275 void handleNoteEditorEditPadAction(int32_t x, int32_t y, int32_t on);
276 void deselectNoteAndGoUpOneLevel();
277 ActionResult handleNoteEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
278 ActionResult handleNoteEditorHorizontalEncoderAction(int32_t offset);
279 ActionResult handleNoteEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
281 SquareInfo gridSquareInfo[kDisplayHeight][kDisplayWidth];
282 int32_t lastSelectedNoteXDisplay;
283 int32_t lastSelectedNoteYDisplay;
286 void adjustVelocity(int32_t velocityChange);
287 void updateVelocityValue(int32_t& velocityValue, int32_t newVelocity);
288 void displayVelocity(int32_t velocityValue, int32_t velocityChange);
289 void popupVelocity(
char const* displayString);
291 void handleProbabilityOrIteranceEditing(int8_t offset,
bool editNoteRow);
292 void adjustNoteProbabilityWithOffset(int32_t offset);
293 void adjustNoteIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
294 void adjustNoteIteranceWithFinalValue(
Iterance finalValue);
295 void adjustNoteFillWithOffset(int32_t offset);
296 Note* getLeftMostNotePressed();
297 void adjustNoteParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
298 int32_t parameterMinValue, int32_t parameterMaxValue,
299 bool allowTogglingBetweenPresetsAndCustom =
true);
302 void editNoteRepeat(int32_t offset);
305 void blinkSelectedNote(int32_t whichMainRows = 0);
306 void resetSelectedNoteBlinking();
309 bool enterNoteRowEditor();
310 void exitNoteRowEditor();
311 bool handleNoteRowEditorPadAction(int32_t x, int32_t y, int32_t on);
312 bool handleNoteRowEditorMainPadAction(int32_t x, int32_t y, int32_t on);
313 void handleNoteRowEditorAuditionPadAction(int32_t y);
314 void copyNotesToFile(
Serializer& writer,
bool selectedDrumOnly =
false);
315 Error pasteNotesFromFile(
Deserializer& reader,
bool overwriteExisting,
bool noScaling,
bool previewOnly,
316 bool selectedDrumOnly);
317 void patternPreview();
319 ActionResult handleNoteRowEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
320 ActionResult handleNoteRowEditorHorizontalEncoderAction(int32_t offset);
321 ActionResult handleNoteRowEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
324 int32_t setNoteRowProbabilityWithOffset(int32_t offset);
325 int32_t setNoteRowIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
326 int32_t setNoteRowIteranceWithFinalValue(
Iterance finalValue);
327 int32_t setNoteRowFillWithOffset(int32_t offset);
328 int32_t setNoteRowParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
329 int32_t parameterMinValue, int32_t parameterMaxValue,
330 bool allowTogglingBetweenPresetsAndCustom =
true);
334 void commandEuclidean(int32_t offset);
336 void editNoteRowLength(int32_t offset);
337 void rotateNoteRowHorizontally(int32_t offset);
342 void blinkSelectedNoteRow(int32_t whichMainRows = 0);
343 void resetSelectedNoteRowBlinking();
345 bool noteRowBlinking;
347 const char* getFillString(uint8_t fill);
353 bool doneAnyNudgingSinceFirstEditPadPress;
354 bool offsettingNudgeNumberDisplay;
356 uint8_t flashScaleModeLedErrorCount;
360 Drum* drumForNewNoteRow;
361 uint8_t yDisplayOfNewNoteRow;
363 int32_t quantizeAmount;
364 uint32_t timeSongButtonPressed;
366 std::array<RGB, kDisplayHeight> rowColour;
367 std::array<RGB, kDisplayHeight> rowTailColour;
368 std::array<RGB, kDisplayHeight> rowBlurColour;
371 void nudgeNotes(int32_t offset);
372 void displayProbability(uint8_t probability,
bool prevBase);
373 void displayIterance(
Iterance iterance);
376 void copyNotes(
Serializer* writer,
bool selectedDrumOnly =
false);
377 void pasteNotes(
bool overwriteExisting =
true,
bool pasteFromFile =
false,
bool noScaling =
false,
378 bool previewOnly =
false,
bool selectedDrumOnly =
false);
379 void deleteCopiedNoteRows();
381 int32_t copiedScreenWidth;
382 ScaleType copiedScaleType;
383 int16_t copiedYNoteOfBottomRow;
386 bool shouldDisplayDirectionEvenIfNoNoteRow =
false);
388 Drum* getNextDrum(
Drum* oldDrum,
bool mayBeNone =
false);
389 Drum* flipThroughAvailableDrums(int32_t newOffset,
Drum* drum,
bool mayBeNone =
false);
391 int32_t* getIndex =
nullptr);
392 void createDrumForAuditionedNoteRow(DrumType drumType);
393 bool isRowAuditionedByInstrument(int32_t yDisplay);
396 void commandQuantizeNotes(int8_t offset, NudgeMode nudgeMode);
397 void commandStartQuantize(int8_t offset, NudgeMode nudgeMode);
398 void silenceAllAuditions();
401 Drum* getAuditionedDrum(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown,
Instrument* instrument,
405 int32_t getVelocityToSound(int32_t velocity);