Fix another hardcoded "tar.xz" -> ARDOUR::session_archive_suffix
[ardour.git] / libs / ardour / lv2_plugin.cc
index b51db6548526efd1184ae173a602342d731c6c92..46c80d56580c1210e5fa1a2e334046eef807ab47 100644 (file)
@@ -353,7 +353,7 @@ struct LV2Plugin::Impl {
 LV2Plugin::LV2Plugin (AudioEngine& engine,
                       Session&     session,
                       const void*  c_plugin,
-                      framecnt_t   rate)
+                      samplecnt_t   rate)
        : Plugin (engine, session)
        , Workee ()
        , _impl(new Impl())
@@ -391,7 +391,7 @@ LV2Plugin::LV2Plugin (const LV2Plugin& other)
 }
 
 void
-LV2Plugin::init(const void* c_plugin, framecnt_t rate)
+LV2Plugin::init(const void* c_plugin, samplecnt_t rate)
 {
        DEBUG_TRACE(DEBUG::LV2, "init\n");
 
@@ -407,7 +407,7 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate)
        _bpm_control_port       = 0;
        _freewheel_control_port = 0;
        _latency_control_port   = 0;
-       _next_cycle_start       = std::numeric_limits<framepos_t>::max();
+       _next_cycle_start       = std::numeric_limits<samplepos_t>::max();
        _next_cycle_speed       = 1.0;
        _seq_size               = _engine.raw_buffer_size(DataType::MIDI);
        _state_version          = 0;
@@ -788,7 +788,7 @@ LV2Plugin::init(const void* c_plugin, framecnt_t rate)
                        lilv_port_get_range(plugin, port, &def, NULL, NULL);
                        _defaults[i] = def ? lilv_node_as_float(def) : 0.0f;
                        if (lilv_port_has_property (plugin, port, _world.lv2_sampleRate)) {
-                               _defaults[i] *= _session.frame_rate ();
+                               _defaults[i] *= _session.sample_rate ();
                        }
                        lilv_node_free(def);
 
@@ -901,7 +901,7 @@ LV2Plugin::requires_fixed_sized_buffers () const
         */
        if (get_info()->n_inputs.n_midi() > 0) {
                /* we don't yet implement midi buffer offsets (for split cycles).
-                * Also connect_and_run() also uses _session.transport_frame() directly
+                * Also connect_and_run() also uses _session.transport_sample() directly
                 * (for BBT) which is not offset for plugin cycle split.
                 */
                return true;
@@ -1721,7 +1721,7 @@ LV2Plugin::write_from_ui(uint32_t       index,
                if (_atom_ev_buffers && _atom_ev_buffers[0]) {
                        bufsiz =  lv2_evbuf_get_capacity(_atom_ev_buffers[0]);
                }
-               int fact = ceilf(_session.frame_rate () / 3000.f);
+               int fact = ceilf(_session.sample_rate () / 3000.f);
                rbs = max((size_t) bufsiz * std::max (8, fact), rbs);
                _from_ui = new RingBuffer<uint8_t>(rbs);
        }
@@ -1825,19 +1825,19 @@ LV2Plugin::set_property(uint32_t key, const Variant& value)
 
        // Set up forge to write to temporary buffer on the stack
        LV2_Atom_Forge*      forge = &_impl->ui_forge;
-       LV2_Atom_Forge_Frame frame;
+       LV2_Atom_Forge_Frame sample;
        uint8_t              buf[PATH_MAX];  // Ought to be enough for anyone...
 
        lv2_atom_forge_set_buffer(forge, buf, sizeof(buf));
 
        // Serialize patch:Set message to set property
 #ifdef HAVE_LV2_1_10_0
-       lv2_atom_forge_object(forge, &frame, 0, _uri_map.urids.patch_Set);
+       lv2_atom_forge_object(forge, &sample, 0, _uri_map.urids.patch_Set);
        lv2_atom_forge_key(forge, _uri_map.urids.patch_property);
        lv2_atom_forge_urid(forge, key);
        lv2_atom_forge_key(forge, _uri_map.urids.patch_value);
 #else
-       lv2_atom_forge_blank(forge, &frame, 0, _uri_map.urids.patch_Set);
+       lv2_atom_forge_blank(forge, &sample, 0, _uri_map.urids.patch_Set);
        lv2_atom_forge_property_head(forge, _uri_map.urids.patch_property, 0);
        lv2_atom_forge_urid(forge, key);
        lv2_atom_forge_property_head(forge, _uri_map.urids.patch_value, 0);
@@ -1988,16 +1988,16 @@ LV2Plugin::announce_property_values()
 
        // Set up forge to write to temporary buffer on the stack
        LV2_Atom_Forge*      forge = &_impl->ui_forge;
-       LV2_Atom_Forge_Frame frame;
+       LV2_Atom_Forge_Frame sample;
        uint8_t              buf[PATH_MAX];  // Ought to be enough for anyone...
 
        lv2_atom_forge_set_buffer(forge, buf, sizeof(buf));
 
        // Serialize patch:Get message with no subject (implicitly plugin instance)
 #ifdef HAVE_LV2_1_10_0
-       lv2_atom_forge_object(forge, &frame, 0, _uri_map.urids.patch_Get);
+       lv2_atom_forge_object(forge, &sample, 0, _uri_map.urids.patch_Get);
 #else
-       lv2_atom_forge_blank(forge, &frame, 0, _uri_map.urids.patch_Get);
+       lv2_atom_forge_blank(forge, &sample, 0, _uri_map.urids.patch_Get);
 #endif
 
        // Write message to UI=>Plugin ring
@@ -2202,8 +2202,8 @@ LV2Plugin::get_parameter_descriptor(uint32_t which, ParameterDescriptor& desc) c
        load_parameter_descriptor_units(_world.world, desc, portunits);
 
        if (desc.sr_dependent) {
-               desc.lower *= _session.frame_rate ();
-               desc.upper *= _session.frame_rate ();
+               desc.lower *= _session.sample_rate ();
+               desc.upper *= _session.sample_rate ();
        }
 
        desc.enumeration = lilv_port_has_property(_impl->plugin, port, _world.lv2_enumeration);
@@ -2346,17 +2346,17 @@ LV2Plugin::describe_parameter(Evoral::Parameter which)
        }
 }
 
-framecnt_t
+samplecnt_t
 LV2Plugin::max_latency () const
 {
        return _max_latency;
 }
 
-framecnt_t
+samplecnt_t
 LV2Plugin::signal_latency() const
 {
        if (_latency_control_port) {
-               return (framecnt_t)floor(*_latency_control_port);
+               return (samplecnt_t)floor(*_latency_control_port);
        } else {
                return 0;
        }
@@ -2498,17 +2498,17 @@ write_position(LV2_Atom_Forge*     forge,
                Timecode::BBT_Time& bbt,
                double              speed,
                double              bpm,
-               framepos_t          position,
-               framecnt_t          offset)
+               samplepos_t          position,
+               samplecnt_t          offset)
 {
        const URIMap::URIDs& urids = URIMap::instance().urids;
 
        uint8_t pos_buf[256];
        lv2_atom_forge_set_buffer(forge, pos_buf, sizeof(pos_buf));
-       LV2_Atom_Forge_Frame frame;
+       LV2_Atom_Forge_Frame sample;
 #ifdef HAVE_LV2_1_10_0
-       lv2_atom_forge_object(forge, &frame, 0, urids.time_Position);
-       lv2_atom_forge_key(forge, urids.time_frame);
+       lv2_atom_forge_object(forge, &sample, 0, urids.time_Position);
+       lv2_atom_forge_key(forge, urids.time_sample);
        lv2_atom_forge_long(forge, position);
        lv2_atom_forge_key(forge, urids.time_speed);
        lv2_atom_forge_float(forge, speed);
@@ -2524,8 +2524,8 @@ write_position(LV2_Atom_Forge*     forge,
        lv2_atom_forge_key(forge, urids.time_beatsPerMinute);
        lv2_atom_forge_float(forge, bpm);
 #else
-       lv2_atom_forge_blank(forge, &frame, 1, urids.time_Position);
-       lv2_atom_forge_property_head(forge, urids.time_frame, 0);
+       lv2_atom_forge_blank(forge, &sample, 1, urids.time_Position);
+       lv2_atom_forge_property_head(forge, urids.time_sample, 0);
        lv2_atom_forge_long(forge, position);
        lv2_atom_forge_property_head(forge, urids.time_speed, 0);
        lv2_atom_forge_float(forge, speed);
@@ -2550,9 +2550,9 @@ write_position(LV2_Atom_Forge*     forge,
 
 int
 LV2Plugin::connect_and_run(BufferSet& bufs,
-               framepos_t start, framepos_t end, double speed,
+               samplepos_t start, samplepos_t end, double speed,
                ChanMapping in_map, ChanMapping out_map,
-               pframes_t nframes, framecnt_t offset)
+               pframes_t nframes, samplecnt_t offset)
 {
        DEBUG_TRACE(DEBUG::LV2, string_compose("%1 run %2 offset %3\n", name(), nframes, offset));
        Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset);
@@ -2568,7 +2568,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
        }
 
        if (_bpm_control_port) {
-               *_bpm_control_port = tmap.tempo_at_frame (start).note_types_per_minute();
+               *_bpm_control_port = tmap.tempo_at_sample (start).note_types_per_minute();
        }
 
 #ifdef LV2_EXTENDED
@@ -2639,8 +2639,8 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
 
                        if (valid && (flags & PORT_INPUT)) {
                                if ((flags & PORT_POSITION)) {
-                                       Timecode::BBT_Time bbt (tmap.bbt_at_frame (start));
-                                       double bpm = tmap.tempo_at_frame (start).note_types_per_minute();
+                                       Timecode::BBT_Time bbt (tmap.bbt_at_sample (start));
+                                       double bpm = tmap.tempo_at_sample (start).note_types_per_minute();
                                        double beatpos = (bbt.bars - 1) * tmetric.meter().divisions_per_bar()
                                                       + (bbt.beats - 1)
                                                       + (bbt.ticks / Timecode::BBT_Time::ticks_per_beat);
@@ -2665,14 +2665,14 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
 
                                // Now merge MIDI and any transport events into the buffer
                                const uint32_t     type = _uri_map.urids.midi_MidiEvent;
-                               const framepos_t   tend = end;
+                               const samplepos_t   tend = end;
                                ++metric_i;
                                while (m != m_end || (metric_i != tmap.metrics_end() &&
-                                                     (*metric_i)->frame() < tend)) {
+                                                     (*metric_i)->sample() < tend)) {
                                        MetricSection* metric = (metric_i != tmap.metrics_end())
                                                ? *metric_i : NULL;
-                                       if (m != m_end && (!metric || metric->frame() > (*m).time())) {
-                                               const Evoral::Event<framepos_t> ev(*m, false);
+                                       if (m != m_end && (!metric || metric->sample() > (*m).time())) {
+                                               const Evoral::Event<samplepos_t> ev(*m, false);
                                                if (ev.time() < nframes) {
                                                        LV2_Evbuf_Iterator eend = lv2_evbuf_end(_ev_buffers[port_index]);
                                                        lv2_evbuf_write(&eend, ev.time(), 0, type, ev.size(), ev.buffer());
@@ -2681,12 +2681,12 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                        } else {
                                                tmetric.set_metric(metric);
                                                Timecode::BBT_Time bbt;
-                                               bbt = tmap.bbt_at_frame (metric->frame());
-                                               double bpm = tmap.tempo_at_frame (start/*XXX*/).note_types_per_minute();
+                                               bbt = tmap.bbt_at_sample (metric->sample());
+                                               double bpm = tmap.tempo_at_sample (start/*XXX*/).note_types_per_minute();
                                                write_position(&_impl->forge, _ev_buffers[port_index],
                                                               tmetric, bbt, speed, bpm,
-                                                              metric->frame(),
-                                                              metric->frame() - start);
+                                                              metric->sample(),
+                                                              metric->sample() - start);
                                                ++metric_i;
                                        }
                                }
@@ -2778,9 +2778,9 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                        for (LV2_Evbuf_Iterator i = lv2_evbuf_begin(buf);
                             lv2_evbuf_is_valid(i);
                             i = lv2_evbuf_next(i)) {
-                               uint32_t frames, subframes, type, size;
+                               uint32_t samples, subframes, type, size;
                                uint8_t* data;
-                               lv2_evbuf_get(i, &frames, &subframes, &type, &size, &data);
+                               lv2_evbuf_get(i, &samples, &subframes, &type, &size, &data);
 
 #ifdef LV2_EXTENDED
                                // Intercept Automation Write Events
@@ -2802,13 +2802,13 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                                const float v = ((const LV2_Atom_Float*)value)->body;
                                                                // -> add automation event..
                                                                DEBUG_TRACE(DEBUG::LV2Automate,
-                                                                               string_compose ("Event p: %1 t: %2 v: %3\n", p, frames, v));
+                                                                               string_compose ("Event p: %1 t: %2 v: %3\n", p, samples, v));
                                                                AutomationCtrlPtr c = get_automation_control (p);
                                                                if (c &&
                                                                     (c->ac->automation_state() == Touch || c->ac->automation_state() == Write)
                                                                   ) {
-                                                                       framepos_t when = std::max ((framepos_t) 0, start + frames - _current_latency);
-                                                                       assert (start + frames - _current_latency >= 0);
+                                                                       samplepos_t when = std::max ((samplepos_t) 0, start + samples - _current_latency);
+                                                                       assert (start + samples - _current_latency >= 0);
                                                                        if (c->guard) {
                                                                                c->guard = false;
                                                                                c->ac->list()->add (when, v, true, true);
@@ -2870,7 +2870,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                                AutomationCtrlPtr c = get_automation_control (p);
                                                                DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("Start Touch p: %1\n", p));
                                                                if (c) {
-                                                                       c->ac->start_touch (std::max ((framepos_t)0, start - _current_latency));
+                                                                       c->ac->start_touch (std::max ((samplepos_t)0, start - _current_latency));
                                                                        c->guard = true;
                                                                }
                                                        }
@@ -2885,7 +2885,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                                AutomationCtrlPtr c = get_automation_control (p);
                                                                DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("End Touch p: %1\n", p));
                                                                if (c) {
-                                                                       c->ac->stop_touch (std::max ((framepos_t)0, start - _current_latency));
+                                                                       c->ac->stop_touch (std::max ((samplepos_t)0, start - _current_latency));
                                                                }
                                                        }
                                                }
@@ -2955,17 +2955,17 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                 * so it needs to be realative to that.
                 */
                TempoMetric t = tmap.metric_at(start);
-               _current_bpm = tmap.tempo_at_frame (start).note_types_per_minute();
-               Timecode::BBT_Time bbt (tmap.bbt_at_frame (start));
+               _current_bpm = tmap.tempo_at_sample (start).note_types_per_minute();
+               Timecode::BBT_Time bbt (tmap.bbt_at_sample (start));
                double beatpos = (bbt.bars - 1) * t.meter().divisions_per_bar()
                               + (bbt.beats - 1)
                               + (bbt.ticks / Timecode::BBT_Time::ticks_per_beat);
                beatpos *= tmetric.meter().note_divisor() / 4.0;
-               _next_cycle_beat = beatpos + nframes * speed * _current_bpm / (60.f * _session.frame_rate());
+               _next_cycle_beat = beatpos + nframes * speed * _current_bpm / (60.f * _session.sample_rate());
        }
 
        if (_latency_control_port) {
-               framecnt_t new_latency = signal_latency ();
+               samplecnt_t new_latency = signal_latency ();
                _current_latency = new_latency;
        }
        return 0;
@@ -3120,7 +3120,7 @@ LV2Plugin::latency_compute_run()
        uint32_t out_index  = 0;
 
        // this is done in the main thread. non realtime.
-       const framecnt_t bufsize = _engine.samples_per_cycle();
+       const samplecnt_t bufsize = _engine.samples_per_cycle();
        float            *buffer = (float*) malloc(_engine.samples_per_cycle() * sizeof(float));
 
        memset(buffer, 0, sizeof(float) * bufsize);
@@ -3356,7 +3356,7 @@ LV2PluginInfo::load(Session& session)
                if (!uri) { throw failed_constructor(); }
                const LilvPlugin* lp = lilv_plugins_get_by_uri(plugins, uri);
                if (!lp) { throw failed_constructor(); }
-               plugin.reset(new LV2Plugin(session.engine(), session, lp, session.frame_rate()));
+               plugin.reset(new LV2Plugin(session.engine(), session, lp, session.sample_rate()));
                lilv_node_free(uri);
                plugin->set_info(PluginInfoPtr(shared_from_this ()));
                return plugin;