Example #1
0
void redEyeApp::setup() {
    
    //-settings
    mListener.setup(43334);  //osc input port
    
    //--defaults
    mHide= false;       //also keydown 'i'
    mError= "";
    mOsc= "";
    mMode= 5;
    mAmplitude= 0.0f;
    mNumSamples= 512;
    mDownSample= 0;
    mWidth= 1.0f;
    mColorBack= ColorA(0.0f, 0.0f, 0.0f, 1.0f);
    
    //mVisible0= mVisible1= true;
    mScale0= mScale1= Vec3f(1.0f, 1.0f, 1.0f);
    mTranslate0= mTranslate1= Vec3f::zero();
    mColor0= ColorA(1.0f, 0.0f, 0.0f, 1.0f);
    mColor1= ColorA(0.0f, 1.0f, 0.0f, 1.0f);
    
    //--audio
    mInput= audio::Input();     //use default input device
    mInput.start();             //start capturing
    
    //--shaders
    mPathFrag= getPathDirectory(app::getAppPath().string())+"data/_default_frag.glsl";
    mPathVert= getPathDirectory(app::getAppPath().string())+"data/_default_vert.glsl";
    //loadShader();
    
    //--parameter window
    mParams= params::InterfaceGl::create(getWindow(), "redEye", toPixels(Vec2i(200, 400)));
    //mParams->addText("text", ("label=`redEye`"));
    mParams->addParam("NumSamples", &mNumSamples, "min=1 max=2048 step=1");
    mParams->addParam("DownSample", &mDownSample, "min=0 max=2047 step=1");
    mParams->addParam("Width", &mWidth, "min=0 max=1000 step=1");
    mParams->addParam("Back color", &mColorBack, "");
    mParams->addSeparator();
    //mParams->addParam("Visible", &mVisible0);
    mParams->addParam("Scale", &mScale0);
    mParams->addParam("Rotate", &mRotate0);
    mParams->addParam("Translate", &mTranslate0);
    mParams->addParam("Color", &mColor0, "");
    /*mParams->addSeparator();
    mParams->addParam("Visible1", &mVisible1);
    mParams->addParam("Scale1", &mScale1);
    mParams->addParam("Rotate1", &mRotate1);
    mParams->addParam("Translate1", &mTranslate1);
    mParams->addParam("Color1", &mColor1, "");*/
    
    //mParams->addParam("Cube Size", &mObjSize, "min=0.1 max=20.5 step=0.5 keyIncr=z keyDecr=Z");
    mParams->addSeparator();
    mParams->addParam("String00", &mNameFrag, "label=`frag (f):`");
    mParams->addParam("String01", &mNameVert, "label=`vert (v):`");
    mParams->addParam("String02", &mError, "label=`error:`");
    mParams->addParam("String03", &mOsc, "label=`osc:`");
    mParams->addParam("String04", &mMode, "label=`mode (m):`");
    mParams->addParam("String05", &mFps, "label=`fps:`");
}
Example #2
0
void svvimApp::getAlpha () {
  
  // Sound buffer for FFT
  mPcmBuffer = mInput.getPcmBuffer();
  
  //
  if (mPcmBuffer) {
    mFftDataRef = audio::calculateFft(mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_LEFT ), 512);
  }
  
	uint16_t bandCount = 64;
	
	if( ! mPcmBuffer )
    return;
	
	//use the most recent Pcm data to calculate t`he Fft
	std::shared_ptr <float> fftRef = audio::calculateFft( mPcmBuffer->getChannelData( audio::CHANNEL_FRONT_LEFT ), bandCount );
  
	if( ! fftRef ) {
		return;
	}
	
	float * fftBuffer = fftRef.get();
	 
  //mAlpha = max(2, mAlpha);
	//draw the bands
	for( int i = 0; i < ( bandCount/32 ); i++ ) {
		 mAlpha += fftBuffer[i] / bandCount / 4;
	}
  
  mAlpha /= 6.5;
}
void TouchAudioTestApp::update()
{
	mPcmBuffer = mInput.getPcmBuffer();
	if( ! mPcmBuffer ) {
		return;
	}
}
void TouchAudioTestApp::setup()
{
	//mAudioSource = audio::load( loadResource( RES_BOOYAH ) );
	//initialize the audio Input, using the default input device
	mInput = audio::Input();
	
	//tell the input to start capturing audio
	mInput.start();
	
}
void shader02vertexApp::setup() {
    
    //--defaults
    mHide= false;       //also keydown 'i'
    mError= "";
    mMode= 0;
    mAmplitude= 0.0f;
    mMouse= Vec2f(0.0f, 0.0f);
    
    //--audio
    mInput= audio::Input();     //use default input device
    mInput.start();             //start capturing
    
    //--shader
    mPathFrag= getPathDirectory(app::getAppPath().string())+"data/_default_frag.glsl";
    mPathVert= getPathDirectory(app::getAppPath().string())+"data/_default_vert.glsl";
    loadShader();
}
void shader02vertexApp::update() {
    
    //--audio input
    mPcmBuffer= mInput.getPcmBuffer();
    if(mPcmBuffer) {
        mBufferSize= mPcmBuffer->getSampleCount();
        //std::cout<<"mBufferSize: "<<mBufferSize<<std::endl;
        mBufferLeft= mPcmBuffer->getChannelData(audio::CHANNEL_FRONT_LEFT);
        mFftLeft= audio::calculateFft(mPcmBuffer->getChannelData(audio::CHANNEL_FRONT_LEFT), mBufferSize/2);
        mAmplitude= 0.0f;
        for(uint32_t i= 0; i<mBufferSize; i++) {
            mAmplitude += abs(mBufferLeft->mData[i]);
        }
        mAmplitude /= float(mBufferSize);   //average amplitude
        
        Surface32f mSurfaceSnd(mBufferSize, 1, true);
        Surface32f::Iter sndIter(mSurfaceSnd.getIter());
        uint32_t i= 0;
        while(sndIter.line()) {
            while(sndIter.pixel()) {
                sndIter.r()= mBufferLeft->mData[i];
                i++;
            }
        }
        mTextureSnd= gl::Texture(mSurfaceSnd);
        
        Surface32f mSurfaceFft(mBufferSize/2, 1, true);
        Surface32f::Iter fftIter(mSurfaceFft.getIter());
        uint32_t j= 0;
        float *fftBuffer= mFftLeft.get();
        while(fftIter.line()) {
            while(fftIter.pixel()) {
                fftIter.r()= fftBuffer[j];
                j++;
            }
        }
        mTextureFft= gl::Texture(mSurfaceFft);
    }
    
    //--shaders
    if((fs::last_write_time(mPathFrag)>mTimeFrag) || (fs::last_write_time(mPathVert)>mTimeVert)) {
        loadShader();   //hot-loading shader
    }
}
Example #7
0
void svvimApp::setup() {
  mLastElapsedSecondsSwitch = 0;
  mPerlinGenerator = Perlin();
  
  mBgTextureList = new gl::Texture [3];
  
  
  
  mPoolWaterMovie = qtime::MovieGl(getResourcePath("water-over.m4v"));
  mPoolWaterMovie.setLoop();
  mPoolWaterMovie.play();
  
  mMovieList = new qtime::MovieGl [13];
  
  mMovieList[ 0] = qtime::MovieGl(getResourcePath("SVVIM4_VIS_04.mov"));
  mMovieList[ 1] = qtime::MovieGl(getResourcePath("SVVIM4_VIS_08.mov"));
  mMovieList[ 2] = qtime::MovieGl(getResourcePath("SVVIM4_VIS_10.mov"));
  mMovieList[ 3] = qtime::MovieGl(getResourcePath("SVVIM4_VIS_11.mov"));
  mMovieList[ 4] = qtime::MovieGl(getResourcePath("SVVIM4_VIS_07.mov"));
  mMovieList[ 5] = qtime::MovieGl(getResourcePath("movie-006.mov"));
  mMovieList[ 6] = qtime::MovieGl(getResourcePath("movie-002.mov"));
  mMovieList[ 7] = qtime::MovieGl(getResourcePath("movie-008.mov"));
  mMovieList[ 8] = qtime::MovieGl(getResourcePath("movie-009.mov"));
  mMovieList[ 9] = qtime::MovieGl(getResourcePath("movie-010.mov"));
  mMovieList[10] = qtime::MovieGl(getResourcePath("movie-011.mov"));
  mMovieList[11] = qtime::MovieGl(getResourcePath("movie-012.mov"));
  mMovieList[12] = qtime::MovieGl(getResourcePath("movie-013.mov"));
  
  // Load Svvim Logo from PNG
  
  app::console() << "setup\n";
  
  // Compile shader
  try {
    mShader = gl::GlslProg(loadResource(RES_VERT_GLSL), loadResource(RES_FRAG_GLSL));
  }
  catch (const std::exception & e) {
    mShader = gl::GlslProg();
    console() << "Compile error in shader: " << e.what() << "\n";
  }
  
  // Begin reading MIC
  mInput = audio::Input();
  mInput.start();
  
  //
  mMovieIndex = 4;
  
  mCurrentMovie = mMovieList[mMovieIndex];
  
  mCurrentMovie.play();
  mCurrentMovie.setVolume(0.);
  
  gl::Texture::Format format;
  format.setTargetRect();
  
  mImageTexture = gl::Texture(loadImage(loadResource("saturday-night.jpg")), format);
  mSvvimLogoPng = gl::Texture(loadImage(loadResource(RES_SVVIM_LOGO_PNG)), format);
  mCurrentBgTexture = gl::Texture(loadImage(loadResource("bgMarble.png")), format);
  
  mCurrentMovie.seekToTime(82.);
  
  gl::enableAlphaBlending();
}
Example #8
0
void redEyeApp::update() {
    
    //--osc input
    while(mListener.hasWaitingMessages()) {
		osc::Message msg;
		mListener.getNextMessage(&msg);
        mOsc= msg.getAddress();
        for(uint32_t i= 0; i<msg.getNumArgs(); i++) {
            mOsc= mOsc+" "+msg.getArgAsString(i, true);
        }
        if(msg.getAddress()=="/numSamples") {
            mNumSamples= math<int32_t>::clamp(msg.getArgAsInt32(0, true), 1, 2048);
        } else if(msg.getAddress()=="/downSample") {
            mDownSample= math<int32_t>::clamp(msg.getArgAsInt32(0, true), 0, 2047);
        } else if(msg.getAddress()=="/amplitude") {
            mAmplitude= msg.getArgAsFloat(0, true);
        } else if(msg.getAddress()=="/width") {
            mWidth= math<float>::clamp(msg.getArgAsFloat(0, true), 0, 1000);
        } else if(msg.getAddress()=="/colorBack") {
            ColorA col= ColorA(0, 0, 0, 1);
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 4); i++) {
                col[i]= msg.getArgAsFloat(i, true);
            }
            mColorBack.set(col.r, col.g, col.b, col.a);
        
        } else if(msg.getAddress()=="/scale0") {
            Vec3f sca= Vec3f(1.0f, 1.0f, 1.0f);
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 3); i++) {
                msg.getArgAsFloat(i, true);
            }
            mScale0.set(sca.x, sca.y, sca.z);
        } else if(msg.getAddress()=="/scale1") {
            Vec3f sca= Vec3f(1.0f, 1.0f, 1.0f);
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 3); i++) {
                msg.getArgAsFloat(i, true);
            }
            mScale1.set(sca.x, sca.y, sca.z);
        } else if(msg.getAddress()=="/rotate0") {
            Vec3f rot= Vec3f::zero();
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 3); i++) {
                rot[i]= msg.getArgAsFloat(i, true);
            }
            mRotate0.set(rot.x, rot.y, rot.z);
        } else if(msg.getAddress()=="/rotate1") {
            Vec3f rot= Vec3f::zero();
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 3); i++) {
                rot[i]= msg.getArgAsFloat(i, true);
            }
            mRotate1.set(rot.x, rot.y, rot.z);
        } else if(msg.getAddress()=="/translate0") {
            Vec3f tra= Vec3f::zero();
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 3); i++) {
                tra[i]= msg.getArgAsFloat(i, true);
            }
            mTranslate0.set(tra.x, tra.y, tra.z);
        } else if(msg.getAddress()=="/translate1") {
            Vec3f tra= Vec3f::zero();
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 3); i++) {
                tra[i]= msg.getArgAsFloat(i, true);
            }
            mTranslate1.set(tra.x, tra.y, tra.z);
        } else if(msg.getAddress()=="/color0") {
            ColorA col= ColorA(0, 0, 0, 1);
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 4); i++) {
                col[i]= msg.getArgAsFloat(i, true);
            }
            mColor0.set(col.r, col.g, col.b, col.a);
        } else if(msg.getAddress()=="/color1") {
            ColorA col= ColorA(0, 0, 0, 1);
            for(uint32_t i= 0; i<min(msg.getNumArgs(), 4); i++) {
                col[i]= msg.getArgAsFloat(i, true);
            }
            mColor1.set(col.r, col.g, col.b, col.a);
        }
	}
    
    //--audio input
    mPcmBuffer= mInput.getPcmBuffer();
    if(mPcmBuffer) {
        mBufferSize= mPcmBuffer->getSampleCount();
        //std::cout<<"mBufferSize: "<<mBufferSize<<std::endl;
        mBufferLeft= mPcmBuffer->getChannelData(audio::CHANNEL_FRONT_LEFT);
        //mBufferRight= mPcmBuffer->getChannelData(audio::CHANNEL_FRONT_RIGHT);
        mFftLeft= audio::calculateFft(mPcmBuffer->getChannelData(audio::CHANNEL_FRONT_LEFT), mBufferSize/2);
        //mFftRight= audio::calculateFft(mPcmBuffer->getChannelData(audio::CHANNEL_FRONT_LEFT), mBufferSize/2);
        mAmplitude= 0.0f;
        for(uint32_t i= 0; i<mBufferSize; i++) {
            mAmplitude += abs(mBufferLeft->mData[i]);
        }
        mAmplitude /= float(mBufferSize);   //average amplitude
        
        Surface32f mSurfaceSnd(mBufferSize, 1, true);
        Surface32f::Iter sndIter(mSurfaceSnd.getIter());
        uint32_t i= 0;
        while(sndIter.line()) {
            while(sndIter.pixel()) {
                sndIter.r()= mBufferLeft->mData[i];
                i++;
            }
        }
        mTextureSnd= gl::Texture(mSurfaceSnd);
        
        Surface32f mSurfaceFft(mBufferSize/2, 1, true);
        Surface32f::Iter fftIter(mSurfaceFft.getIter());
        uint32_t j= 0;
        float *fftBuffer= mFftLeft.get();
        while(fftIter.line()) {
            while(fftIter.pixel()) {
                fftIter.r()= fftBuffer[j];
                j++;
            }
        }
        mTextureFft= gl::Texture(mSurfaceFft);
    }
    
    //--shaders
    if(mShader!=NULL) {
        if((fs::last_write_time(mPathFrag)>mTimeFrag) || (fs::last_write_time(mPathVert)>mTimeVert)) {
            loadShader();   //hot-loading shader
        }
    }
    
    mFps= getAverageFps();
}