#include <ISoundElement.h>
Classes | |
class | Lock |
Public Member Functions | |
void | AddInput (ISoundElement *element) |
void | DelParameter (const string &pname) |
ISoundElement * | GetParameter (const string &pname) |
SoundFrame & | GetPipe () |
ISoundElement () | |
void | RemoveInput (ISoundElement *element) |
void | SetParameter (const string &pname, ISoundElement *e) |
virtual | ~ISoundElement () |
Protected Member Functions | |
virtual void | Process (jack_nframes_t count) |
Protected Attributes | |
list< ISoundElement * > | m_inputs |
Private Member Functions | |
bool | _Ready (unsigned int tickid) |
bool | _Updatable (unsigned int tickid) |
void | _Update (unsigned int tickid, jack_nframes_t count) |
Private Attributes | |
unsigned int | m_lasttickid |
pthread_mutex_t | m_mtx |
map< string, ISoundElement * > | m_parameters |
SoundFrame | m_pipe |
Friends | |
class | JackClient |
class | Lock |
Definition at line 14 of file ISoundElement.h.
ISoundElement::ISoundElement | ( | ) |
Definition at line 8 of file ISoundElement.cpp.
References JackClient::GetSingleton(), JackClient::m_elements, and m_mtx.
00009 { 00010 JackClient::GetSingleton()->m_elements.push_back(this); 00011 pthread_mutex_init(&m_mtx, NULL); 00012 }
ISoundElement::~ISoundElement | ( | ) | [virtual] |
Definition at line 14 of file ISoundElement.cpp.
References JackClient::GetSingleton(), JackClient::m_elements, and m_mtx.
00015 { 00016 pthread_mutex_destroy(&m_mtx); 00017 try { 00018 JackClient::GetSingleton()->m_elements.remove(this); 00019 } 00020 catch(...) {} //Ignore. 00021 }
bool ISoundElement::_Ready | ( | unsigned int | tickid | ) | [private] |
Definition at line 93 of file ISoundElement.cpp.
References m_lasttickid.
Referenced by _Updatable().
00094 { 00095 //Return whether our pipe is out of date. 00096 return m_lasttickid != tickid; 00097 }
bool ISoundElement::_Updatable | ( | unsigned int | tickid | ) | [private] |
Definition at line 70 of file ISoundElement.cpp.
References _Ready(), m_inputs, and m_parameters.
00071 { 00072 Lock l(this); 00073 00074 list<ISoundElement*>::iterator i; 00075 for (i = m_inputs.begin(); i != m_inputs.end(); ++i) { 00076 //If any of our inputs still need updating, we're not yet updatable. 00077 if ((*i)->_Ready(tickid) == true) { 00078 return false; 00079 } 00080 } 00081 00082 map<string, ISoundElement*>::iterator pi; 00083 for (pi = m_parameters.begin(); pi != m_parameters.end(); ++pi) { 00084 //If any of our parameters still need updating, we're not yet updatable. 00085 if (pi->second->_Ready(tickid) == true) { 00086 return false; 00087 } 00088 } 00089 00090 return true && _Ready(tickid); 00091 }
void ISoundElement::_Update | ( | unsigned int | tickid, | |
jack_nframes_t | count | |||
) | [private] |
Definition at line 99 of file ISoundElement.cpp.
References m_lasttickid, and Process().
00100 { 00101 //Lock l(this); 00102 00103 m_lasttickid = tickid; 00104 Process(count); 00105 }
void ISoundElement::AddInput | ( | ISoundElement * | element | ) |
Definition at line 38 of file ISoundElement.cpp.
References m_inputs.
Referenced by BOOST_PYTHON_MODULE().
void ISoundElement::DelParameter | ( | const string & | pname | ) |
Definition at line 65 of file ISoundElement.cpp.
References m_parameters.
Referenced by BOOST_PYTHON_MODULE().
00066 { 00067 m_parameters.erase(pname); 00068 }
ISoundElement * ISoundElement::GetParameter | ( | const string & | pname | ) |
Definition at line 50 of file ISoundElement.cpp.
References m_parameters.
Referenced by Amp::Process().
00051 { 00052 Lock l(this); 00053 map<string, ISoundElement*>::iterator i = m_parameters.find(pname); 00054 if (i != m_parameters.end()) { 00055 return i->second; 00056 } 00057 throw runtime_error("No parameter named " + pname + "." ); 00058 }
SoundFrame & ISoundElement::GetPipe | ( | ) |
Definition at line 24 of file ISoundElement.cpp.
References m_pipe.
Referenced by Waveform::Process(), Recorder::Process(), JackOutput::Process(), JackInput::Process(), ISoundSource::Process(), Process(), and Amp::Process().
00025 { 00026 return m_pipe; 00027 }
void ISoundElement::Process | ( | jack_nframes_t | count | ) | [protected, virtual] |
Reimplemented in Amp, ISoundSource, JackInput, JackOutput, Recorder, and Waveform.
Definition at line 29 of file ISoundElement.cpp.
References GetPipe(), m_inputs, and SoundFrame::Zero().
Referenced by _Update().
00030 { 00031 GetPipe().Zero(); 00032 list<ISoundElement*>::iterator i; 00033 for (i = m_inputs.begin(); i != m_inputs.end(); i++) { 00034 GetPipe() += (*i)->GetPipe(); 00035 } 00036 }
void ISoundElement::RemoveInput | ( | ISoundElement * | element | ) |
Definition at line 44 of file ISoundElement.cpp.
References m_inputs.
Referenced by BOOST_PYTHON_MODULE().
void ISoundElement::SetParameter | ( | const string & | pname, | |
ISoundElement * | e | |||
) |
Definition at line 60 of file ISoundElement.cpp.
References m_parameters.
Referenced by BOOST_PYTHON_MODULE().
00061 { 00062 m_parameters[pname] = e; 00063 }
friend class JackClient [friend] |
Definition at line 16 of file ISoundElement.h.
friend class Lock [friend] |
Definition at line 17 of file ISoundElement.h.
list<ISoundElement*> ISoundElement::m_inputs [protected] |
Definition at line 47 of file ISoundElement.h.
Referenced by _Updatable(), AddInput(), Process(), and RemoveInput().
unsigned int ISoundElement::m_lasttickid [private] |
pthread_mutex_t ISoundElement::m_mtx [private] |
Definition at line 54 of file ISoundElement.h.
Referenced by ISoundElement(), ISoundElement::ISoundElement::Lock::Lock(), ~ISoundElement(), and ISoundElement::ISoundElement::Lock::~Lock().
map<string, ISoundElement*> ISoundElement::m_parameters [private] |
Definition at line 49 of file ISoundElement.h.
Referenced by _Updatable(), DelParameter(), GetParameter(), and SetParameter().
SoundFrame ISoundElement::m_pipe [private] |