1 /* === S Y N F I G ========================================================= */
2 /*! \file audiocontainer.h
3 ** \brief Sound info header
5 ** $Id: audiocontainer.h,v 1.1.1.1 2005/01/07 03:34:35 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SYNFIG_AUDIOCONTAINER_H
25 #define __SYNFIG_AUDIOCONTAINER_H
27 /* === H E A D E R S ======================================================= */
28 #include <sigc++/signal.h>
35 #include <synfig/time.h>
37 /* === M A C R O S ========================================================= */
38 const float DEF_DISPLAYSAMPLERATE = 400;
39 /* === T Y P E D E F S ===================================================== */
41 /* === C L A S S E S & S T R U C T S ======================================= */
47 //Note: Might want to abstract something to share data between profile and parent
48 class AudioProfile : public etl::shared_object
51 typedef std::vector<char> SampleProfile;
54 SampleProfile samples;
55 double samplerate; //samples / second of the profile
57 //reference our parent for any native sound info
58 etl::loose_handle<AudioContainer> parent;
60 public: //samples interface
62 SampleProfile::const_iterator begin() const {return samples.begin();}
63 SampleProfile::const_iterator end() const {return samples.end();}
66 unsigned int size() const {return samples.size();}
68 char operator[](int i) const
70 if(i >= 0 && i < (int)samples.size()) return samples[i];
76 double get_samplerate() const {return samplerate;}
77 void set_samplerate(double f) {samplerate = f;}
79 double get_offset() const;
81 etl::handle<AudioContainer> get_parent() const;
82 void set_parent(etl::handle<AudioContainer> i);
83 friend class AudioContainer;
86 /* Audio container actually implements all the cool stuff
87 Note: May be a bit to monolithic...
89 class AudioContainer : public sigc::trackable, public etl::shared_object
91 etl::handle<AudioProfile> prof;
96 bool profilevalid; //this is only half useful
97 //it makes it so we don't always have to realloc memory when the file switches...
104 public: //accessor interface
105 void set_offset(const double &s);
106 double get_offset() const;
108 public: //info gather interface
109 etl::handle<AudioProfile> get_profile(float samplerate = DEF_DISPLAYSAMPLERATE);
110 bool get_current_time(double &out);
112 public: //operational interface
113 bool load(const std::string &filename, const std::string &filedirectory = "");
119 //Note: this refers to the wrapper concept of the audio, the actual sound may or may not be playing...
120 bool is_playing() const;
122 //scrubbing functions...
123 void start_scrubbing(double t);
124 void stop_scrubbing();
125 void scrub(double t); //!< if we are not currently scrubbing this will not work
126 bool is_scrubbing() const;
128 double scrub_time() const;
130 bool isRunning() const;
131 bool isPaused() const;
134 } // END of namespace studio
136 /* === E N D =============================================================== */