JackTrip
NetKS.h
Go to the documentation of this file.
1//*****************************************************************
2/*
3 JackTrip: A System for High-Quality Audio Network Performance
4 over the Internet
5
6 Copyright (c) 2008 Juan-Pablo Caceres, Chris Chafe.
7 SoundWIRE group at CCRMA, Stanford University.
8
9 Permission is hereby granted, free of charge, to any person
10 obtaining a copy of this software and associated documentation
11 files (the "Software"), to deal in the Software without
12 restriction, including without limitation the rights to use,
13 copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the
15 Software is furnished to do so, subject to the following
16 conditions:
17
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
23 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 OTHER DEALINGS IN THE SOFTWARE.
29*/
30//*****************************************************************
31
38#ifndef __NETKS_H__
39#define __NETKS_H__
40
41#include <iostream>
42//#include <unistd.h>
43
44#include <QTimer>
45
46#include "ProcessPlugin.h"
47
52class NetKS : public ProcessPlugin
53{
54 Q_OBJECT;
55
56
57public:
58 /*
59 void play()
60 {
61 std::cout << "********** PALYING ***********************************" << std::endl;
62 QTimer *timer = new QTimer(this);
63 QObject::connect(timer, SIGNAL(timeout()), this, SLOT(exciteString()));
64 timer->start(300);
65 }
66 */
67
68private slots:
69
71 void exciteString()
72 {
73 std::cout << "========= EXTICING STRING ===========" << std::endl;
74 fbutton0 = 1.0;
75 //std::cout << fbutton0 << std::endl;
76 QThread::usleep(280000);
77 fbutton0 = 0.0;
78 //std::cout << fbutton0 << std::endl;
79 }
80
81 //=========== FROM FAUST ===================================================
82private:
83 float fbutton0;
84 float fVec0[2];
85 float fRec0[2];
86 int iRec1[2];
87 float fVec1[2];
88public:
89 virtual int getNumInputs() { return 1; }
90 virtual int getNumOutputs() { return 1; }
91 static void classInit(int /*samplingFreq*/) {}
92 virtual void instanceInit(int samplingFreq) {
93 fSamplingFreq = samplingFreq;
94 fbutton0 = 0.0;
95 for (int i=0; i<2; i++) fVec0[i] = 0;
96 for (int i=0; i<2; i++) fRec0[i] = 0;
97 for (int i=0; i<2; i++) iRec1[i] = 0;
98 for (int i=0; i<2; i++) fVec1[i] = 0;
99 }
100 virtual void init(int samplingFreq) {
101 classInit(samplingFreq);
102 instanceInit(samplingFreq);
103 }
104 /*
105 virtual void buildUserInterface(UI* interface) {
106 interface->openVerticalBox("excitator");
107 interface->addButton("play", &fbutton0);
108 interface->closeBox();
109 }
110 */
111 virtual void compute (int count, float** input, float** output) {
112 float* input0 = input[0];
113 float* output0 = output[0];
114 float fSlow0 = fbutton0;
115 for (int i=0; i<count; i++) {
116 fVec0[0] = fSlow0;
117 fRec0[0] = ((((fSlow0 - fVec0[1]) > 0.000000f) + fRec0[1]) - (3.333333e-03f * (fRec0[1] > 0.000000f)));
118 iRec1[0] = (12345 + (1103515245 * iRec1[1]));
119 float fTemp0 = ((4.190951e-10f * iRec1[0]) * (fRec0[0] > 0.000000f));
120 float fTemp1 = input0[i];
121 fVec1[0] = (fTemp1 + fTemp0);
122 output0[i] = (0.500000f * ((fTemp0 + fTemp1) + fVec1[1]));
123 // post processing
124 fVec1[1] = fVec1[0];
125 iRec1[1] = iRec1[0];
126 fRec0[1] = fRec0[0];
127 fVec0[1] = fVec0[0];
128 }
129 }
130
131 //============================================================================
132
133};
134
135
136#endif // __NETKS_H__
A simple (basic) network Karplus Strong.
Definition: NetKS.h:53
virtual void init(int samplingFreq)
Do proper Initialization of members and class instances. By default this initializes the Sampling Fre...
Definition: NetKS.h:100
virtual void compute(int count, float **input, float **output)
Compute process.
Definition: NetKS.h:111
virtual void instanceInit(int samplingFreq)
Definition: NetKS.h:92
static void classInit(int)
Definition: NetKS.h:91
virtual int getNumOutputs()
Return Number of Output Channels.
Definition: NetKS.h:90
virtual int getNumInputs()
Return Number of Input Channels.
Definition: NetKS.h:89
Interface for the process plugins to add to the JACK callback process in JackAudioInterface.
Definition: ProcessPlugin.h:53
int fSamplingFreq
Faust Data member, Sampling Rate.
Definition: ProcessPlugin.h:92