00001 // Sample.cc - an audio sample class. 00002 // 00003 // Vamos Automotive Simulator 00004 // Copyright (C) 2003 Sam Varner 00005 // 00006 // This program is free software; you can redistribute it and/or modify 00007 // it under the terms of the GNU General Public License as published by 00008 // the Free Software Foundation; either version 2 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // This program is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU General Public License 00017 // along with this program; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 #include <vamos/geometry/Sample.h> 00021 00022 Vamos_Geometry:: 00023 Sample::Sample (std::string file, double base_volume, double base_pitch, 00024 bool volume_envelope, bool pitch_envelope) 00025 /*: 00026 m_base_volume (base_volume), 00027 m_base_pitch (base_pitch), 00028 m_loop (false), 00029 mp_volume_envelope (volume_envelope ? new slEnvelope () : 0), 00030 mp_pitch_envelope (pitch_envelope ? new slEnvelope () : 0), 00031 mp_scheduler (0)*/ 00032 { 00033 /*if (!loadFile (const_cast <char*> (file.c_str ()))) 00034 { 00035 throw (Missing_Sound_File (file)); 00036 }*/ 00037 } 00038 00039 Vamos_Geometry:: 00040 Sample::~Sample () 00041 { 00042 /*if (mp_scheduler != 0) 00043 { 00044 // Stop the scheduler playing the sample before deleting. 00045 mp_scheduler->stopSample (this); 00046 mp_scheduler->update (); 00047 00048 // Remove the envelopes (by adding a null envelope) before deleting. 00049 if (mp_volume_envelope != 0) 00050 { 00051 mp_scheduler->addSampleEnvelope (this, 0, 1, 0, SL_VOLUME_ENVELOPE); 00052 } 00053 if (mp_pitch_envelope != 0) 00054 { 00055 mp_scheduler->addSampleEnvelope (this, 0, 0, 0, SL_PITCH_ENVELOPE); 00056 } 00057 } 00058 delete mp_pitch_envelope; 00059 delete mp_volume_envelope;*/ 00060 } 00061 00062 void Vamos_Geometry:: 00063 Sample::schedule (slScheduler* scheduler, bool loop, int priority) 00064 { 00065 /*mp_scheduler = scheduler; 00066 m_loop = loop; 00067 00068 if (m_loop) 00069 { 00070 mp_scheduler->loopSample (this, priority); 00071 } 00072 00073 if (mp_volume_envelope != 0) 00074 { 00075 mp_scheduler->addSampleEnvelope (this, 0, 1, mp_volume_envelope, 00076 SL_VOLUME_ENVELOPE); 00077 } 00078 if (mp_pitch_envelope != 0) 00079 { 00080 mp_scheduler->addSampleEnvelope (this, 0, 0, mp_pitch_envelope, 00081 SL_PITCH_ENVELOPE); 00082 }*/ 00083 } 00084 00085 void Vamos_Geometry:: 00086 Sample::volume (double volume_factor) 00087 { 00088 //mp_volume_envelope->setStep (0, 0.0, volume_factor * m_base_volume); 00089 } 00090 00091 void Vamos_Geometry:: 00092 Sample::pitch (double pitch_factor) 00093 { 00094 //mp_pitch_envelope->setStep (0, 0.0, pitch_factor * m_base_pitch); 00095 } 00096 00097 void Vamos_Geometry:: 00098 Sample::play () 00099 { 00100 /*if (mp_scheduler != 0) 00101 { 00102 if (m_loop) 00103 { 00104 mp_scheduler->resumeSample (this); 00105 } 00106 else 00107 { 00108 mp_scheduler->playSample (this); 00109 } 00110 }*/ 00111 } 00112 00113 void Vamos_Geometry:: 00114 Sample::pause () 00115 { 00116 /*if (mp_scheduler != 0) 00117 { 00118 mp_scheduler->pauseSample (this); 00119 }*/ 00120 } 00121 00122 void Vamos_Geometry:: 00123 Sample::stop () 00124 { 00125 /*if (mp_scheduler != 0) 00126 { 00127 mp_scheduler->stopSample (this); 00128 }*/ 00129 }
1.4.6