|
Blender
V2.59
|
00001 /* 00002 * $Id: AUD_SequencerFactory.cpp 36092 2011-04-10 22:40:37Z nexyon $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * Copyright 2009-2011 Jörg Hermann Müller 00007 * 00008 * This file is part of AudaSpace. 00009 * 00010 * Audaspace is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * AudaSpace is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with Audaspace; if not, write to the Free Software Foundation, 00022 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include "AUD_SequencerFactory.h" 00033 #include "AUD_SequencerReader.h" 00034 00035 typedef std::list<AUD_SequencerReader*>::iterator AUD_ReaderIterator; 00036 00037 AUD_SequencerFactory::AUD_SequencerFactory(AUD_Specs specs, bool muted, 00038 void* data, 00039 AUD_volumeFunction volume) : 00040 m_specs(specs), 00041 m_muted(muted), 00042 m_data(data), 00043 m_volume(volume) 00044 { 00045 } 00046 00047 AUD_SequencerFactory::~AUD_SequencerFactory() 00048 { 00049 AUD_SequencerReader* reader; 00050 AUD_SequencerEntry* entry; 00051 00052 while(!m_readers.empty()) 00053 { 00054 reader = m_readers.front(); 00055 m_readers.pop_front(); 00056 reader->destroy(); 00057 } 00058 00059 while(!m_entries.empty()) 00060 { 00061 entry = m_entries.front(); 00062 m_entries.pop_front(); 00063 delete entry; 00064 } 00065 } 00066 00067 void AUD_SequencerFactory::mute(bool muted) 00068 { 00069 m_muted = muted; 00070 } 00071 00072 bool AUD_SequencerFactory::getMute() const 00073 { 00074 return m_muted; 00075 } 00076 00077 AUD_IReader* AUD_SequencerFactory::newReader() 00078 { 00079 AUD_SequencerReader* reader = new AUD_SequencerReader(this, m_entries, 00080 m_specs, m_data, 00081 m_volume); 00082 m_readers.push_front(reader); 00083 00084 return reader; 00085 } 00086 00087 AUD_SequencerEntry* AUD_SequencerFactory::add(AUD_IFactory** sound, float begin, float end, float skip, void* data) 00088 { 00089 AUD_SequencerEntry* entry = new AUD_SequencerEntry; 00090 entry->sound = sound; 00091 entry->begin = begin; 00092 entry->skip = skip; 00093 entry->end = end; 00094 entry->muted = false; 00095 entry->data = data; 00096 00097 m_entries.push_front(entry); 00098 00099 for(AUD_ReaderIterator i = m_readers.begin(); i != m_readers.end(); i++) 00100 (*i)->add(entry); 00101 00102 return entry; 00103 } 00104 00105 void AUD_SequencerFactory::remove(AUD_SequencerEntry* entry) 00106 { 00107 for(AUD_ReaderIterator i = m_readers.begin(); i != m_readers.end(); i++) 00108 (*i)->remove(entry); 00109 00110 m_entries.remove(entry); 00111 00112 delete entry; 00113 } 00114 00115 void AUD_SequencerFactory::move(AUD_SequencerEntry* entry, float begin, float end, float skip) 00116 { 00117 entry->begin = begin; 00118 entry->skip = skip; 00119 entry->end = end; 00120 } 00121 00122 void AUD_SequencerFactory::mute(AUD_SequencerEntry* entry, bool mute) 00123 { 00124 entry->muted = mute; 00125 } 00126 00127 AUD_IReader* AUD_SequencerFactory::createReader() const 00128 { 00129 return const_cast<AUD_SequencerFactory*>(this)->newReader(); 00130 } 00131 00132 void AUD_SequencerFactory::removeReader(AUD_SequencerReader* reader) 00133 { 00134 m_readers.remove(reader); 00135 }