Commit graph

789 commits

Author SHA1 Message Date
Robin Gareus
63c78ebced Fix MIDI edit opertaiont (trim, draw) across tempo-changes
In the presence of tempo-changes distinguishing between offsets and
absolute positions is signficant. It is only valid to convert absolute
times using the tempo-map

Furthermore since GUI zoom-factor is time-invariant (samples per pixel),
all GUI operations must explictly use samples (or timecnt). It is not
valid (and problematic) to use use a location dependent timepos.
2022-10-23 19:12:31 +02:00
Paul Davis
173de9f0ef change MidiRegionView scroll behavior to somethings slightly more useful
1. leave tertiary-scroll for navigation and primary scroll for session timeline zoom
2. unmodified scroll in edit mode scrolls contents
3. secondary-scroll zooms in and out on contents (i.e. vertical zoom for MIDI)
4. primary-secondary scroll has the just-one-edge behavior previously provided
2022-09-30 16:32:29 -06:00
Paul Davis
47e9bb05c8 midi editing: if nudge clock says zero, use grid for nudging notes 2022-09-23 11:30:17 -06:00
Paul Davis
04d367fdfe midi note drawing: fix snap used to place ghost note 2022-09-22 16:16:20 -06:00
Paul Davis
d2fc142e21 infrastructure and implementation to allow "q" to drive quantize-selected-notes in midi edit mode 2022-08-31 13:53:55 -06:00
Paul Davis
b11ba8eec7 MIDI editing: primary+tertiary makes scroll do what it does when not editing 2022-08-31 12:16:14 -06:00
itmuckel
63f94d2946 Remove unused includes 2022-08-19 09:27:19 -06:00
Robin Gareus
c0ec11db8e
Cleanup code, return early, don't nest 2022-07-14 01:25:06 +02:00
Robin Gareus
b4a7c8a17d
Better version of 6a57baf193
This also fixes Menu > Edit Delete "delete MIDI" operation.
Pressing backspace/delete calls "Delete Selection" which is
unrelated to MRV::cut_copy_clear.
2022-07-14 01:23:04 +02:00
Robin Gareus
6a57baf193
Fix MIDI note cut
1. Editor::cut_copy() calls begin_reversible_command ("cut MIDI")
2. Editor::cut_copy_midi calls mrv->cut_copy_clear()
3. MidiRegionView::cut_copy_clear calls start_note_diff_command()
4. second call to  begin_reversible_command()
- debug builds assert() here, optimized builds continue
5. abort_reversible_command() is called, _current_trans = NULL;
6. MidiModel::apply_diff_command_as_subcommand()
7. Session::add_command, segfault because _current_trans == NULL

```
An UNDO transaction was started while a prior command was underway.
Aborting command (midi edit) and prior (cut MIDI)
```
2022-07-13 22:12:30 +02:00
Paul Davis
f631f742fa remove debug output 2022-06-29 08:17:16 -06:00
Paul Davis
fadf77e39c NO-OP: update comment to reflect the context 2022-06-28 12:24:54 -06:00
Paul Davis
5c2831e218 tempo display: modify how we implement MidiRegionView::_redisplay() so that the width is also correctly updated 2022-06-28 12:21:44 -06:00
Paul Davis
4acd63b2ef fix uninitialized variable (detected with valgrind) 2022-06-18 12:37:39 -06:00
Robin Gareus
86ddb11b9b
Fix displaying note events across tempo-changes
Note position in samples must be calculated using absolute position
on the timeline. Otherwise the tempo-map is not applied correctly.

Previously this caused issues since the position was first
offset back by _region->position() - time relative to region left
edge - and then the tempo-map was applied.

Another solution identically would be:
(note_start + session_source_start).samples() - _region->position().samples()
2022-06-17 17:07:47 +02:00
Ben Loftis
39f41e2357 fix midi-note Copy+Paste and Duplicate actions
* broken in 1fa7a7
2022-05-13 14:00:14 -05:00
Ben Loftis
41815f8d53 midi_region_view: use absolute_time_to_region_beats
* this fixes the location of the 'ghost note' that is shown
 when adding notes with the Draw tool
2022-05-12 12:15:53 -05:00
Ben Loftis
83d0892777 when drawing notes, the grid should be scaled to the zoom scale
this prevents the case where have enabled snap, and you add a note that
 appears to be on a bar line. but actually it is {some Grid value} off,
 it just looks right because of pixel rounding.
2022-05-11 11:45:33 -05:00
Ben Loftis
a60dfc19d2 take Snap enablement into account when drawing new notes
* snap_to_bbt assumes that snap is enabled and you want to snap to bbt
* snap_to() is the generic form to snap to the user's snap+grid settings
2022-05-11 11:38:54 -05:00
Ben Loftis
ee137333b9 midi_region_view: implement undo for duplicating a note selection 2022-05-10 15:47:56 -05:00
Ben Loftis
dbe49ae8c4 editor::paste fix a thinko in undo nesting 2022-05-10 15:47:56 -05:00
Ben Loftis
1fa7a72f72 midi_region_view: rename 'apply_diff' to 'apply_note_diff' for clarity
these functions operate on the _note_diff_command,
 which is explicitly a NoteDiff,  not a generic DiffCommand

also fix a few thinkos where the ambiguous naming led to errors
2022-05-10 15:47:48 -05:00
Ben Loftis
133600d5dc midi_region_view::apply_diff: implement using renamed midi_model functions 2022-05-10 15:47:48 -05:00
Ben Loftis
9fcf8b3a11 midi_region_view: rename commit_resizing -> finish_resizing
* 'commit' suggests that this function would commit an undo record
2022-05-10 15:47:48 -05:00
Ben Loftis
f9c9fd099d midi_region_view: adopt midi_model renaming (gtk patch_change part)
* apply_diff_command_as_commit explicitly tells us we don't
  need the begin/commit pair here
2022-05-10 15:47:47 -05:00
Paul Davis
9c9273e694 scrolling the midi track/region works only if pointed-at-region is selected 2022-05-10 11:45:52 -06:00
Paul Davis
126a85aaca midi editing: simple click on region in internal edit/draw modes selects region 2022-05-10 11:45:10 -06:00
Robin Gareus
fd33784e45
Suppres debug output from optimized builds
see also dc9eb38a27

Even though it may be useful to get timing information from
optimized builds, this should not be enabled by default.
2022-05-03 20:12:21 +02:00
Paul Davis
9e77d8923a MIDI: ctrl-d now duplicates selected notes
This commit also fixes selection-after-paste, so that the selection is always
the newly pasted notes.
2022-04-27 08:13:09 -06:00
Paul Davis
0852032e85 midi note editing: adjust scroll modifiers and allow range expansion as well as scroll 2022-04-17 23:23:45 -06:00
Paul Davis
b725b7ddb4 midi editing: scroll in a midi region with no selection will scroll the note range (#8721) 2022-04-17 23:16:50 -06:00
Paul Davis
a0d08232ad midi selection: implement MidiRegionView::set_selected()
This allows an MRV to clear its own selection of notes when
the region itself is deselected. This should help #8729 and #8899
2022-04-17 22:58:16 -06:00
Paul Davis
e01452c6a6 MIDI editing: clean up logic for ::note_selected()
The behavior should be the same but the logical intent of the code is now more
obvious.
2022-04-17 22:17:09 -06:00
Paul Davis
95b1943978 midi editing: when transposing, expand MIDI streamview note range when/as necessary so that notes do not vanish 2022-04-17 12:03:36 -06:00
Paul Davis
bde3f3a277 midi region view: allow change_note_note() to return the new note value 2022-04-17 12:02:53 -06:00
Paul Davis
3315a6588a midi regon view: fix logic error introduced when redisplay was split between model_changed and view_changed 2022-04-17 12:02:18 -06:00
Paul Davis
dc9eb38a27 Revert "MIDI region view: remove debug/analysis output"
This reverts commit d01ad0b4d4.

These are still useful.
2022-04-05 21:03:05 -06:00
Paul Davis
d01ad0b4d4 MIDI region view: remove debug/analysis output 2022-04-05 20:52:10 -06:00
Paul Davis
6ac9c52b5f remove debug output and some mistakenly commented lines 2022-04-05 20:52:10 -06:00
Paul Davis
4fa97e2c50 split midi region view redisplay into two similar methods
::model_changed() is used when the model has changed (eg. new notes or some
notes deleted); ::view_changed() is used when only some view parameter (e.g.
zoom, scroll, track height etc) has been altered.

Not fully functional yet (::view_chanted() ignores scroll)
2022-04-05 20:52:10 -06:00
Paul Davis
0638d3c99e remove use of canvas freeze-queue-draw API
Measurement shows that this makes no actual difference to the speed
of marking up the canvas for a redraw
2022-04-05 20:52:10 -06:00
Paul Davis
3ff4d6c5ab some instrumentation for MidiRegionView::redisplay_model() 2022-04-05 20:52:10 -06:00
Paul Davis
cc0869d931 restore setting selection in MidiRegionView::redisplay_model() 2022-04-05 20:52:10 -06:00
Paul Davis
b8a6b97b49 redesign (MIDI)RegionView display disabling around an RAII model 2022-04-05 20:52:10 -06:00
Paul Davis
d586956636 NOOP: some minor whitespace fixes 2022-04-05 20:52:09 -06:00
Paul Davis
7c6bce5cda fix recursive loop in patch change display
We do not want a loop between ::add_canvas_patch_change() and
::display_patch_changes(), even if it does bottom out in the end
2022-04-05 20:52:09 -06:00
Paul Davis
ae8c043fe1 regionviews: use integer counter instead of boolean to control redisplay of contents 2022-04-05 20:52:09 -06:00
Paul Davis
1686db8b0c Change the type of reference held by a MidiModel to its MidiSource
This also requires a change in the type of reference held by
a MidiAutomationListBinder.

Both the MidiSource and MidiModel have a reference to each other, and it is
important that we avoid circular references to avoid problems with object
destruction. We had been accomplishing this by having the Model hold a
weak_ptr<MidiSource>. However, the lifetime of a MidiSource and its MidiModel
are coincident and there's really no need to use a smart ptr at all. A normal
reference is just fine. However, due to constructors that accept a serialized
state, we cannot use an actual reference (we cannot set the constructor in the
initializer list), so we use a bare ptr instead.

This forces a similar change in MidiAutomationListBinder, which also maintains
a reference to the Source. However, the only purpose of this object is to
ensure that if the Source is destroyed, relevant commands will be removed from
the undo/redo history, and so all that matters here is that the binder connects
to the Destroyed signal of the source, and arranges for its own destruction
when received.

Note that the previous construction of the binder, actually holding a
shared_ptr<MidiSource> would appear have prevented the Destroyed signal from
ever being emitted (from ~Destructible), and so this may also be a bug fix that
allows MidiSources to actually be deleted (the memory object, not the file).
2022-04-05 20:52:09 -06:00
Paul Davis
22a56de13a use canvas freeze-queue-draw API when redrawing a MIDI region 2022-04-05 20:52:09 -06:00
Robin Gareus
3c03e4951e
Use updated temporal API 2/2 2021-12-11 15:51:31 +01:00