logo
Main Page | Namespaces | Classes | Compounds | Files | Compound Members | Related

Modules.cpp

00001 //
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 // Visual C++ compiler warnings: 255 char limit on var names.....
00008 #pragma warning(disable: 4786)
00009 
00010 #include "modules.h"
00011 #include "math.h"
00012 #include "SynthVoice.h"
00013 
00014 using namespace std;
00015 
00016 namespace SynthCore {
00017 
00018 #define PI  3.141592653589793f
00019 
00020 // Those darn static variables - this is a bit ugly:
00021 int Module::IDCount = 1;
00022 
00023 
00024 // ------ Module methods -------------------------------------------------------------------------
00025 
00026 
00027 string Module::getXML(int indent ) { 
00028         return (Utils::space(indent)+"<Module> Undefined: "+getName()+" </Module>"+Utils::newline()); 
00029 }
00030 
00031 
00032 string Module::saveParameter(string tag, float f, int indent) {
00033         return Utils::space(indent)+"<"+tag+">" + Utils::floatToString(f) + "</"+tag+">"+Utils::newline() ;
00034 }
00035 
00036 
00037 
00038 string Module::saveParameter(string tag, std::string s, int indent) {
00039         return Utils::space(indent)+"<"+tag+">"+s+"</"+tag+">" +Utils::newline();
00040 }
00041 
00042 
00043 
00044 
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 string Module::saveID( int indent ) {
00053         return Utils::space(indent)+"<ID>"+Utils::intToString((int)this)+"</ID>" +Utils::newline()+
00054                         Utils::space(indent)+"<hostVoice>"+Utils::intToString((int)hostVoice)+"</hostVoice>" +Utils::newline()  ;
00055 }
00056 
00057 
00058 
00059 
00060 ostream & operator<< (ostream & ostr, Module & myMod)
00061 {
00062     return (ostr << myMod.getXML());
00063 }
00064 
00065 
00066 
00067 
00068 ostream & operator<< (ostream & ostr, Module * myMod)
00069 {
00070     return (ostr << myMod->getXML());
00071 }
00072 
00073 
00074 
00075 // Multiplier ----------------------------------------------------------------------------------------------------
00076 Multiplier::Multiplier(SynthVoice * S1) {
00077         hostVoice = S1;
00078         
00079         Input1 = new Input(this);
00080         Input2 = new Input(this);
00081         Output1 = new Output(this);
00082 }
00083 
00084 inline void Multiplier::update() {
00085         // Simple logic: multiply signals.
00086         Output1->write( Input1->read()*Input2->read() );
00087 }
00088 
00089 
00090 // Dummy
00091 
00092 Dummy::Dummy(SynthVoice * S1) {
00093         hostVoice = S1;
00094         
00095         Input1 = new Input(this);
00096         Output1 = new Output(this);
00097         Out = Input1->ConFrom;
00098         Ou1 = &Output1->value;
00099 }
00100 
00101 void Dummy::update() {
00102         Output1->value=Input1->ConFrom->value;
00103 }
00104 
00105 
00106 
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115 void Module::loadParameter(string tagName, float par, XMLNode * n) {
00116         string text = n->getTagText(tagName) ;
00117         if (text == "") { throw parseError("Tag missing: "+ tagName); }
00118 
00119         par = Utils::stringToFloat(text);
00120         cout << "Set parameter to: " << par << endl;
00121 }
00122 
00123 
00124 
00125 
00126 moduleRegistry * moduleRegistry::instance = 0;
00127 
00128 Module * Multiplier::newInstance(SynthVoice * S1) { 
00129         return new Multiplier(S1); 
00130 }
00131 
00132 void Module::loadXML(XMLNode * n, bool firstPass) { 
00133         cout << "NOT IMPLEMENTED" << endl;
00134 };
00135 
00136 
00137 }; // end of namespace: SynthCore
00138 
00139 

Syntopia Project. Visit the web page, or the SourceForge page.
Docs made by Doxygen. Email: Mikael Christensen