make resampled sources (during import) report their "natural position" (i.e. BWF...
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 16 Sep 2010 16:11:26 +0000 (16:11 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 16 Sep 2010 16:11:26 +0000 (16:11 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7785 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_audio_import.cc
gtk2_ardour/midi_region_view.cc
libs/ardour/ardour/importable_source.h
libs/ardour/ardour/resampled_source.h
libs/ardour/ardour/sndfileimportable.h
libs/ardour/import.cc
libs/ardour/resampled_source.cc
libs/ardour/sndfileimportable.cc

index c1d51e11a45ebbd19fae5fffb1d9be2f1a1f99c5..db470fbe64110b8063b6eefcb8d13f14169815ea 100644 (file)
@@ -827,20 +827,16 @@ Editor::add_sources (vector<string> paths, SourceList& sources, nframes64_t& pos
                         
                         if (as->natural_position() != 0) {
                                 pos = as->natural_position();
-                                cerr << "\tgot " << pos << " from source TC info\n";
                         } else if (target_tracks == 1) {
                                 /* hmm, no timestamp available, put it after the previous region
                                  */
                                 if (n == 0) {
                                         pos = get_preferred_edit_position ();
-                                        cerr << "\tno timestamp, first file, use edit pos = " << pos << endl;
                                 } else {
                                         pos += rlen;
-                                        cerr << "\tpacked-sequence-shuffle to " << pos << endl;
                                 }
                         } else {
                                 pos = get_preferred_edit_position ();
-                                cerr << "\tmultitracks, using edit position = " << pos << endl;
                         }
                                 
                 }
index f3e1b2cd98e0fc6c022b5c0d2c9e7e0140577a56..505380cc253b2d55b2484bca439cb97b4b19a68d 100644 (file)
@@ -1997,7 +1997,7 @@ MidiRegionView::move_selection(double dx, double dy, double cumulative_dy)
         }
 
         if (dy && !_selection.empty() && !no_sound_notes && trackview.editor().sound_notes()) {
-                
+
                 if (to_play.size() > 1) {
 
                         PossibleChord shifted;
index 7df346a782ddde412cfa1d7f42e0fbfd3880d065..c610d546f2574fc55bb4989319b7f6f981fff783 100644 (file)
@@ -30,13 +30,13 @@ public:
        ImportableSource () {}
        virtual ~ImportableSource() {}
 
-       virtual nframes_t read (Sample* buffer, nframes_t nframes) = 0;
-       virtual float ratio() const { return 1.0f; }
-       virtual uint32_t channels() const = 0;
-       virtual nframes_t length() const = 0;
-       virtual nframes_t samplerate() const = 0;
-       virtual void      seek (nframes_t pos) = 0;
-       virtual nframes64_t natural_position() const = 0;
+       virtual nframes_t  read (Sample* buffer, nframes_t nframes) = 0;
+       virtual float      ratio() const { return 1.0f; }
+       virtual uint32_t   channels() const = 0;
+       virtual framecnt_t length() const = 0;
+       virtual nframes_t  samplerate() const = 0;
+       virtual void       seek (nframes_t pos) = 0;
+       virtual framepos_t natural_position() const = 0;
 
        virtual bool clamped_at_unity () const = 0;
 };
index b61303b65ca7efe18975f036232bb458eeb16391..6d630bc44bf0895547c61255fd161e4675fd57b0 100644 (file)
@@ -34,13 +34,13 @@ class ResampledImportableSource : public ImportableSource
 
        ~ResampledImportableSource ();
 
-       nframes_t read (Sample* buffer, nframes_t nframes);
-       float ratio() const { return src_data.src_ratio; }
-       uint32_t channels() const { return source->channels(); }
-       nframes_t length() const { return source->length(); }
-       nframes_t samplerate() const { return source->samplerate(); }
-       void      seek (nframes_t);
-       nframes64_t natural_position() const { return source->natural_position(); }
+       nframes_t  read (Sample* buffer, nframes_t nframes);
+       float      ratio() const { return src_data.src_ratio; }
+       uint32_t   channels() const { return source->channels(); }
+       framecnt_t length() const { return source->length(); }
+       nframes_t  samplerate() const { return source->samplerate(); }
+       void       seek (nframes_t);
+       framepos_t natural_position() const;
 
        bool clamped_at_unity () const {
                /* resampling may generate inter-sample peaks with magnitude > 1 */
index 6e308415c97072956d6a1c80994aebfcdb1dfdc2..aab8b6ac5999a3ad74005254a787e0cef9f6383b 100644 (file)
@@ -33,18 +33,23 @@ class SndFileImportableSource : public ImportableSource {
        SndFileImportableSource (const std::string& path);
        virtual ~SndFileImportableSource();
 
-       nframes_t read (Sample* buffer, nframes_t nframes);
-       uint32_t  channels() const;
-       nframes_t length() const;
-       nframes_t samplerate() const;
-       void      seek (nframes_t pos);
-       nframes64_t natural_position() const;
-       bool clamped_at_unity () const;
+       nframes_t  read (Sample* buffer, nframes_t nframes);
+       uint32_t   channels() const;
+       framecnt_t length() const;
+       nframes_t  samplerate() const;
+       void       seek (nframes_t pos);
+       framepos_t natural_position() const;
+       bool       clamped_at_unity () const;
 
    protected:
        SF_INFO sf_info;
        boost::shared_ptr<SNDFILE> in;
-       nframes_t timecode;
+        
+        /* these are int64_t so as to be independent of whatever
+           types Ardour may use for framepos_t, framecnt_t etc.
+        */
+
+       int64_t timecode;
        int64_t get_timecode_info (SNDFILE*, SF_BROADCAST_INFO*, bool&);
 };
 
index 784fedefdb87c8e5c7bf1adab6df97d1def46831..13fb859efe9081311583134e8b9d3e40dcac7a63 100644 (file)
@@ -214,7 +214,6 @@ create_mono_sources_for_writing (const vector<string>& new_paths, Session& sess,
                {
                        const DataType type = SMFSource::safe_midi_file_extension (*i) ? DataType::MIDI : DataType::AUDIO;
 
-
                        source = SourceFactory::createWritable (type, sess,
                                        i->c_str(),
                                        false, // destructive
index 675a0e426dc083473f11c03e5af2cea4c9d7ebc8..7379aa74afbd2d027edde496b903b721c2ac90e0 100644 (file)
@@ -134,3 +134,8 @@ ResampledImportableSource::seek (nframes_t pos)
        src_data.end_of_input = 0;
 }
        
+framepos_t
+ResampledImportableSource::natural_position () const
+{
+        return source->natural_position() * ratio ();
+}
index 99697b888f6918dc613e39afd874c778e1ac4f45..b51ad3634a974aa4b4fcaa2976c690c0a30b2749 100644 (file)
@@ -57,10 +57,10 @@ SndFileImportableSource::channels () const
        return sf_info.channels;
 }
 
-nframes_t
+framecnt_t
 SndFileImportableSource::length () const
 {
-       return sf_info.frames;
+       return (framecnt_t) sf_info.frames;
 }
 
 nframes_t
@@ -75,10 +75,10 @@ SndFileImportableSource::seek (nframes_t /*pos*/)
        sf_seek (in.get(), 0, SEEK_SET);
 }
 
-nframes64_t
+framepos_t
 SndFileImportableSource::natural_position () const
 {
-       return timecode;
+       return (framepos_t) timecode;
 }
 
 bool