1 #ifndef INCLUDED_ECA_AUDIO_TIME_H 2 #define INCLUDED_ECA_AUDIO_TIME_H 3 4 #include <string> 5 #include "sample-specs.h" 6 7 /** 8 * Generic class for representing time in audio environment 9 */ 10 class ECA_AUDIO_TIME { 11 12 private: 13 14 SAMPLE_SPECS::sample_pos_t samples_rep; 15 mutable SAMPLE_SPECS::sample_rate_t sample_rate_rep; 16 mutable bool rate_set_rep; 17 18 static const SAMPLE_SPECS::sample_rate_t default_srate = 384000; 19 static const SAMPLE_SPECS::sample_rate_t invalid_srate = -1; 20 21 public: 22 23 enum format_type { format_hour_min_sec, format_min_sec, format_seconds, format_samples }; 24 25 ECA_AUDIO_TIME(SAMPLE_SPECS::sample_pos_t samples, SAMPLE_SPECS::sample_rate_t sample_rate); 26 ECA_AUDIO_TIME(double time_in_seconds); 27 ECA_AUDIO_TIME(format_type type, const std::string& time); 28 ECA_AUDIO_TIME(const std::string& time); 29 ECA_AUDIO_TIME(void); 30 31 void set(format_type type, const std::string& time); 32 void set_seconds(double seconds); 33 void set_time_string(const std::string& time); 34 void set_samples(SAMPLE_SPECS::sample_pos_t samples); 35 void set_samples_per_second(long int srate); 36 void set_samples_per_second_keeptime(long int srate); 37 void mark_as_invalid(void); 38 39 std::string to_string(format_type type) const; 40 double seconds(void) const; 41 SAMPLE_SPECS::sample_rate_t samples_per_second(void) const; 42 SAMPLE_SPECS::sample_pos_t samples(void) const; 43 bool valid(void) const; 44 }; 45 46 #endif 47