Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

soundbuffer.cpp

Go to the documentation of this file.
00001 /*
00002         $Id: soundbuffer.cpp,v 1.1 2001/03/06 15:09:26 mbn Exp $
00003 
00004         ------------------------------------------------------------------------
00005         ClanLib, the platform independent game SDK.
00006 
00007         This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
00008         version 2. See COPYING for details.
00009 
00010         For a total list of contributers see CREDITS.
00011 
00012         ------------------------------------------------------------------------
00013 */
00014 
00015 #ifdef WIN32
00016 #pragma warning (disable:4786)
00017 #endif
00018 
00019 #include "API/Sound/soundbuffer.h"
00020 #include "API/Core/System/error.h"
00021 #include "resourcetype_sample.h"
00022 #include "soundbuffer_generic.h"
00023 #include "soundbuffer_static.h"
00024 #include "soundbuffer_stream.h"
00025 
00026 CL_SoundBuffer *CL_SoundBuffer::load(
00027         const char *res_id,
00028         CL_ResourceManager *manager)
00029 {
00030         return new CL_SoundBuffer(res_id, manager);
00031 }
00032 
00033 CL_SoundBuffer *CL_SoundBuffer::create(
00034         CL_StaticSoundProvider *provider,
00035         bool delete_provider)
00036 {
00037         return new CL_SoundBuffer(provider, delete_provider);
00038 }
00039 
00040 CL_SoundBuffer *CL_SoundBuffer::create(
00041         CL_StreamSoundProvider *provider,
00042         bool delete_provider)
00043 {
00044         return new CL_SoundBuffer(provider, delete_provider);
00045 }
00046 
00047 CL_SoundBuffer::CL_SoundBuffer(
00048         const char *res_id,
00049         CL_ResourceManager *manager)
00050 :
00051         impl(NULL)
00052 {
00053         CL_Resource *res = manager->get_resource(std::string(res_id));
00054         if (res == NULL) throw CL_Error("Unknown resource!");
00055         if (res->get_type() != "sample") throw CL_Error("Resource is not a sample!");
00056 
00057         impl = ((CL_WritableSampleResource *) res)->create_sample()->impl;
00058         impl->add_reference();
00059 }
00060 
00061 CL_SoundBuffer::CL_SoundBuffer(
00062         CL_StaticSoundProvider *provider,
00063         bool delete_provider,
00064         CL_Resource *resource)
00065 :
00066         impl(new CL_SoundBuffer_Generic_Static(provider, delete_provider, resource))
00067 {
00068         impl->add_reference();
00069 }
00070 
00071 CL_SoundBuffer::CL_SoundBuffer(
00072         CL_StreamSoundProvider *provider,
00073         bool delete_provider,
00074         CL_Resource *resource)
00075 :
00076         impl(new CL_SoundBuffer_Generic_Stream(provider, delete_provider, resource))
00077 {
00078         impl->add_reference();
00079 }
00080 
00081 CL_SoundBuffer::CL_SoundBuffer(const CL_SoundBuffer &copy)
00082 : impl(copy.impl)
00083 {
00084         impl->add_reference();
00085 }
00086 
00087 CL_SoundBuffer::~CL_SoundBuffer()
00088 {
00089         if (impl != NULL) impl->release_reference();
00090 }
00091 
00092 CL_StaticSoundProvider *CL_SoundBuffer::get_static_provider() const
00093 {
00094         return impl->get_static_provider();
00095 }
00096 
00097 CL_StreamSoundProvider *CL_SoundBuffer::get_stream_provider() const
00098 {
00099         return impl->get_stream_provider();
00100 }
00101 
00102 int CL_SoundBuffer::get_length() const
00103 {
00104         return impl->get_length();
00105 }
00106 
00107 int CL_SoundBuffer::get_num_samples() const
00108 {
00109         return impl->get_num_samples();
00110 }
00111 
00112 int CL_SoundBuffer::get_frequency() const
00113 {
00114         return impl->get_frequency();
00115 }
00116 
00117 bool CL_SoundBuffer::set_frequency(int new_freq)
00118 {
00119         return impl->set_frequency(new_freq);
00120 }
00121 
00122 float CL_SoundBuffer::get_volume() const
00123 {
00124         return impl->get_volume();
00125 }
00126 
00127 bool CL_SoundBuffer::set_volume(float new_volume)
00128 {
00129         return impl->set_volume(new_volume);
00130 }
00131 
00132 float CL_SoundBuffer::get_pan() const
00133 {
00134         return impl->get_pan();
00135 }
00136 
00137 bool CL_SoundBuffer::set_pan(float new_pan)
00138 {
00139         return impl->set_pan(new_pan);
00140 }
00141 
00142 bool CL_SoundBuffer::is_playing(
00143         CL_SoundBuffer_Session **session,
00144         CL_SoundCard *card) const
00145 {
00146         return impl->is_playing(session, card);
00147 }
00148 
00149 void CL_SoundBuffer::stop(CL_SoundCard *card)
00150 {
00151         impl->stop(card);
00152 }
00153 
00154 CL_SoundBuffer_Session CL_SoundBuffer::play(
00155         bool looping,
00156         CL_SoundCard *card)
00157 {
00158         return impl->play(looping, card);
00159 }
00160 
00161 CL_SoundBuffer_Session CL_SoundBuffer::prepare(
00162         bool looping,
00163         CL_SoundCard *card)
00164 {
00165         return impl->prepare(looping, card);
00166 }

Generated at Wed Apr 4 19:54:03 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001