diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/analyser.h | 35 | ||||
-rw-r--r-- | libs/ardour/ardour/audioanalyser.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/audiofilesource.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/audioregion.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/audiosource.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/configuration_vars.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/region.h | 23 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 13 | ||||
-rw-r--r-- | libs/ardour/ardour/silentfilesource.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/source.h | 23 | ||||
-rw-r--r-- | libs/ardour/ardour/tempo.h | 16 | ||||
-rw-r--r-- | libs/ardour/ardour/transient_detector.h | 12 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 2 |
14 files changed, 120 insertions, 29 deletions
diff --git a/libs/ardour/ardour/analyser.h b/libs/ardour/ardour/analyser.h new file mode 100644 index 0000000000..8771cab6b0 --- /dev/null +++ b/libs/ardour/ardour/analyser.h @@ -0,0 +1,35 @@ +#ifndef __ardour_analyser_h__ +#define __ardour_analyser_h__ + +#include <glibmm/thread.h> +#include <boost/shared_ptr.hpp> + +namespace ARDOUR { + +class AudioFileSource; +class Source; +class TransientDetector; + +class Analyser { + + public: + Analyser(); + ~Analyser (); + + static void init (); + static void queue_source_for_analysis (boost::shared_ptr<Source>, bool force); + static void work (); + + private: + static Analyser* the_analyser; + static Glib::StaticMutex analysis_queue_lock; + static Glib::Cond* SourcesToAnalyse; + static std::list<boost::weak_ptr<Source> > analysis_queue; + + static void analyse_audio_file_source (boost::shared_ptr<AudioFileSource>); +}; + + +} + +#endif /* __ardour_analyser_h__ */ diff --git a/libs/ardour/ardour/audioanalyser.h b/libs/ardour/ardour/audioanalyser.h index dbd8a52d5a..06b841990a 100644 --- a/libs/ardour/ardour/audioanalyser.h +++ b/libs/ardour/ardour/audioanalyser.h @@ -40,7 +40,7 @@ class AudioAnalyser { AudioAnalyser (float sample_rate, AnalysisPluginKey key); virtual ~AudioAnalyser(); - + /* analysis object should provide a run method that accepts a path to write the results to (optionally empty) a Readable* to read data from diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index 4d80c8ddf5..0e8b6e4fde 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -125,6 +125,8 @@ class AudioFileSource : public AudioSource { virtual void handle_header_position_change () {} + bool can_be_analysed() const { return _length > 0; } + protected: /* constructor to be called for existing external-to-session files */ diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index 2c5630aec0..3fddfc55b4 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -134,7 +134,7 @@ class AudioRegion : public Region void resume_fade_in (); void resume_fade_out (); - int get_transients (std::vector<nframes64_t>&, bool force_new = false); + int get_transients (AnalysisFeatureList&, bool force_new = false); private: friend class RegionFactory; @@ -170,6 +170,7 @@ class AudioRegion : public Region void fade_out_changed (); void source_offset_changed (); void listen_to_my_curves (); + void listen_to_my_sources (); boost::shared_ptr<AutomationList> _fade_in; FadeShape _fade_in_shape; @@ -187,11 +188,6 @@ class AudioRegion : public Region AudioRegion (boost::shared_ptr<const AudioRegion>); int set_live_state (const XMLNode&, Change&, bool send); - - std::vector<nframes64_t> _transients; - bool valid_transients; - void invalidate_transients (); - void cleanup_transients (std::vector<nframes64_t>&); }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/audiosource.h b/libs/ardour/ardour/audiosource.h index b11174abe8..1589841baa 100644 --- a/libs/ardour/ardour/audiosource.h +++ b/libs/ardour/ardour/audiosource.h @@ -111,14 +111,12 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR: int prepare_for_peakfile_writes (); void done_with_peakfile_writes (bool done = true); - std::vector<nframes64_t> transients; - std::string get_transients_path() const; - protected: static bool _build_missing_peakfiles; static bool _build_peakfiles; bool _peaks_built; + bool _analysed; mutable Glib::Mutex _lock; mutable Glib::Mutex _peaks_ready_lock; Glib::ustring peakpath; @@ -145,9 +143,7 @@ class AudioSource : public Source, public boost::enable_shared_from_this<ARDOUR: double samples_per_visual_peak, nframes_t fpp) const; int compute_and_write_peaks (Sample* buf, nframes_t first_frame, nframes_t cnt, bool force, - bool intermediate_peaks_ready_signal, nframes_t frames_per_peak); - - int load_transients (const std::string&); + bool intermediate_peaks_ready_signal, nframes_t frames_per_peak); private: int peakfile; diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h index 99776929a4..134557daeb 100644 --- a/libs/ardour/ardour/configuration_vars.h +++ b/libs/ardour/ardour/configuration_vars.h @@ -53,6 +53,7 @@ CONFIG_VARIABLE (float, track_buffer_seconds, "track-buffer-seconds", 5.0) CONFIG_VARIABLE (uint32_t, disk_choice_space_threshold, "disk-choice-space-threshold", 57600000) CONFIG_VARIABLE (SampleFormat, native_file_data_format, "native-file-data-format", ARDOUR::FormatFloat) CONFIG_VARIABLE (HeaderFormat, native_file_header_format, "native-file-header-format", ARDOUR::WAVE) +CONFIG_VARIABLE (bool, auto_analyse_audio, "auto-analyse-audio", true) /* OSC */ diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 3f328de005..d8a38841f8 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -96,6 +96,7 @@ class Playlist : public SessionObject, public boost::enable_shared_from_this<Pla void duplicate (boost::shared_ptr<Region>, nframes_t position, float times); void nudge_after (nframes_t start, nframes_t distance, bool forwards); void shuffle (boost::shared_ptr<Region>, int dir); + void update_after_tempo_map_change (); boost::shared_ptr<Playlist> cut (list<AudioRange>&, bool result_is_hidden = true); boost::shared_ptr<Playlist> copy (list<AudioRange>&, bool result_is_hidden = true); @@ -110,6 +111,8 @@ class Playlist : public SessionObject, public boost::enable_shared_from_this<Pla nframes64_t find_next_region_boundary (nframes64_t frame, int dir); bool region_is_shuffle_constrained (boost::shared_ptr<Region>); + nframes64_t find_next_transient (nframes64_t position, int dir); + template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>, void *), void *arg); template<class T> void foreach_region (T *t, void (T::*func)(boost::shared_ptr<Region>)); diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index da07c580b4..d793e8ca23 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -73,6 +73,11 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> range_guarantoor = USHRT_MAX }; + enum PositionLockStyle { + AudioTime, + MusicTime + }; + static const Flag DefaultFlags = Flag (Opaque|DefaultFadeIn|DefaultFadeOut|FadeIn|FadeOut); static Change FadeChanged; @@ -130,6 +135,9 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> bool captured() const { return !(_flags & (Region::Flag (Region::Import|Region::External))); } bool can_move() const { return !(_flags & (Locked|PositionLocked)); } + PositionLockStyle positional_lock_style() const { return _positional_lock_style; } + void set_position_lock_style (PositionLockStyle ps); + virtual bool should_save_state () const { return !(_flags & DoNotSaveState); }; void freeze (); @@ -156,6 +164,7 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> void set_position (nframes_t, void *src); void set_position_on_top (nframes_t, void *src); void special_set_position (nframes_t); + void update_position_after_tempo_map_change (); void nudge_position (nframes64_t, void *src); bool at_natural_position () const; @@ -213,6 +222,13 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> virtual bool is_dependent() const { return false; } virtual bool depends_on (boost::shared_ptr<Region> other) const { return false; } + virtual int get_transients (AnalysisFeatureList&, bool force_new = false) { + // no transients, but its OK + return 0; + } + + void invalidate_transients (); + protected: friend class RegionFactory; @@ -226,8 +242,6 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> Region (boost::shared_ptr<Source> src, const XMLNode&); Region (const SourceList& srcs, const XMLNode&); - /* this one is for derived types of derived types */ - Region (Session& s, nframes_t start, nframes_t length, const string& name, DataType, layer_t = 0, Flag flags = DefaultFlags); protected: @@ -236,6 +250,7 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> void send_change (Change); void trim_to_internal (nframes_t position, nframes_t length, void *src); + void set_position_internal (nframes_t pos, bool allow_bbt_recompute); bool copied() const { return _flags & Copied; } void maybe_uncopy (); @@ -256,6 +271,7 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> nframes_t _last_length; nframes_t _position; nframes_t _last_position; + PositionLockStyle _positional_lock_style; nframes_t _sync_position; layer_t _layer; mutable RegionEditState _first_edit; @@ -264,6 +280,9 @@ class Region : public Automatable, public boost::enable_shared_from_this<Region> nframes64_t _ancestral_length; float _stretch; float _shift; + BBT_Time _bbt_time; + AnalysisFeatureList _transients; + bool _valid_transients; mutable uint32_t _read_data_count; ///< modified in read() Change _pending_changed; uint64_t _last_layer_op; ///< timestamp diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index d27df2f7ea..c0c178eb02 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -389,7 +389,10 @@ class Session : public PBD::StatefulDestructible nframes_t get_maximum_extent () const; nframes_t current_end_frame() const { return end_location->start(); } nframes_t current_start_frame() const { return start_location->start(); } + // "actual" sample rate of session, set by current audioengine rate, pullup/down etc. nframes_t frame_rate() const { return _current_frame_rate; } + // "native" sample rate of session, regardless of current audioengine rate, pullup/down etc + nframes_t nominal_frame_rate() const { return _nominal_frame_rate; } nframes_t frames_per_hour() const { return _frames_per_hour; } double frames_per_smpte_frame() const { return _frames_per_smpte_frame; } @@ -432,6 +435,9 @@ class Session : public PBD::StatefulDestructible sigc::signal<void,string> StateSaved; sigc::signal<void> StateReady; + + vector<string*>* possible_states() const; + static vector<string*>* possible_states(string path); XMLNode& get_state(); int set_state(const XMLNode& node); // not idempotent @@ -624,6 +630,12 @@ class Session : public PBD::StatefulDestructible sigc::signal<int,boost::shared_ptr<ARDOUR::Playlist> > AskAboutPlaylistDeletion; + /* handlers should return 0 for "ignore the rate mismatch" + and !0 for "do not use this session" + */ + + static sigc::signal<int,nframes_t, nframes_t> AskAboutSampleRateMismatch; + /* handlers should return !0 for use pending state, 0 for ignore it. */ @@ -981,6 +993,7 @@ class Session : public PBD::StatefulDestructible bool waiting_for_sync_offset; nframes_t _base_frame_rate; nframes_t _current_frame_rate; //this includes video pullup offset + nframes_t _nominal_frame_rate; //ignores audioengine setting, "native" SR int transport_sub_state; mutable gint _record_status; volatile nframes_t _transport_frame; diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h index e0103185c2..87065c1cd0 100644 --- a/libs/ardour/ardour/silentfilesource.h +++ b/libs/ardour/ardour/silentfilesource.h @@ -35,6 +35,7 @@ class SilentFileSource : public AudioFileSource { void set_length (nframes_t len); bool destructive() const { return false; } + bool can_be_analysed() const { return false; } protected: diff --git a/libs/ardour/ardour/source.h b/libs/ardour/ardour/source.h index 174e58c61b..3109cb00ff 100644 --- a/libs/ardour/ardour/source.h +++ b/libs/ardour/ardour/source.h @@ -78,14 +78,27 @@ class Source : public SessionObject, public ARDOUR::Readable static sigc::signal<void,Source*> SourceCreated; sigc::signal<void,boost::shared_ptr<Source> > Switched; + bool has_been_analysed() const; + virtual bool can_be_analysed() const { return false; } + virtual void set_been_analysed (bool yn); + virtual bool check_for_analysis_data_on_disk(); + + sigc::signal<void> AnalysisChanged; + + AnalysisFeatureList transients; + std::string get_transients_path() const; + int load_transients (const std::string&); + protected: void update_length (nframes_t pos, nframes_t cnt); - DataType _type; - time_t _timestamp; - nframes_t _length; - - Glib::Mutex playlist_lock; + DataType _type; + time_t _timestamp; + nframes_t _length; + bool _analysed; + mutable Glib::Mutex _analysis_lock; + Glib::Mutex _playlist_lock; + typedef std::map<boost::shared_ptr<ARDOUR::Playlist>, uint32_t > PlaylistMap; PlaylistMap _playlists; diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index dc49f5cdef..c4915072c5 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -279,6 +279,10 @@ class TempoMap : public PBD::StatefulDestructible void bbt_time_with_metric (nframes_t, BBT_Time&, const Metric&) const; void change_existing_tempo_at (nframes_t, double bpm, double note_type); + void change_initial_tempo (double bpm, double note_type); + + int n_tempos () const; + int n_meters () const; sigc::signal<void,ARDOUR::Change> StateChanged; @@ -286,12 +290,12 @@ class TempoMap : public PBD::StatefulDestructible static Tempo _default_tempo; static Meter _default_meter; - Metrics *metrics; - nframes_t _frame_rate; - nframes_t last_bbt_when; - bool last_bbt_valid; - BBT_Time last_bbt; - mutable Glib::RWLock lock; + Metrics* metrics; + nframes_t _frame_rate; + nframes_t last_bbt_when; + bool last_bbt_valid; + BBT_Time last_bbt; + mutable Glib::RWLock lock; void timestamp_metrics (bool use_bbt); diff --git a/libs/ardour/ardour/transient_detector.h b/libs/ardour/ardour/transient_detector.h index c65bae3ed5..259b79176f 100644 --- a/libs/ardour/ardour/transient_detector.h +++ b/libs/ardour/ardour/transient_detector.h @@ -34,17 +34,23 @@ class TransientDetector : public AudioAnalyser TransientDetector (float sample_rate); ~TransientDetector(); + static std::string operational_identifier(); + void set_threshold (float); void set_sensitivity (float); float get_threshold () const; float get_sensitivity () const; - int run (const std::string& path, Readable*, uint32_t channel, std::vector<nframes64_t>& results); + int run (const std::string& path, Readable*, uint32_t channel, AnalysisFeatureList& results); - protected: - std::vector<nframes64_t>* current_results; + static void cleanup_transients (AnalysisFeatureList&, float sr, float gap_msecs); + + protected: + AnalysisFeatureList* current_results; int use_features (Vamp::Plugin::FeatureSet&, std::ostream*); + + static std::string _op_id; }; } /* namespace */ diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index cc756b0ec6..fdf8d0b439 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -392,6 +392,8 @@ namespace ARDOUR { int opts; // really RubberBandStretcher::Options }; + typedef std::list<nframes64_t> AnalysisFeatureList; + } // namespace ARDOUR std::istream& operator>>(std::istream& o, ARDOUR::SampleFormat& sf); |