diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/testApp.cpp | 18 | ||||
| -rwxr-xr-x | src/testApp.h | 9 | ||||
| -rwxr-xr-x | src/viewport.cpp | 37 | ||||
| -rwxr-xr-x | src/viewport.h | 17 |
4 files changed, 59 insertions, 22 deletions
diff --git a/src/testApp.cpp b/src/testApp.cpp index 967d2d1..e9b8403 100755 --- a/src/testApp.cpp +++ b/src/testApp.cpp @@ -88,7 +88,6 @@ void testApp::createports(int num){ //-------------------------------------------------------------- void testApp::setup(){ - windowsize=32; previewscale=5; showFPS=false; @@ -113,6 +112,9 @@ void testApp::setup(){ brightSlider=0; gui.add(bS.setup("brightness",brightSlider,0,255,255)); + fadeSlider=0; + gui.add(fS.setup("fade",fadeSlider,0,255,255)); + gui.add(create_1.setup("1")); create_1.addListener(this,&testApp::create1port); gui.add(create_2.setup("2")); @@ -127,8 +129,11 @@ void testApp::setup(){ gui.add(sF.setup("freq",slidFreq,0,1.0,255)); gui.add(wave.setup("wave", false)); + gui.add(fillwave.setup("wave fill", false)); slidThickness=1.0f; gui.add(sT.setup("thickness",slidThickness,0,10.0,255)); + slidWave=1.0f; + gui.add(sT.setup("amplitude",slidWave,0,4.0,255)); /* gui.setup("","panel.xml",0,0); @@ -167,7 +172,7 @@ void testApp::setup(){ soundStream.listDevices(); //if you want to set a different device id - //soundStream.setDeviceID(0); //bear in mind the device id corresponds to all audio devices, including input-only and output-only devices. + //soundStream.setDeviceID(4); //bear in mind the device id corresponds to all audio devices, including input-only and output-only devices. @@ -218,6 +223,9 @@ void testApp::update(){ control.freq=slidFreq; control.wave=wave; control.thickness=slidThickness; + control.fillwave=fillwave; + control.waveheight=slidWave; + control.fade=(uint8_t)fadeSlider; } //-------------------------------------------------------------- @@ -256,6 +264,12 @@ void testApp::keyPressed(int key){ if(key == OF_KEY_DOWN){ control.yshift++; } + if(key == OF_KEY_LEFT){ + control.xshift--; + } + if(key == OF_KEY_RIGHT){ + control.xshift++; + } } diff --git a/src/testApp.h b/src/testApp.h index 3148eb2..780bdc2 100755 --- a/src/testApp.h +++ b/src/testApp.h @@ -63,16 +63,23 @@ class testApp : public ofxFensterListener { ofxIntSlider bS; ofxParameter<int> brightSlider; + ofxIntSlider fS; + ofxParameter<int> fadeSlider; + ofxToggle fill; ofxFloatSlider sF; ofxParameter<float> slidFreq; ofxToggle wave; + ofxToggle fillwave; ofxFloatSlider sT; ofxParameter<float> slidThickness; + ofxFloatSlider sW; + ofxParameter<float> slidWave; + void create1port(bool & pressed); void create2port(bool & pressed); @@ -82,7 +89,7 @@ class testApp : public ofxFensterListener { vector<viewport> viewports; vpcontrol control; - int windowsize,previewscale; + int previewscale; // diff --git a/src/viewport.cpp b/src/viewport.cpp index c660ede..5a246e0 100755 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -13,11 +13,13 @@ viewport::viewport(int _w,int _h,int _ox,int _oy,int _num) { void viewport::setup(int _w,int _h,int _ox,int _oy,int _num) {
w=_w;
h=_h;
+ bw=w*oversample;
+ bh=h*oversample;
ox=_ox;
oy=_oy;
num=_num;
- rb1.allocate(w,h,GL_RGB);
- rb2.allocate(w,h,GL_RGB);
+ rb1.allocate(bw,bh,GL_RGB);
+ rb2.allocate(bw,bh,GL_RGB);
seed=ofRandom(1.0f);
}
@@ -27,17 +29,24 @@ void viewport::drawport(vpcontrol &control){ //can be done with texture offset?
- int startx=((w-(w*control.fscale))/2)+control.xshift;
- while (startx>0) startx-=(w*control.fscale);
- int starty=((h-(h*control.fscale))/2)+control.yshift;
- while (starty>0) starty-=(h*control.fscale);
+ int startx=((bw-(bw*control.fscale))/2)+control.xshift;
+ while (startx>0) startx-=(bw*control.fscale);
+ int starty=((bh-(bh*control.fscale))/2)+control.yshift;
+ while (starty>0) starty-=(bh*control.fscale);
- for (int i=startx;i<w*2;i+=(w*control.fscale)) {
- for (int j=starty;j<h*2;j+=(h*control.fscale)) {
- rb2.draw(i,j,w*control.fscale,h*control.fscale);
+ for (int i=startx;i<bw*2;i+=(bw*control.fscale)) {
+ for (int j=starty;j<bh*2;j+=(bh*control.fscale)) {
+ rb2.draw(i,j,bw*control.fscale,bh*control.fscale);
}
}
+ if (control.fade>0){
+ ofEnableAlphaBlending();
+ ofSetColor(0,0,0,control.fade);
+ ofRect(0,0,bw,bh);
+ ofDisableAlphaBlending();
+ }
+
//do whatever with feedback
//set draw colour from palette
@@ -51,7 +60,7 @@ void viewport::drawport(vpcontrol &control){ }
if (control.fill){
- ofRect(0,0,w,h);
+ ofRect(0,0,bw,bh);
}
ofSetLineWidth(3); //control.thickness);
@@ -59,15 +68,15 @@ void viewport::drawport(vpcontrol &control){ if(control.wave){
if (h>w){
ofBeginShape();
- for (int i = 0; i < h; i++){
- ofVertex((w/2) -(control.right[i+(num*h)]*w),i);
+ for (int i = 0; i < bh; i++){
+ ofVertex((bw/2) -(control.right[i+(num*bh)]*bw),i);
}
ofEndShape(false);
}
else {
ofBeginShape();
- for (int i = 0; i < w; i++){
- ofVertex(i, (h/2) -(control.right[i+(num*w)]*h) );
+ for (int i = 0; i < bw; i++){
+ ofVertex(i, (bh/2) -(control.right[i+(num*bw)]*bh) );
}
ofEndShape(false);
}
diff --git a/src/viewport.h b/src/viewport.h index b786fe9..1e3e8a8 100755 --- a/src/viewport.h +++ b/src/viewport.h @@ -4,8 +4,11 @@ #include "ofMain.h"
#include "ofxXmlSettings.h"
-static int bufferSize = 1024;
-static int bufferscale = 4;
+static int bufferSize = 2048;
+static int oversample = 8;
+static int windowsize = 32;
+
+//make sure that windowsize*oversample*8 <= buffersize
class palette {
public:
@@ -71,7 +74,10 @@ class vpcontrol { yshift=0;
fscale=1.0f;
wave=false;
+ fillwave=false;
thickness=1.0f;
+ waveheight=1.0f;
+ fade=0;
left.assign(bufferSize, 0.0);
right.assign(bufferSize, 0.0);
@@ -99,8 +105,9 @@ class vpcontrol { float freq;
int xshift,yshift;
float fscale,scale;
- bool wave;
- float thickness;
+ bool wave,fillwave;
+ float thickness,waveheight;
+ uint8_t fade;
vector <float> left;
vector <float> right;
@@ -126,7 +133,7 @@ class viewport palette Palette;
protected:
private:
- int x,y,w,h,ox,oy,num;
+ int x,y,w,h,bw,bh,ox,oy,num;
float seed;
};
|
