From 30b087ab3d28f1585987fa3f6ae006562ae192e3 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 18 Sep 2017 12:39:17 -0400 Subject: globally change all use of "frame" to refer to audio into "sample". Generated by tools/f2s. Some hand-editing will be required in a few places to fix up comments related to timecode and video in order to keep the legible --- libs/ardour/ardour/types.h | 104 ++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'libs/ardour/ardour/types.h') diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 3999c36aa3..d3ed94e552 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -65,27 +65,27 @@ namespace ARDOUR { typedef uint64_t microseconds_t; typedef uint32_t pframes_t; - /* Any position measured in audio frames. + /* Any position measured in audio samples. Assumed to be non-negative but not enforced. */ - typedef int64_t framepos_t; + typedef int64_t samplepos_t; - /* Any distance from a given framepos_t. + /* Any distance from a given samplepos_t. Maybe positive or negative. */ - typedef int64_t frameoffset_t; + typedef int64_t sampleoffset_t; - /* Any count of audio frames. + /* Any count of audio samples. Assumed to be positive but not enforced. */ - typedef int64_t framecnt_t; + typedef int64_t samplecnt_t; - static const framepos_t max_framepos = INT64_MAX; - static const framecnt_t max_framecnt = INT64_MAX; + static const samplepos_t max_samplepos = INT64_MAX; + static const samplecnt_t max_samplecnt = INT64_MAX; static const layer_t max_layer = UINT32_MAX; // a set of (time) intervals: first of pair is the offset of the start within the region, second is the offset of the end - typedef std::list > AudioIntervalResult; + typedef std::list > AudioIntervalResult; // associate a set of intervals with regions (e.g. for silence detection) typedef std::map,AudioIntervalResult> AudioIntervalMap; @@ -251,7 +251,7 @@ namespace ARDOUR { enum Type { Timecode, BBT, - Frames, + Samples, Seconds }; @@ -261,11 +261,11 @@ namespace ARDOUR { Timecode::BBT_Time bbt; union { - framecnt_t frames; + samplecnt_t samples; double seconds; }; - AnyTime() { type = Frames; frames = 0; } + AnyTime() { type = Samples; samples = 0; } bool operator== (AnyTime const & other) const { if (type != other.type) { return false; } @@ -275,8 +275,8 @@ namespace ARDOUR { return timecode == other.timecode; case BBT: return bbt == other.bbt; - case Frames: - return frames == other.frames; + case Samples: + return samples == other.samples; case Seconds: return seconds == other.seconds; } @@ -291,8 +291,8 @@ namespace ARDOUR { timecode.seconds != 0 || timecode.frames != 0; case BBT: return bbt.bars != 0 || bbt.beats != 0 || bbt.ticks != 0; - case Frames: - return frames != 0; + case Samples: + return samples != 0; case Seconds: return seconds != 0; } @@ -302,38 +302,38 @@ 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(). + /* used for translating audio samples to an exact musical position using a note divisor. + an exact musical position almost never falls exactly on an audio sample, but for sub-sample + musical accuracy we need to derive exact musical locations from a sample position + the division follows TempoMap::exact_beat_at_sample(). 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 + -1 musical location is the bar closest to sample + 0 musical location is the musical position of the sample + 1 musical location is the BBT beat closest to sample + n musical location is the quarter-note division n closest to sample */ - struct MusicFrame { - framepos_t frame; + struct MusicSample { + samplepos_t sample; int32_t division; - MusicFrame (framepos_t f, int32_t d) : frame (f), division (d) {} + MusicSample (samplepos_t f, int32_t d) : sample (f), division (d) {} - void set (framepos_t f, int32_t d) {frame = f; division = d; } + void set (samplepos_t f, int32_t d) {sample = f; division = d; } - MusicFrame operator- (MusicFrame other) { return MusicFrame (frame - other.frame, 0); } + MusicSample operator- (MusicSample other) { return MusicSample (sample - other.sample, 0); } }; /* XXX: slightly unfortunate that there is this and Evoral::Range<>, but this has a uint32_t id which Evoral::Range<> does not. */ struct AudioRange { - framepos_t start; - framepos_t end; + samplepos_t start; + samplepos_t end; uint32_t id; - AudioRange (framepos_t s, framepos_t e, uint32_t i) : start (s), end (e) , id (i) {} + AudioRange (samplepos_t s, samplepos_t e, uint32_t i) : start (s), end (e) , id (i) {} - framecnt_t length() const { return end - start + 1; } + samplecnt_t length() const { return end - start + 1; } bool operator== (const AudioRange& other) const { return start == other.start && end == other.end && id == other.id; @@ -343,7 +343,7 @@ namespace ARDOUR { return start == other.start && end == other.end; } - Evoral::OverlapType coverage (framepos_t s, framepos_t e) const { + Evoral::OverlapType coverage (samplepos_t s, samplepos_t e) const { return Evoral::coverage (start, end, s, e); } }; @@ -570,7 +570,7 @@ namespace ARDOUR { SrcFastest }; - typedef std::list AnalysisFeatureList; + typedef std::list AnalysisFeatureList; typedef std::list > RouteList; typedef std::list > StripableList; @@ -712,38 +712,38 @@ namespace ARDOUR { }; struct CaptureInfo { - framepos_t start; - framecnt_t frames; + samplepos_t start; + samplecnt_t samples; }; typedef std::vector CaptureInfos; } // namespace ARDOUR -static inline ARDOUR::framepos_t -session_frame_to_track_frame (ARDOUR::framepos_t session_frame, double speed) +static inline ARDOUR::samplepos_t +session_sample_to_track_sample (ARDOUR::samplepos_t session_sample, double speed) { - long double result = (long double) session_frame * (long double) speed; + long double result = (long double) session_sample * (long double) speed; - if (result >= (long double) ARDOUR::max_framepos) { - return ARDOUR::max_framepos; - } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) { - return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1)); + if (result >= (long double) ARDOUR::max_samplepos) { + return ARDOUR::max_samplepos; + } else if (result <= (long double) (ARDOUR::max_samplepos) * (ARDOUR::samplepos_t)(-1)) { + return (ARDOUR::max_samplepos * (ARDOUR::samplepos_t)(-1)); } else { return result; } } -static inline ARDOUR::framepos_t -track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed) +static inline ARDOUR::samplepos_t +track_sample_to_session_sample (ARDOUR::samplepos_t track_sample, double speed) { /* NB - do we need a check for speed == 0 ??? */ - long double result = (long double) track_frame / (long double) speed; + long double result = (long double) track_sample / (long double) speed; - if (result >= (long double) ARDOUR::max_framepos) { - return ARDOUR::max_framepos; - } else if (result <= (long double) (ARDOUR::max_framepos) * (ARDOUR::framepos_t)(-1)) { - return (ARDOUR::max_framepos * (ARDOUR::framepos_t)(-1)); + if (result >= (long double) ARDOUR::max_samplepos) { + return ARDOUR::max_samplepos; + } else if (result <= (long double) (ARDOUR::max_samplepos) * (ARDOUR::samplepos_t)(-1)) { + return (ARDOUR::max_samplepos * (ARDOUR::samplepos_t)(-1)); } else { return result; } @@ -751,7 +751,7 @@ track_frame_to_session_frame (ARDOUR::framepos_t track_frame, double speed) /* for now, break the rules and use "using" to make this "global" */ -using ARDOUR::framepos_t; +using ARDOUR::samplepos_t; #endif /* __ardour_types_h__ */ -- cgit v1.2.3