View Issue Details

IDProjectCategoryView StatusLast Update
0006604ardourbugspublic2015-09-24 15:08
Reportermatufts Assigned ToBenLoftis  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product VersionMixbus 3.0 
Summary0006604: midi VI will only sound after second transport roll
Descriptionmake a midi track
draw a note in the lane
roll transport (no audio produced)
roll transport again, now there will be audio
TagsNo tags attached.

Activities

x42

2015-09-23 21:55

administrator   ~0017342

Last edited: 2015-09-23 21:58

Same for deleting note.. (they will sound the first time)

The problem only exists if the change happens at or after the playhead, between playhead and midi-preload (default 1 second), and only if the change is made while the transport is not rolling.

Seeking before playing will also resolve this.


Tech-details:

The problem is MidiDiskstream::_playback_buf . The midi model is updated but the existing playback buffer is not.

If the change is made while rolling, midi_playlist()->region_edited() will special-case insert the notes into the live-stream. All good.


- The Midi Model (which changes) is a member of MidiSource.
- The Playlist has a reference to the Source(s).
- The Diskstream (where the buffer is) a reference to the playlist.

The GUI which triggers the change know nothing about the diskstream.

Playlists can change, as can sources.
So subscribing to the source's _model->ContentsChanged() in MidiDiskstream is also not realistic.
Furthermore writing or invalidating the playback_buf needs to be done from the butler thread. This will be tricky to resolve.

x42

2015-09-23 22:01

administrator   ~0017343

BTW. Ardour is also affected. Tested with Ardour 4.2-408-gfedec84 This issue is not Mixbus specific.

2015-09-24 15:06

 

midi_playback_buffer_flush.diff (1,626 bytes)   
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 6b71e3c..134cec8 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -385,6 +385,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
 	void adjust_capture_buffering();
 	void request_track_speed (Track *, double speed);
 	void request_input_change_handling ();
+	void flush_track_buffers ();
 
 	bool locate_pending() const { return static_cast<bool>(post_transport_work()&PostTransportLocate); }
 	bool transport_locked () const;
diff --git a/libs/ardour/midi_model.cc b/libs/ardour/midi_model.cc
index 3d53aba..35a3a82 100644
--- a/libs/ardour/midi_model.cc
+++ b/libs/ardour/midi_model.cc
@@ -99,6 +99,7 @@ MidiModel::apply_command(Session& session, Command* cmd)
 	session.begin_reversible_command(cmd->name());
 	(*cmd)();
 	session.commit_reversible_command(cmd);
+	session.flush_track_buffers ();
 	set_edited(true);
 }
 
@@ -112,6 +113,7 @@ MidiModel::apply_command_as_subcommand(Session& session, Command* cmd)
 {
 	(*cmd)();
 	session.add_command(cmd);
+	session.flush_track_buffers ();
 	set_edited(true);
 }
 
diff --git a/libs/ardour/session_butler.cc b/libs/ardour/session_butler.cc
index 613233c..ebca71e 100644
--- a/libs/ardour/session_butler.cc
+++ b/libs/ardour/session_butler.cc
@@ -121,3 +121,13 @@ Session::capture_load ()
 {
 	return (uint32_t) g_atomic_int_get (&_capture_load);
 }
+
+void
+Session::flush_track_buffers ()
+{
+	if (transport_rolling()) {
+		return;
+	}
+	add_post_transport_work (PostTransportLocate);
+	_butler->schedule_transport_work ();
+}

x42

2015-09-24 15:08

administrator   ~0017345

Attached patch flushes the buffer whenever a change is made (fixes this issue).

but: all buffers are flushed on every change.

Ideally: only changed buffers are flushed before stating to play (if no implicit buffer flush, eg seek, occurred).

more work is needed.

Issue History

Date Modified Username Field Change
2015-09-23 15:54 matufts New Issue
2015-09-23 15:55 matufts Assigned To => BenLoftis
2015-09-23 15:55 matufts Status new => assigned
2015-09-23 21:55 x42 Note Added: 0017342
2015-09-23 21:58 x42 Note Edited: 0017342
2015-09-23 22:01 x42 Note Added: 0017343
2015-09-24 15:06 x42 File Added: midi_playback_buffer_flush.diff
2015-09-24 15:08 x42 Note Added: 0017345