visibility macros and flush() added to SrcFileSource; merge with master
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 19 Jan 2014 22:54:47 +0000 (17:54 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 19 Jan 2014 22:54:47 +0000 (17:54 -0500)
13 files changed:
gtk2_ardour/gain_meter.cc
gtk2_ardour/sfdb_ui.cc
gtk2_ardour/sfdb_ui.h
libs/ardour/ardour/panner_shell.h
libs/ardour/ardour/route.h
libs/ardour/ardour/srcfilesource.h [new file with mode: 0644]
libs/ardour/panner_shell.cc
libs/ardour/plugin_insert.cc
libs/ardour/route.cc
libs/ardour/session_vst.cc
libs/ardour/srcfilesource.cc [new file with mode: 0644]
libs/ardour/wscript
midi_maps/Roland_V_Studio_20.map

index edf07a13a584c0079007a1346b58dfedd8ee9b6d..53dd0062245bfae345a98da944f1afdafa41fc2c 100644 (file)
@@ -98,6 +98,7 @@ GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int
        gain_display.signal_activate().connect (sigc::mem_fun (*this, &GainMeter::gain_activated));
        gain_display.signal_focus_in_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
        gain_display.signal_focus_out_event().connect (sigc::mem_fun (*this, &GainMeter::gain_focused), false);
+       gain_display.set_alignment(1.0);
 
        peak_display.set_name ("MixerStripPeakDisplay");
        set_size_request_to_display_given_text (peak_display, "-80.g", 2, 6); /* note the descender */
@@ -143,8 +144,7 @@ GainMeterBase::GainMeterBase (Session* s, bool horizontal, int fader_length, int
 void
 GainMeterBase::set_flat_buttons ()
 {
-printf("set_flat_butt\n");
-//     gain_slider->set_flat_buttons( ARDOUR_UI::config()->get_flat_buttons() );
+//     gain_slider->set_flat_buttons( ARDOUR_UI::config()->flat_buttons.get() );
 }
 
 GainMeterBase::~GainMeterBase ()
@@ -907,6 +907,11 @@ GainMeter::GainMeter (Session* s, int fader_length)
        }
        gain_display_box.pack_start (gain_display, true, true);
 
+       if (peak_display.get_parent()) {
+               peak_display.get_parent()->remove (gain_display);
+       }
+       gain_display_box.pack_start (peak_display, true, true);
+
        meter_metric_area.set_name ("AudioTrackMetrics");
        meter_metric_area.set_size_request(24, -1);
 
index 84065c69b1b4d8b1192a5a99960baef1da8a7f5e..90bb0a3dceaf31981f6ae698cfbb8d8c78f6e81e 100644 (file)
@@ -54,6 +54,7 @@
 #include "ardour/source_factory.h"
 #include "ardour/session.h"
 #include "ardour/session_directory.h"
+#include "ardour/srcfilesource.h"
 
 #include "ardour_ui.h"
 #include "editing.h"
@@ -391,8 +392,12 @@ SoundFileBox::audition ()
                                SourceFactory::createExternal (DataType::AUDIO, *_session,
                                                               path, n,
                                                               Source::Flag (0), false));
-                       
-                       srclist.push_back(afs);
+                       if (afs->sample_rate() != _session->nominal_frame_rate()) {
+                               boost::shared_ptr<SrcFileSource> sfs (new SrcFileSource(*_session, afs, _src_quality));
+                               srclist.push_back(sfs);
+                       } else {
+                               srclist.push_back(afs);
+                       }
 
                } catch (failed_constructor& err) {
                        error << _("Could not access soundfile: ") << path << endmsg;
@@ -1683,6 +1688,7 @@ SoundFileOmega::SoundFileOmega (string title, ARDOUR::Session* s,
        set_popdown_strings (src_combo, str);
        src_combo.set_active_text (str.front());
        src_combo.set_sensitive (false);
+       src_combo.signal_changed().connect (sigc::mem_fun (*this, &SoundFileOmega::src_combo_changed));
 
        reset_options ();
 
@@ -1793,6 +1799,12 @@ SoundFileOmega::get_src_quality() const
        }
 }
 
+void
+SoundFileOmega::src_combo_changed()
+{
+       preview.set_src_quality(get_src_quality());
+}
+
 ImportDisposition
 SoundFileOmega::get_channel_disposition () const
 {
index ccfd3799be01070aa6495534232536ba75e25963..46408ecffc605824912e27daf2749f63de1e15d0 100644 (file)
@@ -70,6 +70,7 @@ class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public P
        void audition();
        bool audition_oneshot();
        bool autoplay () const;
+       void set_src_quality(ARDOUR::SrcQuality q) { _src_quality = q; }
 
   protected:
        std::string path;
@@ -117,6 +118,7 @@ class SoundFileBox : public Gtk::VBox, public ARDOUR::SessionHandlePtr, public P
        bool seek_button_press(GdkEventButton*);
        bool seek_button_release(GdkEventButton*);
        bool _seeking;
+       ARDOUR::SrcQuality _src_quality;
 };
 
 class SoundFileBrowser : public ArdourWindow
@@ -313,6 +315,7 @@ class SoundFileOmega : public SoundFileBrowser
        bool reset_options ();
        void reset_options_noret ();
        bool bad_file_message ();
+       void src_combo_changed ();
 
         void do_something (int action);
 };
index 02f80c7b28bc0db237c6d298593055270f407897..f344afd54a5569e734b35d592132a0e13d4837c7 100644 (file)
@@ -86,7 +86,6 @@ public:
        bool select_panner_by_uri (std::string const uri);
 
   private:
-       friend class Route;
        void distribute_no_automation (BufferSet& src, BufferSet& dest, pframes_t nframes, gain_t gain_coeff);
        bool set_user_selected_panner_uri (std::string const uri);
 
index 5cd17ee24e006ca7e020173dade6f058fde50b72..fb2b18f177d5e54fc7af1e3c635af413f9dc487f 100644 (file)
@@ -256,7 +256,6 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
        int remove_processor (boost::shared_ptr<Processor>, ProcessorStreams* err = 0, bool need_process_lock = true);
        int remove_processors (const ProcessorList&, ProcessorStreams* err = 0);
        int reorder_processors (const ProcessorList& new_order, ProcessorStreams* err = 0);
-       void set_custom_panner_uri (std::string const panner_uri);
        void disable_processors (Placement);
        void disable_processors ();
        void disable_plugins (Placement);
diff --git a/libs/ardour/ardour/srcfilesource.h b/libs/ardour/ardour/srcfilesource.h
new file mode 100644 (file)
index 0000000..0b0865a
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+    Copyright (C) 2014 Paul Davis
+    Written by: Robin Gareus <robin@gareus.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#ifndef __ardour_srcfilesource_h__
+#define __ardour_srcfilesource_h__
+
+#include <cstring>
+#include <samplerate.h>
+#include "ardour/audiofilesource.h"
+#include "ardour/session.h"
+
+namespace ARDOUR {
+
+class SrcFileSource : public AudioFileSource {
+public:
+       SrcFileSource (Session&, boost::shared_ptr<AudioFileSource>, SrcQuality srcq = SrcQuality(SrcQuick));
+       ~SrcFileSource ();
+
+       int update_header (framepos_t /*when*/, struct tm&, time_t) { return 0; }
+       int flush_header () { return 0; }
+       void set_header_timeline_position () {};
+       void set_length (framecnt_t /*len*/) {};
+
+       float sample_rate () const { return _session.nominal_frame_rate(); }
+
+       framepos_t natural_position() const { return _source->natural_position() * _ratio;}
+       framecnt_t readable_length() const { return _source->readable_length() * _ratio; }
+       framecnt_t length (framepos_t pos) const { return _source->length(pos) * _ratio; }
+
+       bool destructive() const { return false; }
+       bool can_be_analysed() const { return false; }
+       bool clamped_at_unity() const { return false; }
+
+protected:
+       framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const;
+       framecnt_t write_unlocked (Sample */*dst*/, framecnt_t /*cnt*/) { return 0; }
+
+       int read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t /*start*/, framecnt_t /*cnt*/,
+                                double /*samples_per_unit*/, framecnt_t /*fpp*/) const {
+               memset (peaks, 0, sizeof (PeakData) * npeaks);
+               return 0;
+       }
+
+private:
+       static const uint32_t blocksize;
+       boost::shared_ptr<AudioFileSource> _source;
+
+       mutable SRC_STATE* _src_state;
+       mutable SRC_DATA   _src_data;
+
+       mutable Sample* _src_buffer;
+       mutable framepos_t _source_position;
+       mutable framepos_t _target_position;
+       mutable double _fract_position;
+
+       double _ratio;
+       framecnt_t src_buffer_size;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_audiofilesource_h__ */
+
index 0297cba6ef3e36ef5f4e91f25f72bb6d7a1483a1..75543433c5171b64dadb65b2cc19726369e84059 100644 (file)
@@ -405,6 +405,7 @@ PannerShell::set_bypassed (bool yn)
        }
        
        _bypassed = yn;
+       _session.set_dirty ();
        Changed (); /* EMIT SIGNAL */
 }
 
index 10368bfb428bf6a1b3efc3a235e22cf7c3d7a89c..f2689bf998abb8e79b8053c9214625a64181d450 100644 (file)
@@ -719,6 +719,10 @@ PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out)
 PluginInsert::Match
 PluginInsert::private_can_support_io_configuration (ChanCount const & inx, ChanCount& out)
 {
+       if (_plugins.empty()) {
+               return Match();
+       }
+
        PluginInfoPtr info = _plugins.front()->get_info();
        ChanCount in; in += inx;
        midi_bypass.reset();
index 7eb50c7695f3dc32d7c54d709c126a58cafb985c..66a8ea706d15c37f83785837d554798293a2aa10 100644 (file)
@@ -1569,63 +1569,6 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams*
        return 0;
 }
 
-#if 0
-/* currently unused (again) -- but will come in handy soon (again)
- * once there is an option to link route + delivery panner settings
- */
-void
-Route::set_custom_panner_uri (std::string const panner_uri)
-{
-       if (_in_configure_processors) {
-               DEBUG_TRACE (DEBUG::Panning, string_compose (_("Route::set_custom_panner_uri '%1' -- called while in_configure_processors\n"), name()));
-               return;
-       }
-
-       if (!_main_outs->panner_shell()->set_user_selected_panner_uri(panner_uri)) {
-               DEBUG_TRACE (DEBUG::Panning, string_compose (_("Route::set_custom_panner_uri '%1 '%2' -- no change needed\n"), name(), panner_uri));
-               /* no change needed */
-               return;
-       }
-
-       DEBUG_TRACE (DEBUG::Panning, string_compose (_("Route::set_custom_panner_uri '%1 '%2' -- reconfigure I/O\n"), name(), panner_uri));
-
-       /* reconfigure I/O -- re-initialize panner modules */
-       {
-               Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
-               Glib::Threads::RWLock::WriterLock lm (_processor_lock);
-
-               for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
-                       boost::shared_ptr<Delivery> dl;
-                       boost::shared_ptr<Panner> panner;
-                       if ((dl = boost::dynamic_pointer_cast<Delivery> (*p)) == 0) {
-                               continue;
-                       }
-                       if (!dl->panner_shell()) {
-                               continue;
-                       }
-                       if (!(panner = dl->panner_shell()->panner())) {
-                               continue;
-                       }
-                       /* _main_outs has already been set before the loop.
-                        * Ignore the return status here. It need reconfiguration */
-                       if (dl->panner_shell() != _main_outs->panner_shell()) {
-                               if (!dl->panner_shell()->set_user_selected_panner_uri(panner_uri)) {
-                                       continue;
-                               }
-                       }
-
-                       ChanCount in = panner->in();
-                       ChanCount out = panner->out();
-                       dl->panner_shell()->configure_io(in, out);
-                       dl->panner_shell()->pannable()->set_panner(dl->panner_shell()->panner());
-               }
-       }
-
-       processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
-       _session.set_dirty ();
-}
-#endif
-
 void
 Route::reset_instrument_info ()
 {
index 9533eef705c866a4e4a857c06af7340804b26dfb..c746a9d388d03d97a2c9575e1641a6211b8bca25 100644 (file)
@@ -187,7 +187,7 @@ intptr_t Session::vst_callback (
                                        
                                        if (value & (kVstBarsValid)) {
                                                _timeInfo.barStartPos = ppqBar;
-                                               _timeInfo.flags |= (kVstPpqPosValid);
+                                               _timeInfo.flags |= (kVstBarsValid);
                                        }
                                        
                                } catch (...) {
diff --git a/libs/ardour/srcfilesource.cc b/libs/ardour/srcfilesource.cc
new file mode 100644 (file)
index 0000000..6af4aaa
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+    Copyright (C) 2014 Paul Davis
+    Written by: Robin Gareus <robin@gareus.org>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "pbd/error.h"
+#include "pbd/failed_constructor.h"
+
+#include "ardour/audiofilesource.h"
+#include "ardour/debug.h"
+#include "ardour/srcfilesource.h"
+
+#include "i18n.h"
+
+using namespace ARDOUR;
+using namespace PBD;
+
+/* see disk_io_chunk_frames */
+const uint32_t SrcFileSource::blocksize = 65536U;
+
+SrcFileSource::SrcFileSource (Session& s, boost::shared_ptr<AudioFileSource> src, SrcQuality srcq)
+       : Source(s, DataType::AUDIO, src->name(), Flag (src->flags() & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
+       , AudioFileSource (s, src->path(), Flag (src->flags() & ~(Writable|Removable|RemovableIfEmpty|RemoveAtDestroy)))
+       , _source (src)
+       , _src_state (0)
+       , _source_position(0)
+       , _target_position(0)
+       , _fract_position(0)
+{
+       assert(_source->n_channels() == 1);
+
+       int src_type = SRC_SINC_BEST_QUALITY;
+
+       switch (srcq) {
+               case SrcBest:
+                       src_type = SRC_SINC_BEST_QUALITY;
+                       break;
+               case SrcGood:
+                       src_type = SRC_SINC_MEDIUM_QUALITY;
+                       break;
+               case SrcQuick:
+                       src_type = SRC_SINC_FASTEST;
+                       break;
+               case SrcFast:
+                       src_type = SRC_ZERO_ORDER_HOLD;
+                       break;
+               case SrcFastest:
+                       src_type = SRC_LINEAR;
+                       break;
+       }
+
+
+       _ratio = s.nominal_frame_rate() / _source->sample_rate();
+       _src_data.src_ratio = _ratio;
+
+       src_buffer_size = ceil((double)blocksize / _ratio) + 2;
+       _src_buffer = new float[src_buffer_size];
+
+       int err;
+       if ((_src_state = src_new (src_type, 1, &err)) == 0) {
+               error << string_compose(_("Import: src_new() failed : %1"), src_strerror (err)) << endmsg ;
+               throw failed_constructor ();
+       }
+}
+
+SrcFileSource::~SrcFileSource ()
+{
+       DEBUG_TRACE (DEBUG::AudioPlayback, "SrcFileSource::~SrcFileSource\n");
+       _src_state = src_delete (_src_state) ;
+       delete [] _src_buffer;
+}
+
+framecnt_t
+SrcFileSource::read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const
+{
+       int err;
+       const double srccnt = cnt / _ratio;
+
+       if (_target_position != start) {
+               DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("SRC: reset %1 -> %2\n", _target_position, start));
+               src_reset(_src_state);
+               _fract_position = 0;
+               _source_position = start / _ratio;
+               _target_position = start;
+       }
+
+       const framecnt_t scnt = ceilf(srccnt - _fract_position);
+       _fract_position += (scnt - srccnt);
+
+#ifndef NDEBUG
+       if (scnt >= src_buffer_size) {
+               DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("SRC: CRASH AHEAD :)  %1 >= %2 (fract=%3, cnt=%4)\n",
+                                       scnt, src_buffer_size, _fract_position, cnt));
+       }
+#endif
+       assert(scnt < src_buffer_size);
+
+       _src_data.input_frames = _source->read (_src_buffer, _source_position, scnt);
+
+       if ((framecnt_t) _src_data.input_frames < scnt
+                       || _source_position + scnt >= _source->length(0)) {
+               _src_data.end_of_input = true;
+               _target_position += _src_data.input_frames * _ratio;
+               DEBUG_TRACE (DEBUG::AudioPlayback, "SRC: END OF INPUT\n");
+       } else {
+               _src_data.end_of_input = false;
+               _target_position += cnt;
+       }
+
+       _src_data.output_frames = cnt;
+       _src_data.data_in = _src_buffer;
+       _src_data.data_out = dst;
+
+       if (_src_data.end_of_input) {
+               _src_data.output_frames = std::min ((long)floor(_src_data.input_frames * _ratio), _src_data.output_frames);
+       }
+
+
+       if ((err = src_process (_src_state, &_src_data))) {
+               error << string_compose(_("SrcFileSource: %1"), src_strerror (err)) << endmsg ;
+               return 0;
+       }
+
+       if (_src_data.end_of_input && _src_data.output_frames_gen <= 0) {
+               return 0;
+       }
+
+       _source_position += _src_data.input_frames_used;
+
+       framepos_t saved_target = _target_position;
+       framecnt_t generated = _src_data.output_frames_gen;
+
+       while (generated < cnt) {
+               DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("SRC: recurse for %1 samples\n",  cnt - generated));
+               framecnt_t g = read_unlocked(dst + generated, _target_position, cnt - generated);
+               generated += g;
+               if (g == 0) break;
+       }
+       _target_position = saved_target;
+
+       DEBUG_TRACE (DEBUG::AudioPlayback, string_compose ("SRC: in: %1-> want: %2 || got: %3 total: %4\n",
+                               _src_data.input_frames, _src_data.output_frames, _src_data.output_frames_gen, generated));
+
+       return generated;
+}
index 799349c22542a25170bff0b339231f1a54c2f507..56c864ca509cb97b01b3ded6c3f13b74797edad1 100644 (file)
@@ -201,6 +201,7 @@ libardour_sources = [
         'source.cc',
         'source_factory.cc',
         'speakers.cc',
+        'srcfilesource.cc',
         'strip_silence.cc',
         'revision.cc',
         'tape_file_matcher.cc',
index 6909435b5af8febd352f868c345cf177576152a6..5e1eea152b60064fb303b90e853f81c3855cb871 100644 (file)
@@ -1,4 +1,3 @@
-
 <?xml version="1.0" encoding="UTF-8"?>
 <ArdourMIDIBindings version="1.0.0" name="Roland V-Studio 20">
 <DeviceInfo bank-size="8"/>