2
Bear Engine - Editor library
4
Copyright (C) 2005-2010 Julien Jorge, Sebastien Angibaud
6
This program is free software; you can redistribute it and/or modify it
7
under the terms of the GNU General Public License as published by the
8
Free Software Foundation; either version 2 of the License, or (at your
9
option) any later version.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
You should have received a copy of the GNU General Public License along
17
with this program; if not, write to the Free Software Foundation, Inc.,
18
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
contact: plee-the-bear@gamned.org
22
Please add the tag [Bear] in the subject of your mails.
25
* \file bf/code/sample.cpp
26
* \brief Implementation of the bf::sample class.
27
* \author Julien Jorge
29
#include "bf/sample.hpp"
31
#include "bf/compiled_file.hpp"
32
#include "bf/path_configuration.hpp"
34
/*----------------------------------------------------------------------------*/
36
* \brief Default constructor.
39
: m_loops(1), m_volume(1)
44
/*----------------------------------------------------------------------------*/
46
* \brief Set the path to the resource to use.
47
* \param name The new value.
49
void bf::sample::set_path( const std::string& name )
52
} // sample::set_path()
54
/*----------------------------------------------------------------------------*/
56
* \brief Set the number of times the sample will be played.
57
* \param loops The new value.
59
void bf::sample::set_loops( const unsigned int loops )
62
} // sample::set_loops()
64
/*----------------------------------------------------------------------------*/
66
* \brief The volume at which the sample is played.
67
* \param v The new value, in the interval (0,1).
69
void bf::sample::set_volume( const double v )
77
} // sample::set_volume()
79
/*----------------------------------------------------------------------------*/
81
* \brief Get how many times the sample will be played.
83
unsigned int bf::sample::get_loops() const
86
} // sample::get_loops()
88
/*----------------------------------------------------------------------------*/
90
* \brief Get the volume at which the sample is played.
92
double bf::sample::get_volume() const
95
} // sample::get_volume()
97
/*----------------------------------------------------------------------------*/
99
* \brief Get the path to the resource to use.
101
const std::string& bf::sample::get_path() const
104
} // sample::get_path()
106
/*----------------------------------------------------------------------------*/
108
* \brief Tell if two samples are the same.
109
* \param that The instance to compare to.
111
bool bf::sample::operator==( const sample& that ) const
113
return (m_path == that.m_path)
114
&& (m_loops == that.m_loops)
115
&& (m_volume == that.m_volume);
116
} // sample::operator==()
118
/*----------------------------------------------------------------------------*/
120
* \brief Tell if two samples are different.
121
* \param that The instance to compare to.
123
bool bf::sample::operator!=( const sample& that ) const
125
return !(*this == that);
126
} // sample::operator!=()
128
/*----------------------------------------------------------------------------*/
130
* \brief Compile the sample.
131
* \param f The stream in which we write the compiled sample.
133
void bf::sample::compile( compiled_file& f ) const
135
std::string path(m_path);
137
if ( path_configuration::get_instance().expand_file_name(path) )
138
path_configuration::get_instance().get_relative_path(path);
140
f << path << m_loops << m_volume;
141
} // sample::compile()