Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
arranger_selections.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2019-2023 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __UNDO_ARRANGER_SELECTIONS_ACTION_H__
11#define __UNDO_ARRANGER_SELECTIONS_ACTION_H__
12
13#include <cstdint>
14
16#include "dsp/audio_function.h"
18#include "dsp/midi_function.h"
19#include "dsp/port_identifier.h"
20#include "dsp/position.h"
27
29typedef struct ArrangerObject ArrangerObject;
30typedef struct Position Position;
31typedef struct QuantizeOptions QuantizeOptions;
32
39enum class ArrangerSelectionsActionType
40{
41 AS_ACTION_AUTOMATION_FILL,
42 AS_ACTION_CREATE,
43 AS_ACTION_DELETE,
44 AS_ACTION_DUPLICATE,
45 AS_ACTION_EDIT,
46 AS_ACTION_LINK,
47 AS_ACTION_MERGE,
48 AS_ACTION_MOVE,
49 AS_ACTION_QUANTIZE,
50 AS_ACTION_RECORD,
51 AS_ACTION_RESIZE,
52 AS_ACTION_SPLIT,
53};
54
59{
60 ARRANGER_SELECTIONS_ACTION_RESIZE_L,
61 ARRANGER_SELECTIONS_ACTION_RESIZE_R,
62 ARRANGER_SELECTIONS_ACTION_RESIZE_L_LOOP,
63 ARRANGER_SELECTIONS_ACTION_RESIZE_R_LOOP,
64 ARRANGER_SELECTIONS_ACTION_RESIZE_L_FADE,
65 ARRANGER_SELECTIONS_ACTION_RESIZE_R_FADE,
66 ARRANGER_SELECTIONS_ACTION_STRETCH_L,
67 ARRANGER_SELECTIONS_ACTION_STRETCH_R,
68};
69
115
120{
121 UndoableAction parent_instance;
122
124 ArrangerSelectionsActionType type;
125
128
134
137
139
141 double ticks;
157
162
164 char * str;
165
168
172 ArrangerObject * r2[800];
173
177
184
187
188 /* --- below for serialization only --- */
189 ChordSelections * chord_sel;
190 ChordSelections * chord_sel_after;
191 TimelineSelections * tl_sel;
192 TimelineSelections * tl_sel_after;
193 MidiArrangerSelections * ma_sel;
194 MidiArrangerSelections * ma_sel_after;
195 AutomationSelections * automation_sel;
196 AutomationSelections * automation_sel_after;
197 AudioSelections * audio_sel;
198 AudioSelections * audio_sel_after;
199
200 /* arranger objects that can be split */
201 Region * region_r1[800];
202 Region * region_r2[800];
203 MidiNote * mn_r1[800];
204 MidiNote * mn_r2[800];
205
208 Region * region_after;
209
211
212void
213arranger_selections_action_init_loaded (ArrangerSelectionsAction * self);
214
221WARN_UNUSED_RESULT UndoableAction *
223 ArrangerSelections * sel,
224 const bool create,
225 GError ** error);
226
227#define arranger_selections_action_new_create(sel, error) \
228 arranger_selections_action_new_create_or_delete ( \
229 (ArrangerSelections *) sel, true, error)
230
231#define arranger_selections_action_new_delete(sel, error) \
232 arranger_selections_action_new_create_or_delete ( \
233 (ArrangerSelections *) sel, false, error)
234
235WARN_UNUSED_RESULT UndoableAction *
236arranger_selections_action_new_record (
237 ArrangerSelections * sel_before,
238 ArrangerSelections * sel_after,
239 const bool already_recorded,
240 GError ** error);
241
253WARN_UNUSED_RESULT UndoableAction *
255 ArrangerSelections * sel,
256 const bool move,
257 const double ticks,
258 const int delta_chords,
259 const int delta_pitch,
260 const int delta_tracks,
261 const int delta_lanes,
262 const double delta_normalized_amount,
263 const PortIdentifier * tgt_port_id,
264 const bool already_moved,
265 GError ** error);
266
267#define arranger_selections_action_new_move( \
268 sel, ticks, chords, pitch, tracks, lanes, norm_amt, port_id, already_moved, \
269 error) \
270 arranger_selections_action_new_move_or_duplicate ( \
271 (ArrangerSelections *) sel, 1, ticks, chords, pitch, tracks, lanes, \
272 norm_amt, port_id, already_moved, error)
273#define arranger_selections_action_new_duplicate( \
274 sel, ticks, chords, pitch, tracks, lanes, norm_amt, port_id, already_moved, \
275 error) \
276 arranger_selections_action_new_move_or_duplicate ( \
277 (ArrangerSelections *) sel, 0, ticks, chords, pitch, tracks, lanes, \
278 norm_amt, port_id, already_moved, error)
279
280#define arranger_selections_action_new_move_timeline( \
281 sel, ticks, delta_tracks, delta_lanes, port_id, already_moved, error) \
282 arranger_selections_action_new_move ( \
283 sel, ticks, 0, 0, delta_tracks, delta_lanes, 0, port_id, already_moved, \
284 error)
285#define arranger_selections_action_new_duplicate_timeline( \
286 sel, ticks, delta_tracks, delta_lanes, port_id, already_moved, error) \
287 arranger_selections_action_new_duplicate ( \
288 sel, ticks, 0, 0, delta_tracks, delta_lanes, 0, port_id, already_moved, \
289 error)
290
291#define arranger_selections_action_new_move_midi( \
292 sel, ticks, delta_pitch, already_moved, error) \
293 arranger_selections_action_new_move ( \
294 sel, ticks, 0, delta_pitch, 0, 0, 0, NULL, already_moved, error)
295#define arranger_selections_action_new_duplicate_midi( \
296 sel, ticks, delta_pitch, already_moved, error) \
297 arranger_selections_action_new_duplicate ( \
298 sel, ticks, 0, delta_pitch, 0, 0, 0, NULL, already_moved, error)
299#define arranger_selections_action_new_move_chord( \
300 sel, ticks, delta_chords, already_moved, error) \
301 arranger_selections_action_new_move ( \
302 sel, ticks, delta_chords, 0, 0, 0, 0, NULL, already_moved, error)
303#define arranger_selections_action_new_duplicate_chord( \
304 sel, ticks, delta_chords, already_moved, error) \
305 arranger_selections_action_new_duplicate ( \
306 sel, ticks, delta_chords, 0, 0, 0, 0, NULL, already_moved, error)
307
308#define arranger_selections_action_new_move_automation( \
309 sel, ticks, norm_amt, already_moved, error) \
310 arranger_selections_action_new_move ( \
311 sel, ticks, 0, 0, 0, 0, norm_amt, NULL, already_moved, error)
312#define arranger_selections_action_new_duplicate_automation( \
313 sel, ticks, norm_amt, already_moved, error) \
314 arranger_selections_action_new_duplicate ( \
315 sel, ticks, 0, 0, 0, 0, norm_amt, NULL, already_moved, error)
316
325WARN_UNUSED_RESULT UndoableAction *
327 ArrangerSelections * sel_before,
328 ArrangerSelections * sel_after,
329 const double ticks,
330 const int delta_tracks,
331 const int delta_lanes,
332 const bool already_moved,
333 GError ** error);
334
345WARN_UNUSED_RESULT UndoableAction *
347 ArrangerSelections * sel_before,
348 ArrangerSelections * sel_after,
350 bool already_edited,
351 GError ** error);
352
353WARN_UNUSED_RESULT UndoableAction *
354arranger_selections_action_new_edit_single_obj (
355 const ArrangerObject * obj_before,
356 const ArrangerObject * obj_after,
358 bool already_edited,
359 GError ** error);
360
366WARN_UNUSED_RESULT UndoableAction *
368 ArrangerSelections * sel_before,
369 MidiFunctionType midi_func_type,
370 MidiFunctionOpts opts,
371 GError ** error);
372
378WARN_UNUSED_RESULT UndoableAction *
380 ArrangerSelections * sel_before,
381 AutomationFunctionType automation_func_type,
382 GError ** error);
383
389WARN_UNUSED_RESULT UndoableAction *
391 ArrangerSelections * sel_before,
392 AudioFunctionType audio_func_type,
394 const char * uri,
395 GError ** error);
396
407WARN_UNUSED_RESULT UndoableAction *
409 Region * region_before,
410 Region * region_after,
411 bool already_changed,
412 GError ** error);
413
420WARN_UNUSED_RESULT UndoableAction *
422 ArrangerSelections * sel,
423 const Position * pos,
424 GError ** error);
425
430WARN_UNUSED_RESULT UndoableAction *
432
439WARN_UNUSED_RESULT UndoableAction *
441 ArrangerSelections * sel_before,
442 ArrangerSelections * sel_after,
444 const double ticks,
445 GError ** error);
446
453WARN_UNUSED_RESULT UndoableAction *
455 ArrangerSelections * sel,
456 QuantizeOptions * opts,
457 GError ** error);
458
460arranger_selections_action_clone (const ArrangerSelectionsAction * src);
461
462bool
463arranger_selections_action_perform_create_or_delete (
464 ArrangerSelections * sel,
465 const bool create,
466 GError ** error);
467
468#define arranger_selections_action_perform_create(sel, error) \
469 arranger_selections_action_perform_create_or_delete ( \
470 (ArrangerSelections *) sel, true, error)
471
472#define arranger_selections_action_perform_delete(sel, error) \
473 arranger_selections_action_perform_create_or_delete ( \
474 (ArrangerSelections *) sel, false, error)
475
476bool
477arranger_selections_action_perform_record (
478 ArrangerSelections * sel_before,
479 ArrangerSelections * sel_after,
480 const bool already_recorded,
481 GError ** error);
482
483bool
484arranger_selections_action_perform_move_or_duplicate (
485 ArrangerSelections * sel,
486 const bool move,
487 const double ticks,
488 const int delta_chords,
489 const int delta_pitch,
490 const int delta_tracks,
491 const int delta_lanes,
492 const double delta_normalized_amount,
493 const PortIdentifier * port_id,
494 const bool already_moved,
495 GError ** error);
496
497#define arranger_selections_action_perform_move( \
498 sel, ticks, chords, pitch, tracks, lanes, norm_amt, port_id, already_moved, \
499 error) \
500 arranger_selections_action_perform_move_or_duplicate ( \
501 (ArrangerSelections *) sel, 1, ticks, chords, pitch, tracks, lanes, \
502 norm_amt, port_id, already_moved, error)
503#define arranger_selections_action_perform_duplicate( \
504 sel, ticks, chords, pitch, tracks, lanes, norm_amt, port_id, already_moved, \
505 error) \
506 arranger_selections_action_perform_move_or_duplicate ( \
507 (ArrangerSelections *) sel, 0, ticks, chords, pitch, tracks, lanes, \
508 norm_amt, port_id, already_moved, error)
509
510#define arranger_selections_action_perform_move_timeline( \
511 sel, ticks, delta_tracks, delta_lanes, port_id, already_moved, error) \
512 arranger_selections_action_perform_move ( \
513 sel, ticks, 0, 0, delta_tracks, delta_lanes, 0, port_id, already_moved, \
514 error)
515#define arranger_selections_action_perform_duplicate_timeline( \
516 sel, ticks, delta_tracks, delta_lanes, port_id, already_moved, error) \
517 arranger_selections_action_perform_duplicate ( \
518 sel, ticks, 0, 0, delta_tracks, delta_lanes, 0, port_id, already_moved, \
519 error)
520
521#define arranger_selections_action_perform_move_midi( \
522 sel, ticks, delta_pitch, already_moved, error) \
523 arranger_selections_action_perform_move ( \
524 sel, ticks, 0, delta_pitch, 0, 0, 0, NULL, already_moved, error)
525#define arranger_selections_action_perform_duplicate_midi( \
526 sel, ticks, delta_pitch, already_moved, error) \
527 arranger_selections_action_perform_duplicate ( \
528 sel, ticks, 0, delta_pitch, 0, 0, 0, NULL, already_moved, error)
529#define arranger_selections_action_perform_move_chord( \
530 sel, ticks, delta_chords, already_moved, error) \
531 arranger_selections_action_perform_move ( \
532 sel, ticks, delta_chords, 0, 0, 0, 0, NULL, already_moved, error)
533#define arranger_selections_action_perform_duplicate_chord( \
534 sel, ticks, delta_chords, already_moved, error) \
535 arranger_selections_action_perform_duplicate ( \
536 sel, ticks, delta_chords, 0, 0, 0, 0, NULL, already_moved, error)
537
538#define arranger_selections_action_perform_move_automation( \
539 sel, ticks, norm_amt, already_moved, error) \
540 arranger_selections_action_perform_move ( \
541 sel, ticks, 0, 0, 0, 0, norm_amt, NULL, already_moved, error)
542#define arranger_selections_action_perform_duplicate_automation( \
543 sel, ticks, norm_amt, already_moved, error) \
544 arranger_selections_action_perform_duplicate ( \
545 sel, ticks, 0, 0, 0, 0, norm_amt, NULL, already_moved, error)
546
547bool
548arranger_selections_action_perform_link (
549 ArrangerSelections * sel_before,
550 ArrangerSelections * sel_after,
551 const double ticks,
552 const int delta_tracks,
553 const int delta_lanes,
554 const bool already_moved,
555 GError ** error);
556
557bool
558arranger_selections_action_perform_edit (
559 ArrangerSelections * sel_before,
560 ArrangerSelections * sel_after,
562 bool already_edited,
563 GError ** error);
564
565bool
566arranger_selections_action_perform_edit_single_obj (
567 const ArrangerObject * obj_before,
568 const ArrangerObject * obj_after,
570 bool already_edited,
571 GError ** error);
572
573bool
574arranger_selections_action_perform_edit_midi_function (
575 ArrangerSelections * sel_before,
576 MidiFunctionType midi_func_type,
577 MidiFunctionOpts opts,
578 GError ** error);
579
580bool
581arranger_selections_action_perform_edit_automation_function (
582 ArrangerSelections * sel_before,
583 AutomationFunctionType automation_func_type,
584 GError ** error);
585
586bool
587arranger_selections_action_perform_edit_audio_function (
588 ArrangerSelections * sel_before,
589 AudioFunctionType audio_func_type,
591 const char * uri,
592 GError ** error);
593
594bool
595arranger_selections_action_perform_automation_fill (
596 Region * region_before,
597 Region * region_after,
598 bool already_changed,
599 GError ** error);
600
601bool
602arranger_selections_action_perform_split (
603 ArrangerSelections * sel,
604 const Position * pos,
605 GError ** error);
606
607bool
608arranger_selections_action_perform_merge (
609 ArrangerSelections * sel,
610 GError ** error);
611
612bool
613arranger_selections_action_perform_resize (
614 ArrangerSelections * sel_before,
615 ArrangerSelections * sel_after,
617 const double ticks,
618 GError ** error);
619
620bool
621arranger_selections_action_perform_quantize (
622 ArrangerSelections * sel,
623 QuantizeOptions * opts,
624 GError ** error);
625
626int
627arranger_selections_action_do (ArrangerSelectionsAction * self, GError ** error);
628
629int
630arranger_selections_action_undo (
632 GError ** error);
633
634char *
635arranger_selections_action_stringize (ArrangerSelectionsAction * self);
636
637bool
638arranger_selections_action_contains_clip (
640 AudioClip * clip);
641
642void
643arranger_selections_action_free (ArrangerSelectionsAction * self);
644
649#endif
AUDIO functions.
API for selections in the AudioArrangerWidget.
Automation functions.
API for selections in the AutomationArrangerWidget.
API for selections in the piano roll.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_edit(ArrangerSelections *sel_before, ArrangerSelections *sel_after, ArrangerSelectionsActionEditType type, bool already_edited, GError **error)
Creates a new action for editing properties of an object.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_create_or_delete(ArrangerSelections *sel, const bool create, GError **error)
Creates a new action for creating/deleting objects.
ArrangerSelectionsActionResizeType
Type used when the action is a RESIZE action.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_resize(ArrangerSelections *sel_before, ArrangerSelections *sel_after, ArrangerSelectionsActionResizeType type, const double ticks, GError **error)
Creates a new action for resizing ArrangerObject's.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_split(ArrangerSelections *sel, const Position *pos, GError **error)
Creates a new action for splitting ArrangerObject's.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_automation_fill(Region *region_before, Region *region_after, bool already_changed, GError **error)
Creates a new action for automation autofill.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_quantize(ArrangerSelections *sel, QuantizeOptions *opts, GError **error)
Creates a new action for quantizing ArrangerObject's.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_edit_midi_function(ArrangerSelections *sel_before, MidiFunctionType midi_func_type, MidiFunctionOpts opts, GError **error)
Wrapper over arranger_selections_action_new_edit() for MIDI functions.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_edit_automation_function(ArrangerSelections *sel_before, AutomationFunctionType automation_func_type, GError **error)
Wrapper over arranger_selections_action_new_edit() for automation functions.
ArrangerSelectionsActionEditType
Type used when the action is an EDIT action.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_link(ArrangerSelections *sel_before, ArrangerSelections *sel_after, const double ticks, const int delta_tracks, const int delta_lanes, const bool already_moved, GError **error)
Creates a new action for linking regions.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_merge(ArrangerSelections *sel, GError **error)
Creates a new action for merging ArrangerObject's.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_edit_audio_function(ArrangerSelections *sel_before, AudioFunctionType audio_func_type, AudioFunctionOpts opts, const char *uri, GError **error)
Wrapper over arranger_selections_action_new_edit() for automation functions.
WARN_UNUSED_RESULT UndoableAction * arranger_selections_action_new_move_or_duplicate(ArrangerSelections *sel, const bool move, const double ticks, const int delta_chords, const int delta_pitch, const int delta_tracks, const int delta_lanes, const double delta_normalized_amount, const PortIdentifier *tgt_port_id, const bool already_moved, GError **error)
Creates a new action for moving or duplicating objects.
@ ARRANGER_SELECTIONS_ACTION_EDIT_SCALE
For editing the MusicalScale inside ScaleObject's.
@ ARRANGER_SELECTIONS_ACTION_EDIT_EDITOR_FUNCTION
For ramping MidiNote velocities or AutomationPoint values.
@ ARRANGER_SELECTIONS_ACTION_EDIT_POS
Edit a Position of the ArrangerObject's in the selection.
@ ARRANGER_SELECTIONS_ACTION_EDIT_FADES
Editing fade positions or curve options.
@ ARRANGER_SELECTIONS_ACTION_EDIT_MUTE
Change mute status.
@ ARRANGER_SELECTIONS_ACTION_EDIT_NAME
Edit the name of the ArrangerObject's in the selection.
@ ARRANGER_SELECTIONS_ACTION_EDIT_PRIMITIVE
Edit a primitive (int, etc) member of ArrangerObject's in the selection.
AudioFunctionType
API for selections in the piano roll.
MIDI functions.
Port identifier.
Position struct and API.
Quantize options.
Base struct for arranger objects.
double delta_normalized_amount
Difference in a normalized amount, such as automation point normalized value.
char * str
String, when changing a string.
ArrangerSelectionsActionType type
Action type.
PortIdentifier * target_port
Target port (used to find corresponding automation track when moving/copying automation regions to an...
ArrangerSelections * sel
A clone of the ArrangerSelections before the change.
int delta_chords
Chords moved (up/down in the Chord editor).
ArrangerObject * r1[800]
Used when splitting - these are the split ArrangerObject's.
ArrangerSelectionsActionEditType edit_type
Type of edit action, if an Edit action.
QuantizeOptions * opts
QuantizeOptions clone, if quantizing.
int num_split_objs
Number of split objects inside r1 and r2 each.
int delta_vel
Delta of MidiNote velocity.
Region * region_before
Used for automation autofill action.
Position pos
Position, when changing a Position.
bool first_run
If this is true, the first "do" call does nothing in some cases.
int delta_pitch
Delta of MidiNote pitch.
ArrangerSelections * sel_after
A clone of the ArrangerSelections after the change (used in the EDIT action and quantize).
Audio clips for the pool.
Definition clip.h:31
Selections to be used for the AudioArrangerWidget's current selections, copying, undoing,...
Selections to be used for the AutomationArrangerWidget's current selections, copying,...
Selections to be used for the ChordArrangerWidget's current selections, copying, undoing,...
A collection of selected MidiNote's.
A MIDI note inside a Region shown in the piano roll.
Definition midi_note.h:49
Struct used to identify Ports in the project.
A Position is made up of bars.beats.sixteenths.ticks.
Definition position.h:124
A region (clip) is an object on the timeline that contains either MidiNote's or AudioClip's.
Definition region.h:72
Selections to be used for the timeline's current selections, copying, undoing, etc.
Base struct to be inherited by implementing undoable actions.
Current TimelineArranger selections.
Undoable actions.