Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related Input.cpp00001 // 00002 // SYNTOPIA. See http://Syntopia.sourceforge.net for details and documentation. 00003 // 00004 // Author of this file: Mikael Hvidtfeldt Christensen (mikaelc@users.sourceforge.net) 00005 // 00006 00007 00008 #include "Input.h" 00009 #include "Output.h" 00010 #include "Modules.h" 00011 #include "Synth.h" 00012 00013 // ------------------------------------------------------------------------------------ 00014 00015 namespace SynthCore { 00016 00017 void Input::ConnectFrom(Output * O) { 00018 ConFrom = O; 00019 00020 } 00021 00022 Input::Input(Module* host) { 00023 HostModule = host; 00024 ConFrom = 0; manualUpdate = false; 00025 host->addInput(this); // Register input at host. 00026 } 00027 00028 float Input::updateRead() { 00029 ConFrom->HostModule->update(); 00030 return ConFrom->value; 00031 } 00032 00033 string Input::getXML(string tag, int indent ) { 00034 return ( Utils::space(indent) + "<" +tag+ " ID=\"" + Utils::intToString((int)this) 00035 + "\" ConnectFrom=\"" + Utils::intToString((int) ConFrom )+ "\" />" + Utils::newline() ); 00036 } 00037 00038 00039 void Input::loadXML(string tagName, XMLNode * n) { 00040 XMLNode * node = n->getTag(tagName) ; 00041 if (node == 0) { throw parseError("Tag missing: "+ tagName); } 00042 00043 string Attr = ((TagNode *)node)->getAttribute("ConnectFrom"); 00044 if (Attr!="" && Attr!="\"0\"") { 00045 Output * Out = SynthEngine::mySynth->XMLGetOutput(Attr); 00046 00047 if (Out != 0) { 00048 cout << "Connecting from: " << Out->HostModule->getName() 00049 << " to this: " << HostModule->getName() << endl; 00050 00051 ConnectFrom(Out); 00052 } else 00053 { 00054 cout << "NO OUTPUT IN MAP:" << Attr << "."<< endl; 00055 throw parseError("Could not find output in "+HostModule->getName()+ ". Check 'connectFrom' tag."); 00056 } 00057 } else { 00058 cout << "NO CONNECTFROM TAG IN "+tagName << endl; 00059 // We are not connected 00060 ; 00061 } 00062 00063 } 00064 00065 00066 // ------------------------------------------------------------------------------------ 00067 00068 00069 void Output::ConnectTo(Input * I) { 00070 I->ConnectFrom(this); value=0.0f; 00071 } 00072 00073 00074 00075 void Output::loadXML(string tagName, XMLNode * n) { 00076 XMLNode * node = n->getTag(tagName) ; 00077 if (node == 0) { throw parseError("Tag missing: "+ tagName); } 00078 00079 string Attr = ((TagNode *)node)->getAttribute("ID"); 00080 cout << "Found attr: " << Attr << "Registering output" << endl; 00081 SynthEngine::mySynth->XMLRegister(Attr, this); 00082 } 00083 00084 string Output::getXML(string tag, int indent ) { 00085 return Utils::space(indent)+"<"+tag+" ID=\""+Utils::intToString((int)this)+"\" />" + Utils::newline(); 00086 } 00087 00088 00089 Output::Output(Module* host) { 00090 HostModule = host; 00091 host->addOutput(this); // Register output at host. 00092 } 00093 00094 }; // end of namespace: SynthCore Docs made by Doxygen. Email: Mikael Christensen |