, via_monitor (false)
, _midi_audition (false)
, _synth_added (false)
+ , _synth_changed (false)
, _queue_panic (false)
+ , _import_position (0)
{
}
_output->add_port ("Midiaudition", this, DataType::MIDI);
+ lookup_synth();
+
+ _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2));
+ Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Auditioner::config_changed, this, _1));
+
+ return 0;
+}
+
+Auditioner::~Auditioner ()
+{
+}
+
+void
+Auditioner::lookup_synth ()
+{
string plugin_id = Config->get_midi_audition_synth_uri();
- boost::shared_ptr<Plugin> p;
+ asynth = boost::shared_ptr<Processor>();
if (!plugin_id.empty()) {
+ boost::shared_ptr<Plugin> p;
p = find_plugin (_session, plugin_id, ARDOUR::LV2);
if (!p) {
p = find_plugin (_session, "https://community.ardour.org/node/7596", ARDOUR::LV2);
warning << _("No synth for midi-audition found.") << endmsg;
}
}
+ if (p) {
+ asynth = boost::shared_ptr<Processor> (new PluginInsert (_session, p));
+ }
}
- if (p) {
- asynth = boost::shared_ptr<Processor> (new PluginInsert (_session, p));
- }
-
- _output->changed.connect_same_thread (*this, boost::bind (&Auditioner::output_changed, this, _1, _2));
-
- return 0;
}
-Auditioner::~Auditioner ()
+void
+Auditioner::config_changed (std::string p)
{
+ if (p == "midi-audition-synth-uri") {
+ _synth_changed = true;
+ }
}
int
_synth_added = false;
}
midi_region.reset();
+ _import_position = 0;
/* copy it */
the_region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region));
_midi_audition = true;
set_diskstream(_diskstream_midi);
the_region.reset();
+ _import_position = region->position();
/* copy it */
midi_region = (boost::dynamic_pointer_cast<MidiRegion> (RegionFactory::create (region)));
- midi_region->set_position (0);
+ midi_region->set_position (_import_position);
_diskstream->playlist()->drop_regions ();
- _diskstream->playlist()->add_region (midi_region, 0, 1);
+ _diskstream->playlist()->add_region (midi_region, _import_position, 1);
midi_diskstream()->reset_tracker();
ProcessorStreams ps;
+ if (_synth_changed && _synth_added) {
+ remove_processor(asynth);
+ _synth_added = false;
+ }
+ if (_synth_changed && !_synth_added) {
+ _synth_added = false;
+ lookup_synth();
+ }
+
+
if (!_synth_added && asynth) {
int rv = add_processor_by_index(asynth, PreFader, &ps, true);
if (rv) {
if (_midi_audition) {
length = midi_region->length();
- offset = midi_region->sync_offset (dir);
+ offset = _import_position + midi_region->sync_offset (dir);
} else {
length = the_region->length();
offset = the_region->sync_offset (dir);
}
if (!_seeking) {
- AuditionProgress(current_frame, length); /* emit */
+ AuditionProgress(current_frame - _import_position, length); /* emit */
}
if (current_frame >= length) {