mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-17 04:06:26 +01:00
Allow to skip setting MIDI patch on session-load #8743
Ardour MIDI tracks unconditionally remember any MIDI CC/Patch changes that are received. Patch changes are re-played after the session is loaded, so that they can reach external synths after ports are re-connected. This can lead to issues with synth plugins. Their state is set first. Receiving a patch-change may alter the synth's state.
This commit is contained in:
parent
446dcbd8ce
commit
de3291d10b
2 changed files with 47 additions and 3 deletions
|
|
@ -138,6 +138,9 @@ public:
|
||||||
bool input_active () const;
|
bool input_active () const;
|
||||||
PBD::Signal0<void> InputActiveChanged;
|
PBD::Signal0<void> InputActiveChanged;
|
||||||
|
|
||||||
|
void set_restore_pgm_on_load (bool yn);
|
||||||
|
bool restore_pgm_on_load () const;
|
||||||
|
|
||||||
void realtime_handle_transport_stopped ();
|
void realtime_handle_transport_stopped ();
|
||||||
void region_edited (boost::shared_ptr<Region>);
|
void region_edited (boost::shared_ptr<Region>);
|
||||||
|
|
||||||
|
|
@ -159,6 +162,7 @@ private:
|
||||||
NoteMode _note_mode;
|
NoteMode _note_mode;
|
||||||
bool _step_editing;
|
bool _step_editing;
|
||||||
bool _input_active;
|
bool _input_active;
|
||||||
|
bool _restore_pgm_on_load;
|
||||||
MidiChannelFilter _playback_filter;
|
MidiChannelFilter _playback_filter;
|
||||||
MidiChannelFilter _capture_filter;
|
MidiChannelFilter _capture_filter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ MidiTrack::MidiTrack (Session& sess, string name, TrackMode mode)
|
||||||
, _note_mode (Sustained)
|
, _note_mode (Sustained)
|
||||||
, _step_editing (false)
|
, _step_editing (false)
|
||||||
, _input_active (true)
|
, _input_active (true)
|
||||||
|
, _restore_pgm_on_load (true)
|
||||||
{
|
{
|
||||||
_session.SessionLoaded.connect_same_thread (*this, boost::bind (&MidiTrack::restore_controls, this));
|
_session.SessionLoaded.connect_same_thread (*this, boost::bind (&MidiTrack::restore_controls, this));
|
||||||
|
|
||||||
|
|
@ -173,6 +174,10 @@ MidiTrack::set_state (const XMLNode& node, int version)
|
||||||
set_input_active (yn);
|
set_input_active (yn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node.get_property ("restore-pgm", yn)) {
|
||||||
|
set_restore_pgm_on_load (yn);
|
||||||
|
}
|
||||||
|
|
||||||
ChannelMode playback_channel_mode = AllChannels;
|
ChannelMode playback_channel_mode = AllChannels;
|
||||||
ChannelMode capture_channel_mode = AllChannels;
|
ChannelMode capture_channel_mode = AllChannels;
|
||||||
|
|
||||||
|
|
@ -251,6 +256,7 @@ MidiTrack::state(bool save_template)
|
||||||
root.set_property ("note-mode", _note_mode);
|
root.set_property ("note-mode", _note_mode);
|
||||||
root.set_property ("step-editing", _step_editing);
|
root.set_property ("step-editing", _step_editing);
|
||||||
root.set_property ("input-active", _input_active);
|
root.set_property ("input-active", _input_active);
|
||||||
|
root.set_property ("restore-pgm", _restore_pgm_on_load);
|
||||||
|
|
||||||
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
||||||
if (boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second)) {
|
if (boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second)) {
|
||||||
|
|
@ -330,10 +336,22 @@ MidiTrack::set_state_part_two ()
|
||||||
void
|
void
|
||||||
MidiTrack::restore_controls ()
|
MidiTrack::restore_controls ()
|
||||||
{
|
{
|
||||||
// TODO order events (CC before PGM to set banks)
|
/* first CC (bank select) */
|
||||||
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
||||||
boost::shared_ptr<MidiTrack::MidiControl> mctrl = boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second);
|
boost::shared_ptr<MidiTrack::MidiControl> mctrl = boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second);
|
||||||
if (mctrl) {
|
if (mctrl && mctrl->parameter().type () != MidiPgmChangeAutomation) {
|
||||||
|
mctrl->restore_value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_restore_pgm_on_load) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* then restore PGM */
|
||||||
|
for (Controls::const_iterator c = _controls.begin(); c != _controls.end(); ++c) {
|
||||||
|
boost::shared_ptr<MidiTrack::MidiControl> mctrl = boost::dynamic_pointer_cast<MidiTrack::MidiControl>(c->second);
|
||||||
|
if (mctrl && mctrl->parameter().type () == MidiPgmChangeAutomation) {
|
||||||
mctrl->restore_value();
|
mctrl->restore_value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -664,8 +682,14 @@ MidiTrack::MidiControl::actually_set_value (double val, PBD::Controllable::Group
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_session.loading ()) {
|
||||||
|
/* send events later in MidiTrack::restore_controls */
|
||||||
|
AutomationControl::actually_set_value (val, group_override);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
assert(val <= desc.upper);
|
assert(val <= desc.upper);
|
||||||
if ( ! _list || ! automation_playback()) {
|
if (!_list || !automation_playback ()) {
|
||||||
size_t size = 3;
|
size_t size = 3;
|
||||||
uint8_t ev[3] = { parameter.channel(), uint8_t (val), 0 };
|
uint8_t ev[3] = { parameter.channel(), uint8_t (val), 0 };
|
||||||
switch(parameter.type()) {
|
switch(parameter.type()) {
|
||||||
|
|
@ -766,6 +790,22 @@ MidiTrack::midi_playlist ()
|
||||||
return boost::dynamic_pointer_cast<MidiPlaylist> (_playlists[DataType::MIDI]);
|
return boost::dynamic_pointer_cast<MidiPlaylist> (_playlists[DataType::MIDI]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MidiTrack::set_restore_pgm_on_load (bool yn)
|
||||||
|
{
|
||||||
|
if (_restore_pgm_on_load == yn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_restore_pgm_on_load = yn;
|
||||||
|
_session.set_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
MidiTrack::restore_pgm_on_load () const
|
||||||
|
{
|
||||||
|
return _restore_pgm_on_load;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MidiTrack::input_active () const
|
MidiTrack::input_active () const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue