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();
213 void tempoEncoderAction(int8_t offset,
bool encoderButtonPressed,
bool shiftButtonPressed);
214 void sendAuditionNote(
bool on, uint8_t yDisplay, uint8_t velocity, uint32_t sampleSyncLength);
218 uint32_t getSquareWidth(int32_t square, int32_t effectiveLength);
219 void drawNoteCode(uint8_t yDisplay);
220 bool createNewInstrument(OutputType instrumentType,
bool is_fm =
false);
221 bool changeOutputType(OutputType newOutputType);
223 void someAuditioningHasEnded(
bool recalculateLastAuditionedNoteOnScreen);
224 bool getAffectEntire()
override;
225 void checkIfAllEditPadPressesEnded(
bool mayRenderSidebar =
true);
226 void endEditPadPress(uint8_t i);
227 void endAllEditPadPresses();
228 void copyAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
229 void pasteAutomation(int32_t whichModEncoder, int32_t navSysId = NAVIGATION_CLIP);
233 InstrumentClipMinder::renderOLED(canvas);
236 CopiedParamAutomation copiedParamAutomation;
238 bool auditioningSilently;
240 bool fileBrowserShouldNotPreview;
242 int16_t mpeValuesAtHighestPressure[MPE_RECORD_LENGTH_FOR_NOTE_EDITING][kNumExpressionDimensions];
243 int16_t mpeMostRecentPressure;
244 uint32_t mpeRecordLastUpdateTime;
247 EditPadPress editPadPresses[kEditPadPressBufferSize];
248 uint8_t lastAuditionedVelocityOnScreen[kDisplayHeight];
249 uint8_t auditionPadIsPressed[kDisplayHeight];
250 uint8_t numEditPadPressesPerNoteRowOnScreen[kDisplayHeight];
251 uint8_t lastAuditionedYDisplay;
252 uint8_t numEditPadPresses;
253 uint32_t timeLastEditPadPress;
254 uint32_t timeFirstEditPadPress;
257 uint32_t timeHorizontalKnobLastReleased;
258 bool shouldIgnoreVerticalScrollKnobActionIfNotAlsoPressedForThisNotePress;
259 bool shouldIgnoreHorizontalScrollKnobActionIfNotAlsoPressedForThisNotePress;
262 bool editedAnyPerNoteRowStuffSinceAuditioningBegan;
266 UIType
getUIType()
override {
return UIType::INSTRUMENT_CLIP; }
270 bool enterNoteEditor();
271 void exitNoteEditor();
272 void handleNoteEditorEditPadAction(int32_t x, int32_t y, int32_t on);
273 void deselectNoteAndGoUpOneLevel();
274 ActionResult handleNoteEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
275 ActionResult handleNoteEditorHorizontalEncoderAction(int32_t offset);
276 ActionResult handleNoteEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
278 SquareInfo gridSquareInfo[kDisplayHeight][kDisplayWidth];
279 int32_t lastSelectedNoteXDisplay;
280 int32_t lastSelectedNoteYDisplay;
283 void adjustVelocity(int32_t velocityChange);
284 void updateVelocityValue(int32_t& velocityValue, int32_t newVelocity);
285 void displayVelocity(int32_t velocityValue, int32_t velocityChange);
286 void popupVelocity(
char const* displayString);
288 void handleProbabilityOrIteranceEditing(int8_t offset,
bool editNoteRow);
289 void adjustNoteProbabilityWithOffset(int32_t offset);
290 void adjustNoteIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
291 void adjustNoteIteranceWithFinalValue(
Iterance finalValue);
292 void adjustNoteFillWithOffset(int32_t offset);
293 Note* getLeftMostNotePressed();
294 void adjustNoteParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
295 int32_t parameterMinValue, int32_t parameterMaxValue,
296 bool allowTogglingBetweenPresetsAndCustom =
true);
299 void editNoteRepeat(int32_t offset);
302 void blinkSelectedNote(int32_t whichMainRows = 0);
303 void resetSelectedNoteBlinking();
306 bool enterNoteRowEditor();
307 void exitNoteRowEditor();
308 bool handleNoteRowEditorPadAction(int32_t x, int32_t y, int32_t on);
309 bool handleNoteRowEditorMainPadAction(int32_t x, int32_t y, int32_t on);
310 void handleNoteRowEditorAuditionPadAction(int32_t y);
311 void copyNotesToFile(
Serializer& writer,
bool selectedDrumOnly =
false);
312 Error pasteNotesFromFile(
Deserializer& reader,
bool overwriteExisting,
bool noScaling,
bool previewOnly,
313 bool selectedDrumOnly);
314 void patternPreview();
316 ActionResult handleNoteRowEditorVerticalEncoderAction(int32_t offset,
bool inCardRoutine);
317 ActionResult handleNoteRowEditorHorizontalEncoderAction(int32_t offset);
318 ActionResult handleNoteRowEditorButtonAction(deluge::hid::Button b,
bool on,
bool inCardRoutine);
321 int32_t setNoteRowProbabilityWithOffset(int32_t offset);
322 int32_t setNoteRowIteranceWithOffset(int32_t offset,
bool allowTogglingBetweenPresetsAndCustom =
true);
323 int32_t setNoteRowIteranceWithFinalValue(
Iterance finalValue);
324 int32_t setNoteRowFillWithOffset(int32_t offset);
325 int32_t setNoteRowParameterValue(int32_t withOffset, int32_t withFinalValue, int32_t changeType,
326 int32_t parameterMinValue, int32_t parameterMaxValue,
327 bool allowTogglingBetweenPresetsAndCustom =
true);
331 void commandEuclidean(int32_t offset);
333 void editNoteRowLength(int32_t offset);
334 void rotateNoteRowHorizontally(int32_t offset);
339 void blinkSelectedNoteRow(int32_t whichMainRows = 0);
340 void resetSelectedNoteRowBlinking();
342 bool noteRowBlinking;
344 const char* getFillString(uint8_t fill);
350 bool doneAnyNudgingSinceFirstEditPadPress;
351 bool offsettingNudgeNumberDisplay;
353 uint8_t flashScaleModeLedErrorCount;
357 Drum* drumForNewNoteRow;
358 uint8_t yDisplayOfNewNoteRow;
360 int32_t quantizeAmount;
361 uint32_t timeSongButtonPressed;
363 std::array<RGB, kDisplayHeight> rowColour;
364 std::array<RGB, kDisplayHeight> rowTailColour;
365 std::array<RGB, kDisplayHeight> rowBlurColour;
368 void nudgeNotes(int32_t offset);
369 void displayProbability(uint8_t probability,
bool prevBase);
370 void displayIterance(
Iterance iterance);
373 void copyNotes(
Serializer* writer,
bool selectedDrumOnly =
false);
374 void pasteNotes(
bool overwriteExisting =
true,
bool pasteFromFile =
false,
bool noScaling =
false,
375 bool previewOnly =
false,
bool selectedDrumOnly =
false);
376 void deleteCopiedNoteRows();
378 int32_t copiedScreenWidth;
379 ScaleType copiedScaleType;
380 int16_t copiedYNoteOfBottomRow;
383 bool shouldDisplayDirectionEvenIfNoNoteRow =
false);
385 Drum* getNextDrum(
Drum* oldDrum,
bool mayBeNone =
false);
386 Drum* flipThroughAvailableDrums(int32_t newOffset,
Drum* drum,
bool mayBeNone =
false);
388 int32_t* getIndex =
nullptr);
389 void createDrumForAuditionedNoteRow(DrumType drumType);
390 bool isRowAuditionedByInstrument(int32_t yDisplay);
393 void commandQuantizeNotes(int8_t offset, NudgeMode nudgeMode);
394 void commandStartQuantize(int8_t offset, NudgeMode nudgeMode);
395 ActionResult commandStopQuantize(int32_t y);
396 void silenceAllAuditions();
399 Drum* getAuditionedDrum(int32_t velocity, int32_t yDisplay,
bool shiftButtonDown,
Instrument* instrument,
403 int32_t getVelocityToSound(int32_t velocity);