X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fauditioner.cc;h=a202fd85548f684f4a9e4f338af821064d865d82;hb=4250940ad83200e065b966d0646c75a48bb0f73d;hp=98d4f6c92a652299bec1b66f386c691e331944cf;hpb=35c7274cc96a04f166df78249e66ae4a32a53a66;p=ardour.git diff --git a/libs/ardour/auditioner.cc b/libs/ardour/auditioner.cc index 98d4f6c92a..a202fd8554 100644 --- a/libs/ardour/auditioner.cc +++ b/libs/ardour/auditioner.cc @@ -47,10 +47,10 @@ using namespace PBD; Auditioner::Auditioner (Session& s) : Track (s, "auditioner", PresentationInfo::Auditioner) - , current_frame (0) + , current_sample (0) , _auditioning (0) , length (0) - , _seek_frame (-1) + , _seek_sample (-1) , _seeking (false) , _seek_complete (false) , via_monitor (false) @@ -74,6 +74,7 @@ Auditioner::init () } _output->add_port ("", this, DataType::MIDI); + use_new_playlist (DataType::MIDI); lookup_synth(); @@ -96,7 +97,7 @@ Auditioner::lookup_synth () { string plugin_id = Config->get_midi_audition_synth_uri(); asynth.reset (); - if (!plugin_id.empty()) { + if (!plugin_id.empty() || plugin_id == X_("@default@")) { boost::shared_ptr p; p = find_plugin (_session, plugin_id, ARDOUR::LV2); if (!p) { @@ -112,6 +113,9 @@ Auditioner::lookup_synth () } } if (p) { + if (plugin_id == X_("@default@")) { + Config->set_midi_audition_synth_uri (p->get_info()->unique_id); + } asynth = boost::shared_ptr (new PluginInsert (_session, p)); } } @@ -216,7 +220,7 @@ Auditioner::data_type () const { } int -Auditioner::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& need_butler) +Auditioner::roll (pframes_t nframes, samplepos_t start_sample, samplepos_t end_sample, int declick, bool& need_butler) { Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK); if (!lm.locked()) { @@ -227,9 +231,6 @@ Auditioner::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram BufferSet& bufs = _session.get_route_buffers (n_process_buffers()); - _silent = false; - _amp->apply_gain_automation(false); - if (_queue_panic) { MidiBuffer& mbuf (bufs.get_midi (0)); _queue_panic = false; @@ -243,7 +244,15 @@ Auditioner::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram } } - process_output_buffers (bufs, start_frame, end_frame, nframes, declick, !_session.transport_stopped()); + process_output_buffers (bufs, start_sample, end_sample, nframes, declick, !_session.transport_stopped(), true); + + /* note: auditioner never writes to disk, so we don't care about the + * disk writer status (it's buffers will always have no data in them). + */ + + if (_disk_reader->need_butler()) { + need_butler = true; + } for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { boost::shared_ptr d = boost::dynamic_pointer_cast (*i); @@ -255,26 +264,6 @@ Auditioner::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram return 0; } -AudioPlaylist& -Auditioner::prepare_playlist () -{ - // used by CrossfadeEditor::audition() - - _midi_audition = false; - - if (_synth_added) { - remove_processor(asynth); - _synth_added = false; - } - - // FIXME auditioner is still audio-only - boost::shared_ptr apl = boost::dynamic_pointer_cast(playlist()); - assert(apl); - - apl->clear (); - return *apl; -} - void Auditioner::audition_region (boost::shared_ptr region) { @@ -302,6 +291,8 @@ Auditioner::audition_region (boost::shared_ptr region) the_region = boost::dynamic_pointer_cast (RegionFactory::create (region)); the_region->set_position (0); + _disk_reader->midi_playlist()->drop_regions (); + _disk_reader->audio_playlist()->drop_regions (); _disk_reader->audio_playlist()->add_region (the_region, 0, 1); @@ -326,6 +317,8 @@ Auditioner::audition_region (boost::shared_ptr region) midi_region = (boost::dynamic_pointer_cast (RegionFactory::create (region))); midi_region->set_position (_import_position); + _disk_reader->audio_playlist()->drop_regions(); + _disk_reader->midi_playlist()->drop_regions (); _disk_reader->midi_playlist()->add_region (midi_region, _import_position, 1); _disk_reader->reset_tracker(); @@ -370,11 +363,11 @@ Auditioner::audition_region (boost::shared_ptr region) /* force a panner reset now that we have all channels */ _main_outs->reset_panner(); - _seek_frame = -1; + _seek_sample = -1; _seeking = false; int dir; - framecnt_t offset; + samplecnt_t offset; if (_midi_audition) { length = midi_region->length(); @@ -391,16 +384,16 @@ Auditioner::audition_region (boost::shared_ptr region) } _disk_reader->seek (offset, true); - current_frame = offset; + current_sample = offset; g_atomic_int_set (&_auditioning, 1); } int -Auditioner::play_audition (framecnt_t nframes) +Auditioner::play_audition (samplecnt_t nframes) { bool need_butler = false; - framecnt_t this_nframes; + samplecnt_t this_nframes; int ret; if (g_atomic_int_get (&_auditioning) == 0) { @@ -411,7 +404,7 @@ Auditioner::play_audition (framecnt_t nframes) #if 0 // TODO if (_seeking && _seek_complete) { // set FADE-IN - } else if (_seek_frame >= 0 && _seek_frame < length && !_seeking) { + } else if (_seek_sample >= 0 && _seek_sample < length && !_seeking) { // set FADE-OUT -- use/override amp? || use region-gain ? } #endif @@ -419,26 +412,26 @@ Auditioner::play_audition (framecnt_t nframes) if (_seeking && _seek_complete) { _seek_complete = false; _seeking = false; - _seek_frame = -1; + _seek_sample = -1; _disk_reader->reset_tracker(); } if(!_seeking) { /* process audio */ - this_nframes = min (nframes, length - current_frame + _import_position); + this_nframes = min (nframes, length - current_sample + _import_position); - if ((ret = roll (this_nframes, current_frame, current_frame + nframes, false, need_butler)) != 0) { + if ((ret = roll (this_nframes, current_sample, current_sample + nframes, false, need_butler)) != 0) { silence (nframes); return ret; } - current_frame += this_nframes; + current_sample += this_nframes; } else { silence (nframes); } - if (_seek_frame >= 0 && _seek_frame < length && !_seeking) { + if (_seek_sample >= 0 && _seek_sample < length && !_seeking) { _queue_panic = true; _seek_complete = false; _seeking = true; @@ -446,10 +439,10 @@ Auditioner::play_audition (framecnt_t nframes) } if (!_seeking) { - AuditionProgress(current_frame - _import_position, length); /* emit */ + AuditionProgress(current_sample - _import_position, length); /* emit */ } - if (current_frame >= length + _import_position) { + if (current_sample >= length + _import_position) { _session.cancel_audition (); return 0; } else { @@ -510,8 +503,12 @@ Auditioner::input_streams () const depends solely on the region we are auditioning. */ - if (_disk_reader) { - return _disk_reader->input_streams (); + if (_midi_audition) { + return ChanCount (DataType::MIDI, 1); + } else { + if (the_region) { + return ChanCount (DataType::AUDIO, the_region->n_channels ()); + } } return ChanCount (DataType::AUDIO, 1);