JackTrip
|
00001 //***************************************************************** 00002 /* 00003 JackTrip: A System for High-Quality Audio Network Performance 00004 over the Internet 00005 00006 Copyright (c) 2008 Juan-Pablo Caceres, Chris Chafe. 00007 SoundWIRE group at CCRMA, Stanford University. 00008 00009 Permission is hereby granted, free of charge, to any person 00010 obtaining a copy of this software and associated documentation 00011 files (the "Software"), to deal in the Software without 00012 restriction, including without limitation the rights to use, 00013 copy, modify, merge, publish, distribute, sublicense, and/or sell 00014 copies of the Software, and to permit persons to whom the 00015 Software is furnished to do so, subject to the following 00016 conditions: 00017 00018 The above copyright notice and this permission notice shall be 00019 included in all copies or substantial portions of the Software. 00020 00021 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00022 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 00023 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00024 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 00025 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00026 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00027 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00028 OTHER DEALINGS IN THE SOFTWARE. 00029 */ 00030 //***************************************************************** 00031 00038 #ifndef __NETKS_H__ 00039 #define __NETKS_H__ 00040 00041 #include <iostream> 00042 #include <unistd.h> 00043 00044 #include <QTimer> 00045 00046 #include "ProcessPlugin.h" 00047 00052 class NetKS : public ProcessPlugin 00053 { 00054 Q_OBJECT; 00055 00056 00057 public: 00058 /* 00059 void play() 00060 { 00061 std::cout << "********** PALYING ***********************************" << std::endl; 00062 QTimer *timer = new QTimer(this); 00063 QObject::connect(timer, SIGNAL(timeout()), this, SLOT(exciteString())); 00064 timer->start(300); 00065 } 00066 */ 00067 00068 private slots: 00069 00071 void exciteString() 00072 { 00073 std::cout << "========= EXTICING STRING ===========" << std::endl; 00074 fbutton0 = 1.0; 00075 //std::cout << fbutton0 << std::endl; 00076 usleep(280000); 00077 fbutton0 = 0.0; 00078 //std::cout << fbutton0 << std::endl; 00079 } 00080 00081 //=========== FROM FAUST =================================================== 00082 private: 00083 float fbutton0; 00084 float fVec0[2]; 00085 float fRec0[2]; 00086 int iRec1[2]; 00087 float fVec1[2]; 00088 public: 00089 virtual int getNumInputs() { return 1; } 00090 virtual int getNumOutputs() { return 1; } 00091 static void classInit(int /*samplingFreq*/) {} 00092 virtual void instanceInit(int samplingFreq) { 00093 fSamplingFreq = samplingFreq; 00094 fbutton0 = 0.0; 00095 for (int i=0; i<2; i++) fVec0[i] = 0; 00096 for (int i=0; i<2; i++) fRec0[i] = 0; 00097 for (int i=0; i<2; i++) iRec1[i] = 0; 00098 for (int i=0; i<2; i++) fVec1[i] = 0; 00099 } 00100 virtual void init(int samplingFreq) { 00101 classInit(samplingFreq); 00102 instanceInit(samplingFreq); 00103 } 00104 /* 00105 virtual void buildUserInterface(UI* interface) { 00106 interface->openVerticalBox("excitator"); 00107 interface->addButton("play", &fbutton0); 00108 interface->closeBox(); 00109 } 00110 */ 00111 virtual void compute (int count, float** input, float** output) { 00112 float* input0 = input[0]; 00113 float* output0 = output[0]; 00114 float fSlow0 = fbutton0; 00115 for (int i=0; i<count; i++) { 00116 fVec0[0] = fSlow0; 00117 fRec0[0] = ((((fSlow0 - fVec0[1]) > 0.000000f) + fRec0[1]) - (3.333333e-03f * (fRec0[1] > 0.000000f))); 00118 iRec1[0] = (12345 + (1103515245 * iRec1[1])); 00119 float fTemp0 = ((4.190951e-10f * iRec1[0]) * (fRec0[0] > 0.000000f)); 00120 float fTemp1 = input0[i]; 00121 fVec1[0] = (fTemp1 + fTemp0); 00122 output0[i] = (0.500000f * ((fTemp0 + fTemp1) + fVec1[1])); 00123 // post processing 00124 fVec1[1] = fVec1[0]; 00125 iRec1[1] = iRec1[0]; 00126 fRec0[1] = fRec0[0]; 00127 fVec0[1] = fVec0[0]; 00128 } 00129 } 00130 00131 //============================================================================ 00132 00133 }; 00134 00135 00136 #endif // __NETKS_H__ 00137