diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audioregion.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_playlist.h | 1 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_region.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 10 | ||||
-rw-r--r-- | libs/ardour/ardour/region.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/region_factory.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/tempo.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 21 |
8 files changed, 40 insertions, 15 deletions
diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index d25cf0e421..a2c43460ed 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -189,7 +189,7 @@ class LIBARDOUR_API AudioRegion : public Region AudioRegion (boost::shared_ptr<AudioSource>); AudioRegion (const SourceList &); AudioRegion (boost::shared_ptr<const AudioRegion>); - AudioRegion (boost::shared_ptr<const AudioRegion>, frameoffset_t offset, const int32_t sub_num); + AudioRegion (boost::shared_ptr<const AudioRegion>, ARDOUR::MusicFrame offset); AudioRegion (boost::shared_ptr<const AudioRegion>, const SourceList&); AudioRegion (SourceList &); diff --git a/libs/ardour/ardour/midi_playlist.h b/libs/ardour/ardour/midi_playlist.h index 3c031a994f..49eb892e42 100644 --- a/libs/ardour/ardour/midi_playlist.h +++ b/libs/ardour/ardour/midi_playlist.h @@ -87,6 +87,7 @@ public: int set_state (const XMLNode&, int version); bool destroy_region (boost::shared_ptr<Region>); + void _split_region (boost::shared_ptr<Region>, MusicFrame position); void set_note_mode (NoteMode m) { _note_mode = m; } diff --git a/libs/ardour/ardour/midi_region.h b/libs/ardour/ardour/midi_region.h index 8f1edded21..b41f620e87 100644 --- a/libs/ardour/ardour/midi_region.h +++ b/libs/ardour/ardour/midi_region.h @@ -127,7 +127,7 @@ class LIBARDOUR_API MidiRegion : public Region MidiRegion (const SourceList&); MidiRegion (boost::shared_ptr<const MidiRegion>); - MidiRegion (boost::shared_ptr<const MidiRegion>, frameoffset_t offset, const int32_t sub_num = 0); + MidiRegion (boost::shared_ptr<const MidiRegion>, ARDOUR::MusicFrame offset); framecnt_t _read_at (const SourceList&, Evoral::EventSink<framepos_t>& dst, framepos_t position, @@ -146,6 +146,7 @@ class LIBARDOUR_API MidiRegion : public Region void recompute_at_end (); void set_position_internal (framepos_t pos, bool allow_bbt_recompute, const int32_t sub_num); + void set_position_music_internal (double qn); void set_length_internal (framecnt_t len, const int32_t sub_num); void set_start_internal (framecnt_t, const int32_t sub_num); void trim_to_internal (framepos_t position, framecnt_t length, const int32_t sub_num); diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index bdf17eabf0..580b245c47 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -135,14 +135,14 @@ public: /* Editing operations */ - void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false, const int32_t sub_num = 0); + void add_region (boost::shared_ptr<Region>, framepos_t position, float times = 1, bool auto_partition = false, int32_t sub_num = 0, double quarter_note = 0.0, bool for_music = false); void remove_region (boost::shared_ptr<Region>); void get_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&); void get_region_list_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&); void get_source_equivalent_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >&); void replace_region (boost::shared_ptr<Region> old, boost::shared_ptr<Region> newr, framepos_t pos); - void split_region (boost::shared_ptr<Region>, framepos_t position, const int32_t sub_num); - void split (framepos_t at, const int32_t sub_num); + void split_region (boost::shared_ptr<Region>, MusicFrame position); + void split (MusicFrame at); void shift (framepos_t at, frameoffset_t distance, bool move_intersected, bool ignore_music_glue); void partition (framepos_t start, framepos_t end, bool cut = false); void duplicate (boost::shared_ptr<Region>, framepos_t position, float times); @@ -372,7 +372,7 @@ public: virtual XMLNode& state (bool); - bool add_region_internal (boost::shared_ptr<Region>, framepos_t position, const int32_t sub_num = 0); + bool add_region_internal (boost::shared_ptr<Region>, framepos_t position, int32_t sub_num = 0, double quarter_note = 0.0, bool for_music = false); int remove_region_internal (boost::shared_ptr<Region>); void copy_regions (RegionList&) const; @@ -390,7 +390,7 @@ public: void begin_undo (); void end_undo (); - void _split_region (boost::shared_ptr<Region>, framepos_t position, const int32_t sub_num); + virtual void _split_region (boost::shared_ptr<Region>, MusicFrame position); typedef std::pair<boost::shared_ptr<Region>, boost::shared_ptr<Region> > TwoRegions; diff --git a/libs/ardour/ardour/region.h b/libs/ardour/ardour/region.h index a01ef703f3..85e0442a41 100644 --- a/libs/ardour/ardour/region.h +++ b/libs/ardour/ardour/region.h @@ -215,6 +215,7 @@ class LIBARDOUR_API Region void set_length (framecnt_t, const int32_t sub_num); void set_start (framepos_t); void set_position (framepos_t, int32_t sub_num = 0); + void set_position_music (double qn); void set_initial_position (framepos_t); void special_set_position (framepos_t); virtual void update_after_tempo_map_change (bool send_change = true); @@ -346,7 +347,7 @@ class LIBARDOUR_API Region Region (boost::shared_ptr<const Region>); /** Construct a region from another region, at an offset within that region */ - Region (boost::shared_ptr<const Region>, frameoffset_t start_offset, const int32_t sub_num); + Region (boost::shared_ptr<const Region>, ARDOUR::MusicFrame start_offset); /** Construct a region as a copy of another region, but with different sources */ Region (boost::shared_ptr<const Region>, const SourceList&); @@ -364,6 +365,7 @@ class LIBARDOUR_API Region virtual int _set_state (const XMLNode&, int version, PBD::PropertyChange& what_changed, bool send_signal); void post_set (const PBD::PropertyChange&); virtual void set_position_internal (framepos_t pos, bool allow_bbt_recompute, const int32_t sub_num); + virtual void set_position_music_internal (double qn); virtual void set_length_internal (framecnt_t, const int32_t sub_num); virtual void set_start_internal (framecnt_t, const int32_t sub_num = 0); bool verify_start_and_length (framepos_t, framecnt_t&); diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h index 6971e77242..4b32da0512 100644 --- a/libs/ardour/ardour/region_factory.h +++ b/libs/ardour/ardour/region_factory.h @@ -59,7 +59,7 @@ public: static PBD::Signal1<void,boost::shared_ptr<Region> > CheckNewRegion; /** create a "pure copy" of Region @param other */ - static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce = false, const int32_t sub_num = 0); + static boost::shared_ptr<Region> create (boost::shared_ptr<const Region> other, bool announce = false); /** create a region from a single Source */ static boost::shared_ptr<Region> create (boost::shared_ptr<Source>, @@ -72,8 +72,8 @@ public: static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const PBD::PropertyList&, bool announce = true); /** create a copy of @param other starting at @param offset within @param other */ - static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, frameoffset_t offset, - const PBD::PropertyList&, bool announce = true, const int32_t sub_num = 0); + static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, ARDOUR::MusicFrame offset, + const PBD::PropertyList&, bool announce = true); /** create a "copy" of @param other but using a different set of sources @param srcs */ static boost::shared_ptr<Region> create (boost::shared_ptr<Region> other, const SourceList& srcs, const PBD::PropertyList&, bool announce = true); diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h index a3ab8d68f6..1dce6347a0 100644 --- a/libs/ardour/ardour/tempo.h +++ b/libs/ardour/ardour/tempo.h @@ -386,10 +386,10 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible void replace_meter (const MeterSection&, const Meter&, const Timecode::BBT_Time& where, framepos_t frame, PositionLockStyle pls); - framepos_t round_to_bar (framepos_t frame, RoundMode dir); - framepos_t round_to_beat (framepos_t frame, RoundMode dir); + MusicFrame round_to_bar (framepos_t frame, RoundMode dir); + MusicFrame round_to_beat (framepos_t frame, RoundMode dir); framepos_t round_to_beat_subdivision (framepos_t fr, int sub_num, RoundMode dir); - framepos_t round_to_quarter_note_subdivision (framepos_t fr, int sub_num, RoundMode dir); + MusicFrame round_to_quarter_note_subdivision (framepos_t fr, int sub_num, RoundMode dir); void set_length (framepos_t frames); @@ -564,7 +564,7 @@ private: void recompute_meters (Metrics& metrics); void recompute_map (Metrics& metrics, framepos_t end = -1); - framepos_t round_to_type (framepos_t fr, RoundMode dir, BBTPointType); + MusicFrame round_to_type (framepos_t fr, RoundMode dir, BBTPointType); const MeterSection& first_meter() const; MeterSection& first_meter(); diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 46ef2bade9..0a2fd62f7b 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -319,6 +319,27 @@ namespace ARDOUR { } }; + /* used for translating audio frames to an exact musical position using a note divisor. + an exact musical position almost never falls exactly on an audio frame, but for sub-sample + musical accuracy we need to derive exact musical locations from a frame position + the division follows TempoMap::exact_beat_at_frame(). + division + -1 musical location is the bar closest to frame + 0 musical location is the musical position of the frame + 1 musical location is the BBT beat closest to frame + n musical location is the quarter-note division n closest to frame + */ + struct MusicFrame { + framepos_t frame; + int32_t division; + + MusicFrame (framepos_t f, int32_t d) : frame (f), division (d) {} + + void set (framepos_t f, int32_t d) {frame = f; division = d; } + + MusicFrame operator- (MusicFrame other) { return MusicFrame (frame - other.frame, 0); } + }; + /* XXX: slightly unfortunate that there is this and Evoral::Range<>, but this has a uint32_t id which Evoral::Range<> does not. */ |