Blender V2.61 - r43446
|
00001 /* 00002 * ***** BEGIN GPL LICENSE BLOCK ***** 00003 * 00004 * Copyright 2009-2011 Jörg Hermann Müller 00005 * 00006 * This file is part of AudaSpace. 00007 * 00008 * Audaspace is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * AudaSpace is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with Audaspace; if not, write to the Free Software Foundation, 00020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include "AUD_SequencerFactory.h" 00031 #include "AUD_SequencerReader.h" 00032 #include "AUD_3DMath.h" 00033 00034 AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, float fps, bool muted) : 00035 m_specs(specs), 00036 m_status(0), 00037 m_entry_status(0), 00038 m_id(0), 00039 m_muted(muted), 00040 m_fps(fps), 00041 m_speed_of_sound(434), 00042 m_doppler_factor(1), 00043 m_distance_model(AUD_DISTANCE_MODEL_INVERSE_CLAMPED), 00044 m_location(3), 00045 m_orientation(4) 00046 { 00047 AUD_Quaternion q; 00048 m_orientation.write(q.get()); 00049 float f = 1; 00050 m_volume.write(&f); 00051 00052 pthread_mutexattr_t attr; 00053 pthread_mutexattr_init(&attr); 00054 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); 00055 00056 pthread_mutex_init(&m_mutex, &attr); 00057 00058 pthread_mutexattr_destroy(&attr); 00059 } 00060 00061 AUD_SequencerFactory::~AUD_SequencerFactory() 00062 { 00063 pthread_mutex_destroy(&m_mutex); 00064 } 00065 00066 void AUD_SequencerFactory::lock() 00067 { 00068 pthread_mutex_lock(&m_mutex); 00069 } 00070 00071 void AUD_SequencerFactory::unlock() 00072 { 00073 pthread_mutex_unlock(&m_mutex); 00074 } 00075 00076 void AUD_SequencerFactory::setSpecs(AUD_Specs specs) 00077 { 00078 lock(); 00079 00080 m_specs = specs; 00081 m_status++; 00082 00083 unlock(); 00084 } 00085 00086 void AUD_SequencerFactory::setFPS(float fps) 00087 { 00088 lock(); 00089 00090 m_fps = fps; 00091 00092 unlock(); 00093 } 00094 00095 void AUD_SequencerFactory::mute(bool muted) 00096 { 00097 lock(); 00098 00099 m_muted = muted; 00100 00101 unlock(); 00102 } 00103 00104 bool AUD_SequencerFactory::getMute() const 00105 { 00106 return m_muted; 00107 } 00108 00109 float AUD_SequencerFactory::getSpeedOfSound() const 00110 { 00111 return m_speed_of_sound; 00112 } 00113 00114 void AUD_SequencerFactory::setSpeedOfSound(float speed) 00115 { 00116 lock(); 00117 00118 m_speed_of_sound = speed; 00119 m_status++; 00120 00121 unlock(); 00122 } 00123 00124 float AUD_SequencerFactory::getDopplerFactor() const 00125 { 00126 return m_doppler_factor; 00127 } 00128 00129 void AUD_SequencerFactory::setDopplerFactor(float factor) 00130 { 00131 lock(); 00132 00133 m_doppler_factor = factor; 00134 m_status++; 00135 00136 unlock(); 00137 } 00138 00139 AUD_DistanceModel AUD_SequencerFactory::getDistanceModel() const 00140 { 00141 return m_distance_model; 00142 } 00143 00144 void AUD_SequencerFactory::setDistanceModel(AUD_DistanceModel model) 00145 { 00146 lock(); 00147 00148 m_distance_model = model; 00149 m_status++; 00150 00151 unlock(); 00152 } 00153 00154 AUD_AnimateableProperty* AUD_SequencerFactory::getAnimProperty(AUD_AnimateablePropertyType type) 00155 { 00156 switch(type) 00157 { 00158 case AUD_AP_VOLUME: 00159 return &m_volume; 00160 case AUD_AP_LOCATION: 00161 return &m_location; 00162 case AUD_AP_ORIENTATION: 00163 return &m_orientation; 00164 default: 00165 return NULL; 00166 } 00167 } 00168 00169 AUD_Reference<AUD_SequencerEntry> AUD_SequencerFactory::add(AUD_Reference<AUD_IFactory> sound, float begin, float end, float skip) 00170 { 00171 lock(); 00172 00173 AUD_Reference<AUD_SequencerEntry> entry = new AUD_SequencerEntry(sound, begin, end, skip, m_id++); 00174 00175 m_entries.push_front(entry); 00176 m_entry_status++; 00177 00178 unlock(); 00179 00180 return entry; 00181 } 00182 00183 void AUD_SequencerFactory::remove(AUD_Reference<AUD_SequencerEntry> entry) 00184 { 00185 lock(); 00186 00187 m_entries.remove(entry); 00188 m_entry_status++; 00189 00190 unlock(); 00191 } 00192 00193 AUD_Reference<AUD_IReader> AUD_SequencerFactory::createQualityReader() 00194 { 00195 return new AUD_SequencerReader(this, true); 00196 } 00197 00198 AUD_Reference<AUD_IReader> AUD_SequencerFactory::createReader() 00199 { 00200 return new AUD_SequencerReader(this); 00201 }