}
}
+AudioPoint::AudioPoint (AudioPoint const & other)
+{
+ for (int i = 0; i < COUNT; ++i) {
+ _data[i] = other._data[i];
+ }
+}
+
+AudioPoint &
+AudioPoint::operator= (AudioPoint const & other)
+{
+ if (this == &other) {
+ return *this;
+ }
+
+ for (int i = 0; i < COUNT; ++i) {
+ _data[i] = other._data[i];
+ }
+
+ return *this;
+}
+
void
AudioPoint::write (ostream& s) const
{
_data.resize (channels);
}
-AudioAnalysis::AudioAnalysis (string filename)
+AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
{
- ifstream f (filename.c_str ());
+ ifstream f (filename.string().c_str ());
int channels;
f >> channels;
}
void
-AudioAnalysis::write (string filename)
+AudioAnalysis::write (boost::filesystem::path filename)
{
- string tmp = filename + ".tmp";
-
+ string tmp = filename.string() + ".tmp";
+
ofstream f (tmp.c_str ());
f << _data.size() << "\n";
for (vector<vector<AudioPoint> >::iterator i = _data.begin(); i != _data.end(); ++i) {
f.close ();
boost::filesystem::rename (tmp, filename);
}
-
-float
-AudioAnalysis::smooth (list<float> const & data, AudioPoint::Type t)
-{
- float val;
-
- switch (t) {
- case AudioPoint::PEAK:
- /* XXX: fall-off, or something...? */
- val = -200;
- for (list<float>::const_iterator i = data.begin(); i != data.end(); ++i) {
- val = max (val, *i);
- }
- return val;
- case AudioPoint::RMS:
- val = 0;
- for (list<float>::const_iterator i = data.begin(); i != data.end(); ++i) {
- val += pow (*i, 2);
- }
- return sqrt (val / data.size());
- default:
- assert (false);
- }
-
- return 0;
-}