Exemplo n.º 1
0
void BufferCont::drawSolution(){
	
	float size = m_view[camBot].width<m_view[camBot].height ? m_view[camBot].width : m_view[camBot].height;
	if (g_showPop)	drawPoint(m_view[viewBot], m_cam[camBot], m_solPoint.front());

	m_cam[camBot].begin(m_view[viewBot]);
	ofSetColor(255, 0, 0);
	ofVec3f start, end;
	start.x = -size / 2;	start.y = -size / 2;		start.z = 0;
	end.x = size / 2; 		end.y = -size / 2;		end.z = 0;
	ofDrawArrow(start, end, 5.0);
	m_font.drawString("x1", end.x, end.y);
	end.x = -size / 2; end.y = size / 2; end.z = 0;
	ofDrawArrow(start, end, 5.0);
	m_font.drawString("x2", end.x, end.y);
	m_cam[camBot].end();

	ofPushView();
	ofViewport(m_view[viewBot]);
	ofSetupScreen();
	stringstream ss;
	ss << "evals: " << Global::msp_global->mp_problem->getEvaluations();
	ofSetColor(0, 0, 0);
	m_font.drawString(ss.str(), 5, 25);
	ofPopView();

}
Exemplo n.º 2
0
//--------------------------------------------------------------
void testApp::setup(){
	
	//samples from http://freesound.org
	samp.load(ofToDataPath("2630__Jovica__133_bpm_ATTACK_LOOP_04_electrified_analog_kit_variation_16_mono.wav"));
	samp2.load(ofToDataPath("24620__anamorphosis__GMB_Kantilan_1.wav"));
	samp3.load(ofToDataPath("26393__brfindla__Calango1berimbau.wav"));
	samp4.load(ofToDataPath("68373__juskiddink__Cello_open_string_bowed.wav"));
	samp5.load(ofToDataPath("71515__Microscopia__Wilhelm_Bruder_Sohne_Organ.wav"));
//	samp5.load(ofToDataPath("sine1sec.wav"));
	

	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetFrameRate(60);
	
	
	/* This is stuff you always need.*/
	sampleRate 			= 44100; /* Sampling Rate */
	initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
	lAudioOut			= new float[initialBufferSize];/* outputs */
	rAudioOut			= new float[initialBufferSize];
	lAudioIn			= new float[initialBufferSize];/* inputs */
	rAudioIn			= new float[initialBufferSize];
	
	
	/* This is a nice safe piece of code */
	memset(lAudioOut, 0, initialBufferSize * sizeof(float));
	memset(rAudioOut, 0, initialBufferSize * sizeof(float));
	
	memset(lAudioIn, 0, initialBufferSize * sizeof(float));
	memset(rAudioIn, 0, initialBufferSize * sizeof(float));
	
	
			   	
	ts = new maxiTimestretch<grainPlayerWin>(&samp);
	ts2 = new maxiTimestretch<grainPlayerWin>(&samp2);
	ts3 = new maxiTimestretch<grainPlayerWin>(&samp3);
	ts4 = new maxiTimestretch<grainPlayerWin>(&samp4);
	ts5 = new maxiTimestretch<grainPlayerWin>(&samp5);
	stretches.push_back(ts);
	stretches.push_back(ts2);
	stretches.push_back(ts3);
	stretches.push_back(ts4);
	stretches.push_back(ts5);
	speed = 1;
	grainLength = 0.05;
	current=0;
	
	fft.setup(1024, 512, 256);
	oct.setup(44100, 1024, 10);
	
	int current = 0;
	ofxMaxiSettings::setup(sampleRate, 2, initialBufferSize);
	ofSoundStreamSetup(2,0, this, maxiSettings::sampleRate, initialBufferSize, 4);/* Call this last ! */
	
	ofSetVerticalSync(true);
	ofEnableAlphaBlending();
	ofEnableSmoothing();
}
Exemplo n.º 3
0
void MCubeP::draw()
{
	ofSetupScreen();
	
	sC1->setColor(150,30,35);
	sC1->setPos(85,148);
		
	sC1->setStr(str);
	sC1->draw();
	
	if(gMode == 0)
	{
		ofSetColor(181,79,74);
		img1.img.draw(img1.pos.x,img1.pos.y,img1.size.x * 2,img1.size.y * 2);
		img2.img.draw(img2.pos.x,img2.pos.y,img2.size.x * 2,img2.size.y * 2);
		
		ofSetColor(180,30,35);
		ofSetLineWidth(8);
		ofLine(2,linePos,fw - 2,linePos);		
	}
	else if(gMode == 1)
	{
		ofSetColor(255,255,255);
		img3.img.draw(img3.pos.x,img3.pos.y,img3.size.x,img3.size.y);
	}
	
}
Exemplo n.º 4
0
//--------------------------------------------------------------
void testApp::draw(){

	if (drawOutlines == 1) ofNoFill();
	else ofFill();

	ofTranslate(x, y);

	for(int i = 0; i < numCircles; i++){
		unsigned char r = i * 34;
		unsigned char g = i * 93;
		unsigned char b = i * 17;
		ofSetColor(r,g,b);
		ofCircle(
					-ofGetWidth() * 0.5 + ofGetWidth() * ofNoise((ofGetFrameNum() + 20 * i) * 0.004  + i),
					-ofGetHeight() * 0.5 + ofGetHeight() * ofNoise((ofGetFrameNum() + 10 * i) * 0.004 + 4 * i),
					25
				 );
	}


	ofSetupScreen();
	ofDrawBitmapStringHighlight(
								string("SERVER\n") + 
								"x: " + ofToString(x) + "\n" +
								"y: " + ofToString(y) + "\n" +
								"drawOutlines: " + ofToString(drawOutlines) + "\n" +
								"currentSentence: " + currentSentence  + "\n" +
								"menu item: " + ofToString(menu) ,
								20, 20,
								ofColor::black, color
								);

	OFX_REMOTEUI_SERVER_DRAW(20, ofGetHeight() - 20);

}
Exemplo n.º 5
0
void ofkMeshRectRenderer::renderDebug()
{
    ofSetupScreen();
    
    ofSetColor(255,255,255,255);
    
    for(int vertical = 0 ; vertical < GridRES ; vertical++ )
    {
        //mVbos[vertical].draw(GL_LINE_STRIP, 0, 2*(GridRES+1));
        
    for(int i = 0; i <  2*(GridRES+1) ; i++)
    {
        
        if(vertical % 10 == 0)
        {
            if(i%10 == 0)
            {
                //
                ofDrawBitmapString( "V" + ofToString(vertical) + "UV" + ofToString(i), mTranslatedUV[vertical][i].x * ofGetWidth(), mTranslatedUV[vertical][i].y * ofGetHeight());
                
            }
        }
        //
        //ofDrawBitmapString( "V" + ofToString(vertical) + "UV" + ofToString(i), mTranslatedUV[vertical][i].x * ofGetWidth(), mTranslatedUV[vertical][i].y * ofGetHeight());
    }
    }
}
//----------
void ofxSplashScreen::begin(float minimumDuration) {
	if (!this->image.isAllocated()) {
		ofLogError("ofxSplashScreen") << "Cannot show splash screen since no image has been loaded";
		return;
	}
	this->endTime = ofGetElapsedTimef() + minimumDuration;
	this->appWindow = glfwGetCurrentContext();
	
	glfwHideWindow(this->appWindow);
	glfwWindowHint(GLFW_DECORATED, GL_FALSE);
	this->splashScreenWindow = glfwCreateWindow(this->image.getWidth(), this->image.getHeight(), "ofxSplashScreen", NULL, this->appWindow);
	glfwSetWindowPos(this->splashScreenWindow, (ofGetScreenWidth() - this->image.getWidth()) / 2.0f, (ofGetScreenHeight() - this->image.getHeight()) / 2.0f);
	glfwWindowHint(GLFW_DECORATED, GL_TRUE);
	glfwMakeContextCurrent(this->splashScreenWindow);
	
	//set the drawing matrices to normalised coordinates
	ofSetMatrixMode(OF_MATRIX_PROJECTION);
	ofLoadIdentityMatrix();
	ofSetMatrixMode(OF_MATRIX_MODELVIEW);
	ofLoadIdentityMatrix();
	
	//draw the images
	ofClear(0,0,0);
	this->image.update();
	this->image.draw(-1,-1,2,2);
	glfwSwapBuffers(this->splashScreenWindow);
	glFlush();
	
	//set the context back to main for rest of setup
	glfwMakeContextCurrent(this->appWindow);
	ofSetupScreen();
}
void wavStretcher::setup()
{
	
	//samples from http://freesound.org
	samp.load(ofToDataPath("organ.wav"));

	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetFrameRate(60);
	
	sampleRate 			= 44100; /* Sampling Rate */
	initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
			   	
	ts = new maxiTimestretch<hannWinFunctor>(&samp);
	
	stretches.push_back(ts);
	
	speed = 1;
	grainLength = 0.05;
	current=0;
	
	fft.setup(1024, 512, 256);
	octaveAnalyser.setup(44100, 1024, 10);
	
	int current = 0;
	ofxMaxiSettings::setup(sampleRate, 2, initialBufferSize);
	ofSoundStreamSetup(2,0, this, maxiSettings::sampleRate, initialBufferSize, 4);/* Call this last ! */
	
}
Exemplo n.º 8
0
void GLWidget::resizeGL(int width, int height)
{
	ofApp->windowResized(width, height);
	
	glViewport(0, 0, width, height);
	ofSetupScreen();			
	glFlush();
}
Exemplo n.º 9
0
//--------------------------------------------------------------
void testApp::draw()
{
	glDrawBuffer(GL_BACK);									//draw into both back buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		//clear color and depth buffers
	glDrawBuffer(GL_BACK_LEFT);								//draw into back left buffer
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();										//reset projection matrix
	glFrustum(leftCam.leftfrustum, leftCam.rightfrustum,	//set left view frustum
			  leftCam.bottomfrustum, leftCam.topfrustum,
			  nearZ, farZ);
	glTranslatef(leftCam.modeltranslation, 0.0, 0.0);		//translate to cancel parallax
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glPushMatrix();
	{
		glTranslatef(0.0, 0.0, depthZ);						//translate to screenplane
		net.draw();
#ifdef USE_GUI
		ofSetColor(0xffffff);
		glScalef(1./100., -1./100., 1.);
		glTranslatef(0.0, 0.0, 3.);
		gui.draw();
#endif
	}
	glPopMatrix();

	glDrawBuffer(GL_BACK_RIGHT);							 //draw into back right buffer
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();										//reset projection matrix
	glFrustum(rightCam.leftfrustum, rightCam.rightfrustum,   //set left view frustum
			  rightCam.bottomfrustum, rightCam.topfrustum,
			  nearZ, farZ);
	glTranslatef(rightCam.modeltranslation, 0.0, 0.0);	   //translate to cancel parallax
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glPushMatrix();
	{
		glTranslatef(0.0, 0.0, depthZ);						//translate to screenplane
		net.draw();
#ifdef USE_GUI
		ofSetColor(0xffffff);
		glScalef(1./100., -1./100., 1.);
		glTranslatef(0.0, 0.0, 3.);
		gui.draw();
#endif
	}
	glPopMatrix();

	ofSetupScreen();

	int w = ofGetWidth();
	int h = ofGetHeight();

	ofSetColor(0xeeeeee);
	font.drawString(ofToString(net.rate*512, 3)+string(" Hz"),	w-100,h-20);
}
Exemplo n.º 10
0
//--------------------------------------------------------------
void
testApp::post_draw_sndpeek()
{
  glDisable(GL_LINE_SMOOTH);
  glDisable(GL_FOG);
  glDisable(GL_DEPTH_TEST);

  ofSetupScreen();
}
Exemplo n.º 11
0
/* Call to render the next GL frame */
void
Java_cc_openframeworks_OFAndroid_render( JNIEnv*  env, jclass  thiz )
{
	int beginFrameMillis = ofGetElapsedTimeMillis();

	if(paused) return;
	//LOGI("update");
	ofNotifyUpdate();


	int width, height;

	width  = sWindowWidth;
	height = sWindowHeight;

	height = height > 0 ? height : 1;
	// set viewport, clear the screen
	//glViewport( 0, 0, width, height );
	ofViewport(0, 0, width, height, false);		// used to be glViewport( 0, 0, width, height );
	float * bgPtr = ofBgColorPtr();
	bool bClearAuto = ofbClearBg();

	if ( bClearAuto == true || nFrameCount < 3){
		ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255);
	}

	if(bSetupScreen) ofSetupScreen();
	ofNotifyDraw();

	/*timeNow = ofGetElapsedTimef();
	double diff = timeNow-timeThen;
	if( diff  > 0.00001 ){
		fps			= 1.0 / diff;
		frameRate	*= 0.9f;
		frameRate	+= 0.1f*fps;
	 }
	 lastFrameTime	= diff;
	 timeThen		= timeNow;*/
	// --------------

	int currTime = ofGetElapsedTimeMillis();
	if(currTime - onesec>=1000){
		frameRate = frames;
		frames = 0;
		onesec = currTime;
	}
	frames++;
	int frameMillis = currTime - beginFrameMillis;
	lastFrameTime = double(frameMillis)/1000.;

	previousFrameMillis = currTime;

	nFrameCount++;		// increase the overall frame count*/

	if(bFrameRateSet && frameMillis<oneFrameTime) ofSleepMillis(oneFrameTime-frameMillis);

}
Exemplo n.º 12
0
void testApp::setup() {
  ofEnableAlphaBlending();
  ofEnableSmoothing();
  ofSetupScreen();
  ofBackground(20);
  ofSetVerticalSync(true);
  position = 0;
  mesh = createGeoSphere(12, 12);
  setup_maximilian();
}
//--------------------------------------------------------------
void testApp::draw() {

	setupScreenForLesson();
	
	shader.setShaderActive(true);
	
	glPushMatrix();
	glTranslatef(0.0, 0.0, z);
    glRotatef(xRot,1.0,0.0,0.0);
	glRotatef(yRot,0.0,1.0,0.0);
	
	
	glBindBuffer(GL_ARRAY_BUFFER, vboId[0]);
	glVertexAttribPointer(locationID[VERTEX_POSITION_ATTRIBUTE], 3, GL_FLOAT, false, 0, 0);	
	glVertexAttribPointer(locationID[TEXTURE_COORD_ATTRIBUTE], 2, GL_FLOAT, false, 0, (void*)sizeof(cubeVertexPosition));
	glVertexAttribPointer(locationID[VERTEX_NORMAL_ATTRIBUTE], 3, GL_FLOAT, false, 0, (void*)(sizeof(cubeVertexPosition)+sizeof(cubeVertexTextureCoord)));
	glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vboId[1]);
	
	//SET TEXTURE
	glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, neheTexture.getTextureReference().getTextureData().textureID);
	shader.setUniformVariable1i((char*)"uSampler", 0);
	
	setMatrixUniforms();
	glDrawElements(GL_TRIANGLES, sizeof(cubeVertexIndices), GL_UNSIGNED_BYTE,0);
	glPopMatrix();	
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	shader.setShaderActive(false);
	
	glPushMatrix();
	glTranslatef(0.0, 0.0, z);
		glPushMatrix();
		glRotatef(xRotLight,1.0,0.0,0.0);
		glRotatef(yRotLight,0.0,1.0,0.0);
		glTranslatef(0.0, 0.0, 2.0);
		glGetFloatv (GL_MODELVIEW_MATRIX, mvMatrix);
		lightDirection.set(mvMatrix[12],mvMatrix[13],mvMatrix[14]-z);
		glColor3f(1.0,1.0,1.0);
		glutSolidSphere(0.05,4,4);
		glPopMatrix();
	glPopMatrix();
	
	
	
	
	ofSetupScreen();
	ofSetColor(0xFFFFFF);
	verdana.drawString(	"* Page Up/Page Down to zoom out/in\n* Cursor keys: make the cube rotate\n* SpaceBar+Cursor keys: make the light rotate\n* L Key toggle light", 5,15);
	verdana.drawString(	"* QWE Keys: R-> "+ofToString(ambient_red_value,2)+" G-> "+ofToString(ambient_green_value,2)+" B-> "+ofToString(ambient_blue_value,2)+" COLOR AMBIENT LIGHT", 5,73);
	verdana.drawString(	"* ASD Keys: R-> "+ofToString(direct_red_value,2)+" G-> "+ofToString(direct_green_value,2)+" B-> "+ofToString(direct_blue_value,2)+" DIRECTIONAL LIGHT COLOR", 5,87);


	
}
Exemplo n.º 14
0
//--------------------------------------------------------------
void testApp::setup(){
	/* some standard setup stuff*/
	
	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetVerticalSync(true);
	
	
	ofSoundStreamSetup(2,0,this, 44100, 512, 4);
}
Exemplo n.º 15
0
//--------------------------------------------------------------
void testApp::setup(){
	/* some standard setup stuff*/

	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetFrameRate(60);
	
	/* This is stuff you always need.*/
	
	sampleRate 			= 44100; /* Sampling Rate */
	initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
	lAudioOut			= new float[initialBufferSize];/* outputs */
	rAudioOut			= new float[initialBufferSize];
	lAudioIn			= new float[initialBufferSize];/* inputs */
	rAudioIn			= new float[initialBufferSize];
	
	
	/* This is a nice safe piece of code */
	memset(lAudioOut, 0, initialBufferSize * sizeof(float));
	memset(rAudioOut, 0, initialBufferSize * sizeof(float));
	
	memset(lAudioIn, 0, initialBufferSize * sizeof(float));
	memset(rAudioIn, 0, initialBufferSize * sizeof(float));
	
	/* Now you can put anything you would normally put in maximilian's 'setup' method in here. */
	
//	samp.load(ofToDataPath("sinetest_stepping2.wav"));
//		samp.load(ofToDataPath("whitenoise2.wav"));
//	samp.load(ofToDataPath("additive22.wav"));
	//samp.load(ofToDataPath("pinknoise2.wav"));
	samp.load(ofToDataPath("filtersweep2.wav"));
	samp.getLength();
	

	fftSize = 1024;
	mfft.setup(fftSize, 512, 256);
	ifft.setup(fftSize, 512, 256);
	
	
	
	nAverages = 12;
	oct.setup(sampleRate, fftSize/2, nAverages);
	
	mfccs = (double*) malloc(sizeof(double) * 13);
	mfcc.setup(512, 42, 13, 20, 20000, sampleRate);

	ofxMaxiSettings::setup(sampleRate, 2, initialBufferSize);
	ofSoundStreamSetup(2,2, this, sampleRate, initialBufferSize, 4);/* Call this last ! */
	
	ofSetVerticalSync(true);

}
Exemplo n.º 16
0
//------------------------------------------------------------
void ofxAppMacScreenSaver::display(void){
	
	//--------------------------------
	// when I had "glutFullScreen()"
	// in the initOpenGl, I was gettings a "heap" allocation error
	// when debugging via visual studio.  putting it here, changes that.
	// maybe it's voodoo, or I am getting rid of the problem
	// by removing something unrelated, but everything seems
	// to work if I put fullscreen on the first frame of display.
	
	///// MAREK HERE	
	// set viewport, clear the screen
	////ofViewport(0, 0, glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));		// used to be glViewport( 0, 0, width, height );
	float * bgPtr = ofBgColorPtr();
	bool bClearAuto = ofbClearBg();
	
    // to do non auto clear on PC for now - we do something like "single" buffering --
    // it's not that pretty but it work for the most part
	

	
	if ( bClearAuto == true || nFrameCount < 3){
		ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255);
	}
	
	if( bEnableSetupScreen )ofSetupScreen();
	
	ofNotifyDraw();
	ofAppPtr->draw();

	if (bClearAuto == false){
		// in accum mode resizing a window is BAD, so we clear on resize events.
		if (nFramesSinceWindowResized < 3){
			ofClear(bgPtr[0]*255,bgPtr[1]*255,bgPtr[2]*255, bgPtr[3]*255);
		}
	}
	
	//// MAREK HERE
	////glutSwapBuffers();

	
    nFramesSinceWindowResized++;
	
	//fps calculation moved to idle_cb as we were having fps speedups when heavy drawing was occuring
	//wasn't reflecting on the actual app fps which was in reality slower.
	//could be caused by some sort of deferred drawing?
	
	nFrameCount++;		// increase the overall frame count
	
	//setFrameNum(nFrameCount); // get this info to ofUtils for people to access
	
}
Exemplo n.º 17
0
//--------------------------------------------------------------
void ofApp::draw() {

    //--
    // 2d view

    drawViewportOutline(viewport2D);

    // keep a copy of your viewport and transform matrices for later
    ofPushView();

    // tell OpenGL to change your viewport. note that your transform matrices will now need setting up
    ofViewport(viewport2D);

    // setup transform matrices for normal oF-style usage, i.e.
    //  0,0=left,top
    //  ofGetViewportWidth(),ofGetViewportHeight()=right,bottom
    ofSetupScreen();

    ofFill();
    ofSetColor(220);
    for(int x = 0; x < 1000; x += 20) {
        for(int y = 0; y < 1000; y += 20) {
            ofCircle(x, y, sin((x + y) / 100.0f + ofGetElapsedTimef()) * 5.0f);
        }
    }

    // restore the old viewport (now full view and oF coords)
    ofPopView();
    //--


    //--
    // 3d view

    drawViewportOutline(viewport3D);

    // note the camera accepts the viewport as an argument
    // this is so that the camera can be aware of which viewport
    // it is acting on
    //
    // ofPushView() / ofPopView() are automatic
    camera.begin(viewport3D);
    ofDrawGrid(100);
    camera.end();
    //--


    ofDrawBitmapString("Press [space] to randomize viewports", 20, 20);
}
//--------------------------------------------------------------
void testApp::draw() {
    ofSetupScreen();
    pic.draw(0,0);
    if(drawPixelGrid) {
        for( int i = 0; i < 10; i++) {
            for( int j = 0; j < 10; j++) {
                ofSetColor( pixels.getColor(mouseX + i - 5, mouseY + j - 5 ), 200 );
                ofRect( mouseX + (i * 20 - 100), mouseY + (j * 20 - 100), 20, 20 );
            }
        }
    } else {
        ofSetColor(pixels.getColor(mouseX, mouseY), 200);
        ofCircle(mouseX, mouseY, 50);
    }
    ofSetColor(255, 255, 255);
}
Exemplo n.º 19
0
//--------------------------------------------------------------
void testApp::setup(){
    
    sender.setup(HOST, PORT);
    
    //Load font
    myfont.loadFont("Arial.ttf", 10);
    
    /* some standard setup stuff*/
    ofEnableAlphaBlending();
    ofSetupScreen();
    ofBackground(0, 0, 0);
    ofSetFrameRate(60);
    
    /* This is stuff you always need when you use Maximilian. Don't change it.*/
    sampleRate 			= 44100; /* Sampling Rate */
    initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
    lAudioOut			= new float[initialBufferSize];/* outputs */
    rAudioOut			= new float[initialBufferSize];
    lAudioIn			= new float[initialBufferSize];/* inputs */
    rAudioIn			= new float[initialBufferSize];
    
    
    /* This is a nice safe piece of code */
    memset(lAudioOut, 0, initialBufferSize * sizeof(float));
    memset(rAudioOut, 0, initialBufferSize * sizeof(float));
    memset(lAudioIn, 0, initialBufferSize * sizeof(float));
    memset(rAudioIn, 0, initialBufferSize * sizeof(float));
    
    /* Now you can put anything you would normally put in maximilian's 'setup' method in here. */
    
    mfft.setup(fftSize, 512, 256); //just a forward FFT
    oct.setup(sampleRate, fftSize/2, nAverages);
    mfccs = (double*) malloc(sizeof(double) * 13);
    
    //512 bins, 42 filters, 13 coeffs, min/max freq 20/20000
    mfcc.setup(512, 42, 13, 20, 20000, sampleRate);
    
    ofxMaxiSettings::setup(sampleRate, 2, initialBufferSize);
    ofSoundStreamSetup(2,2, this, sampleRate, initialBufferSize, 4);/* Call this last ! */
    
    
    
    ofSetVerticalSync(true);
}
Exemplo n.º 20
0
void GenericClientManager::setup() {

    this->minX=99999.0f;
    this->maxX=0.0f;
    this->minY=99999.0f;
    this->maxY=0.0f;

    this->pixels = new map<int,Pixel*>;
    this->pixelsFast = new vector<Pixel*>;
    this->models = new map<string, ofxAssimpModelLoader *>;

    this->sequenceNumber=0;

    this->loadFromXML();


    if(useServer) {
        this->tcpClient.setup(this->serverIP, this->serverTCPPort);
        this->configureFromServer();
        this->udpManager.Create();
        this->udpManager.Connect(this->serverIP.data(),this->UDPPort);
        this->udpManager.SetNonBlocking(true);
    }

    this->transmitEnabled = true;

    ofSetFrameRate(this->appFps);
    this->newFps=this->appFps;
    this->waitForReceiver=0;

    ofBackground(0, 0, 0);
    glEnable(GL_DEPTH_TEST);

    ofSetupScreen();

    myfont.loadFont("Arial.ttf", 12);

    this->showAxis=true;
    this->enableDraw=true;

    //here we call the specific setup
    this->specific = new SpecificBehaviour();
    specific->setup(this->pixels, this->pixelsFast);
}
Exemplo n.º 21
0
//--------------------------------------------------------------
void testApp::draw(){	
	
	int ssaoTexSlot = 6;
	ssaoFBO.beforeDraw(ssaoTexSlot);
	int depthTexSlot = 5;
	depthFBO.beforeDraw(depthTexSlot);
	dofShader.begin();
	dofShader.setUniform1i("bgl_RenderedTexture", ssaoTexSlot);
	dofShader.setUniform1i("bgl_DepthTexture", depthTexSlot);
	dofShader.setUniform1f("focus", focus);
	dofShader.setUniform1f("aspectratiox", aspectratiox);
	dofShader.setUniform1f("aspectratioy", aspectratioy);
	dofShader.setUniform1f("blurclamp", blurclamp);
	dofShader.setUniform1f("bias", bias);
	drawFullScreenQuad(ofGetWidth(), ofGetHeight());
	dofShader.end();	

	ofSetupScreen();
	gui.draw();	
}
Exemplo n.º 22
0
//--------------------------------------------------------------
void testApp::draw(){

//	cam.draw();
//	drawScene();
	
	int colorTexSlot = 4;
	colorFBO.beforeDraw(colorTexSlot);
	int depthTexSlot = 5;
	depthFBO.beforeDraw(depthTexSlot);
	dofShader.begin();
	dofShader.setUniform1i("bgl_RenderedTexture", colorTexSlot);
	dofShader.setUniform1i("bgl_DepthTexture", depthTexSlot);
	dofShader.setUniform1f("focus", focus);
	dofShader.setUniform1f("aspectratiox", aspectratiox);
	dofShader.setUniform1f("aspectratioy", aspectratioy);
	dofShader.setUniform1f("blurclamp", blurclamp);
	dofShader.setUniform1f("bias", bias);
	drawFullScreenQuad(ofGetWidth(), ofGetHeight());
	dofShader.end();
	
//	int colorTexSlot = 4;
//	colorFBO.beforeDraw(colorTexSlot);
//	defaultShader.begin();
//	defaultShader.setUniform1i("tex", colorTexSlot);
//	drawFullScreenQuad(ofGetWidth(), ofGetHeight());
//	defaultShader.end();
//	colorFBO.afterDraw();
	
//	int depthTexSlot = 5;
//	depthFBO.beforeDraw(depthTexSlot);
//	showDepthShader.begin();
//	showDepthShader.setUniform1i("depth", depthTexSlot);
//	drawFullScreenQuad(ofGetWidth(), ofGetHeight());
//	showDepthShader.end();
//	depthFBO.afterDraw();	
	
	
	ofSetupScreen();
	gui.draw();
	
}
Exemplo n.º 23
0
	void terminateApp(const std::string & module, const std::string & reason, float secondsOnScreen){
		
		ofLogFatalError("ofxApp") << "terminateApp()!";
		ofxSimpleHttp::destroySslContext();
		ofLogFatalError("ofxApp") << "";
		ofLogFatalError("ofxApp") << "-----------------------------------------------------------------------------------------------------------";
		ofLogFatalError("ofxApp") << "";
		ofLogFatalError("ofxApp") << "ofxApp is terminating because the module \"" << module << "\" found an unrecoverable error.";
		ofLogFatalError("ofxApp") << "\"" << reason << "\"";
		ofLogFatalError("ofxApp") << "This message will be on screen for " << (int)secondsOnScreen << " seconds, then the app will quit.";
		ofLogFatalError("ofxApp") << "";
		ofLogFatalError("ofxApp") << "-----------------------------------------------------------------------------------------------------------";
		ofLogFatalError("ofxApp") << "";
		ofxThreadSafeLog::one()->close();
		if(ofxApp::get().isWindowSetup()){
			ofxSuperLog::getLogger()->setScreenLoggingEnabled(true); //show log if json error
			ofxSuperLog::getLogger()->getDisplayLogger().setPanelWidth(1.0);
			int numFrames = secondsOnScreen * 1000 / 16; //stay up a bit so that you can read logs on screen
			
			OFXAPP_REPORT("ofxAppTerminate_" + module, reason, 2);
			
			//hijack OF and refresh screen & events by hand at ~60fps
			if(ofGetWindowPtr()){
				for(int i = 0; i < numFrames; i++ ){
					ofSetupScreen();
					ofClear(0,0,0,255);
					ofxSuperLog::getLogger()->getDisplayLogger().draw(ofGetWidth(), ofGetHeight());
					ofGetMainLoop()->pollEvents();
					if(ofGetWindowPtr()->getWindowShouldClose()){
						ofLogFatalError("ofxApp") << "Quitting by user action";
						std::exit(-1);
					}
					ofGetWindowPtr()->swapBuffers();
					ofSleepMillis(16);
				}
			}
		}else{
			ofLogFatalError("ofxApp") << "Terminating ofxApp before the app window is setup.";
		}
		std::exit(0);
	};
Exemplo n.º 24
0
//--------------------------------------------------------------
void mp::setup(){
	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetVerticalSync(true);
//	pyd.setup("localhost", 23612);
//	pyd.clear();
	
	
	maxiAtomBook::loadMPTKXmlBook(ofToDataPath("book100.xml"), book);
	sort(book.atoms.begin(), book.atoms.end(), maxiAtom::atomSortPositionAsc);
	atomBuffer.resize(512);
	atomData.resize(book.atoms[0]->length);

	ofxMaxiSettings::setup(44100, 2, 512);
	ofSoundStreamSetup(maxiSettings::channels,0,this, maxiSettings::sampleRate, maxiSettings::bufferSize, 4);/* Call this last ! */
	
//	flArr test;
//	maxiCollider::createGabor(test, maxiMap::linexp(atom->frequency, 0, 0.2, 20, 20000), 44100, atom->length, atom->phase, 0.3, atom->amp / 40.0);
	
}
Exemplo n.º 25
0
//--------------------------------------------------------------
void testApp::draw(){
	ofSetupScreen();
	
	ofSetColor(0x999999);
	
	//lets show our window pos in pixels
	//macs actually start the Y pos from 40
	vagRounded.drawString("window pos ("+ofToString(ofGetWindowPositionX())+", "+ofToString( ofGetWindowPositionY())+")", 10, 25);

	if(!bFullscreen){
		vagRounded.drawString("press f to enter fullscreen", -140 + ofGetWidth()/2, ofGetHeight()/2);	
		vagRounded.drawString("window is normal", -100 + ofGetWidth()/2, ofGetHeight() - 10);
	} else {
		vagRounded.drawString("press f to exit fullscreen", -150 + ofGetWidth()/2, ofGetHeight()/2); 
		vagRounded.drawString("window is fullscreen", -140 + ofGetWidth()/2, ofGetHeight() - 10); 
	}
	

	ofSetColor(0xFFFFFF);
	ofCircle(ballPositionX, ballPositionY, 15);
}
Exemplo n.º 26
0
//--------------------------------------------------------------
void App::draw(){
	
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glDisableClientState(GL_COLOR_ARRAY);
	ofEnableAlphaBlending();
	ofEnableSmoothing();	
	if (isVidBG) {
		bgPlayer->draw(ofGetScreenWidth()/2-bgPlayer->getWidth()/2, 
					   ofGetScreenHeight()/2-bgPlayer->getHeight()/2);
	}else {
		bg.draw(ofGetScreenWidth()/2-bg.getWidth()/2, 
				ofGetScreenHeight()/2-bg.getHeight()/2);		
	}
	
	ofPushMatrix();
	ofSetupScreen();
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);		
	ofEnableSmoothing(); 	
	ofEnableAlphaBlending();
	ofSetColor(255, 255, 255);
	qImage.draw();
	glDisable(GL_CULL_FACE);	
	ofEnableSmoothing(); 
	sText.drawWithNoScale(upInfo);	
	glEnable(GL_LIGHTING);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	ofPopMatrix();
	
	cam.place();
	//cam.draw();
	convexHull.draw();		

	adminPanel.draw();	
	ofSetColor(255, 255, 255);	

}
void ofxIndustrialRobotVisualizer::draw3d(int x, int y, int w, int h){	
	//	camera.orbitAround(ofxVec3f(ofGetWidth()/2.0,ofGetHeight()/2.0,0), ofxVec3f(0.0,1.0,0.0), rotationSpeed);
	light1.directionalLight(255, 255, 255, 0.0, 0.3, 1.0);
	glPushMatrix();
	glDisable(GL_DEPTH_TEST);
	glTranslated(x, y, 0);
	ofEnableAlphaBlending();
	ofFill();
	ofSetColor(255, 255, 255, 20);
	ofRect(0, 0, w, h);
	glPushMatrix();
	glViewport(x, ofGetHeight()-h-y, w, h);
	glEnable(GL_DEPTH_TEST);
	glTranslated(0, 1000, -2500);
	
	ofxLightsOn();
	ofFill();
	ofSetColor(0, 255, 0);	
	ofxSphere(ofGetWidth()/2.0, ofGetHeight()/2.0, 0, 500, 10, 500);
	ofSetColor(0, 255, 255);	
	glTranslated(ofGetWidth()/2.0, ofGetHeight()/2.0, 0);
	
	drawGeneric();
	
	glColor3f(255, 255, 255);	
	
	glViewport(0, 0, ofGetWidth(), ofGetHeight());
	ofSetupScreen();
	glDisable(GL_DEPTH_TEST);
	
	ofNoFill();
	ofSetColor(255, 255, 255,255);
	ofxLightsOff();
	glPopMatrix();
	ofRect(0, 0, w, h);
	ofDrawBitmapString("Robot Visualizer", x+10, y+15);
	glPopMatrix();
}
void pixelReader::draw() {
    ofSetupScreen();
    pic.draw(0,0);
	
	int mX = mouseX;
	int mY = mouseY;

	if(mX > pixels.getWidth()) mX = pixels.getWidth();
	if(mX > pixels.getHeight()) mX = pixels.getHeight();

	if(drawPixelGrid) {
		for( int i = 0; i < 10; i++) {
			for( int j = 0; j < 10; j++) {
				ofSetColor( pixels.getColor(mX + i - 5, mY + j - 5 ), 200 );
				ofRect( mX + (i * 20 - 100), mY + (j * 20 - 100), 20, 20 );
			}
		}
	} else {
		ofSetColor(pixels.getColor(mX, mY), 200);
		ofCircle(mX, mY, 50);
	}
	ofSetColor(255, 255, 255);
}
//--------------------------------------------------------------
void testApp::draw() {

	setupScreenForLesson();
	
	shader.setShaderActive(true);
	
	glTranslatef(0.0, 0.0, z);
    glRotatef(xRot,1.0,0.0,0.0);
	glRotatef(yRot,0.0,1.0,0.0);
	
	
	glBindBuffer(GL_ARRAY_BUFFER, vboId[0]);
	glVertexAttribPointer(locationID[VERTEX_POSITION_ATTRIBUTE], 3, GL_FLOAT, false, 0, 0);	
	glVertexAttribPointer(locationID[TEXTURE_COORD_ATTRIBUTE], 2, GL_FLOAT, false, 0, (void*)sizeof(cubeVertexPosition));
	glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, vboId[1]);
	
	//SET TEXTURE
	glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, neheTexture.getTextureReference().getTextureData().textureID);
	shader.setUniformVariable1i((char*)"uSampler", 0);
	
	
	setMatrixUniforms();
	glDrawElements(GL_TRIANGLES, sizeof(cubeVertexIndices), GL_UNSIGNED_BYTE,0);
	
	
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	shader.setShaderActive(false);
	
	ofSetupScreen();
	ofSetColor(0xFFFFFF);
	verdana.drawString("* Page Up/Page Down to zoom out/in\n* Cursor keys: make the cube rotate\n* F to toggle through three different\n  kinds of texture filters", 5,15);
		

	
}
Exemplo n.º 30
0
//--------------------------------------------------------------
void testApp::setup(){
	/* some standard setup stuff*/
	
	ofEnableAlphaBlending();
	ofSetupScreen();
	ofBackground(0, 0, 0);
	ofSetVerticalSync(true);
	
	/* This is stuff you always need.*/
	
	sampleRate 			= 44100; /* Sampling Rate */
	initialBufferSize	= 512;	/* Buffer Size. you have to fill this buffer with sound*/
	
	
	/* Now you can put anything you would normally put in maximilian's 'setup' method in here. */
	
	// from example project
//	beat.load(ofToDataPath("beat2.wav"));
//	beat.getLength();
    
//    //from Sequencing.cpp
//    b.amplitude=env[0];//starting value for envelope b
//	f.amplitude=env2[0];//same for f
//	beats.load(ofToDataPath("beat2.wav"));//put a path to a soundfile here. Wav format only.
//	//printf("Summary:\n%s", beats.getSummary());//get info on samples if you like
    
    //from DrumMachine.cpp
    kick.load(ofToDataPath("808kick.wav"));//load in your samples. Provide the full path to a wav file.
	snare.load(ofToDataPath("808snare.wav"));//load in your samples. Provide the full path to a wav file.
	//printf("Summary:\n%s", kick.getSummary());//get info on samples if you like.
	//beats.getLength();

	
	
	ofSoundStreamSetup(2,0,this, sampleRate, initialBufferSize, 4);/* Call this last ! */
}