//-------------------------------------------------------------- void ofApp::update(){ ofSoundUpdate(); updateStars(); movie.update(); satellite.setRotation(1, 270 + (ofGetElapsedTimef()*10), 1, 0, 1); time += ofGetElapsedTimef() - time; bool audioPlaying = false; for (int i = 0; i < 3; i++) { if (audioTracks[i].getIsPlaying()) { audioPlaying = true; } } // when all the audio has been played, print stats to the console if (isReady && !audioPlaying && !printedStats) { printStats(); printedStats = true; } // checks to see if the prelude is over, if so start the main animation if (isPrelude && ((time-timer) > 15.0f)) { isPrelude = false; isReady = true; audioA.play(); audioB.play(); audioC.play(); } }
//-------------------------------------------------------------- void ofApp::update(){ ofSoundUpdate(); beat.setVolume(volume); beat.setSpeed(speed); visual01.update(); }
//-------------------------------------------------------------- void testApp::update(){ //flock flocker.applyForces(80, 0.4, 0.75); flocker.update(); //end flock ofSoundUpdate(); if( bDragging ){ return; } for( int i=0; i<springList.size(); i++ ){ springList[i].update(); } for( int i=0; i<jointList.size(); i++ ){ //jointList[i].update(); //xenos if (i==0) { jointList[i].xenoToPoint(mouseX,mouseY); }else { jointList[i].xenoToPoint(jointList[i-1].pos.x, jointList[i-1].pos.y); } } }
//-------------------------------------------------------------- void testApp::update() { // Nécessaire pour le moteur de sons d'Openframeworks ofSoundUpdate(); // Nécessaire pour la mise à jour du GPIO updateInputOutput(); // if (!listSounds[0].getIsPlaying()){ playSound(0); } // Exemple de lecture depuis une entrée // Puis écriture sur la sortir "/output0" int value = readInput(5); if (value>0) { soundVolumeTarget = 0.0f; soundVolume += (soundVolumeTarget-soundVolume)*0.2; } else { ofLogNotice() << "touch detected"; soundVolumeTarget = 1.0f; soundVolume += (soundVolumeTarget-soundVolume)*0.7; } listSounds[0].setVolume(soundVolume); }
//-------------------------------------------------------------- void testApp::update() { ofBackground(100, 100, 100); kinect.update(); grayImage.setFromPixels(kinect.getDepthPixels(), kinect.width, kinect.height); if( bThreshWithOpenCV ){ grayThreshFar = grayImage; grayThresh = grayImage; grayThreshFar.threshold(farThreshold, true); grayThresh.threshold(nearThreshold); cvAnd(grayThresh.getCvImage(), grayThreshFar.getCvImage(), grayImage.getCvImage(), NULL); } // if one blob found, find nearest point in blob area //update the cv image grayImage.flagImageChanged(); // find contours which are between the size of 20 pixels and 1/3 the w*h pixels. // also, find holes is set to true so we will get interior contours as well.... contourFinder.findContours(grayImage, 10, (kinect.width*kinect.height)/2, 200, false); ofSoundUpdate(); }
//-------------------------------------------------------------- void SoundManager::update(double dt) { ofSoundUpdate(); if(!m_currentSample) { return; } if(!m_currentSample->isPlaying()) { if (m_playExpert) { this->resetSamples(); AppManager::getInstance().getEventManager().setTimedEvent("END_ALL_SAMPLES", m_stateManager->m_t5); } else{ AppManager::getInstance().getVisualEffectsManager().removeAllVisualEffects(*m_sampleName); AppManager::getInstance().getViewManager().fadeVisual(*m_sampleName, 0, m_stateManager->m_t5); AppManager::getInstance().getEventManager().setTimedEvent("END_SAMPLE", m_stateManager->m_t5); m_currentSample = NULL; } } }
void SuperColliderLooper::update(){ float t = beat + (float) (ofGetElapsedTimef() - timeLast) / timeInterval; for (auto e : elements) { e->update(t); } ofSoundUpdate(); }
//-------------------------------------------------------------- void testApp::update(){ ofBackground(255,255,255); // update the sound playing system: ofSoundUpdate(); }
//-------------------------------------------------------------- void ofApp::update(){ ofBackground(80,80,20); // update the sound playing system: ofSoundUpdate(); // (1) we increase px and py by adding vx and vy px += vx; py += vy; // (2) check for collision, and trigger sounds: // horizontal collisions: if (px < 0){ px = 0; vx *= -1; dog.play(); } else if (px > ofGetWidth()){ px = ofGetWidth(); vx *= -1; ow.play(); } // vertical collisions: if (py < 0 ){ py = 0; vy *= -1; rooster.play(); } else if (py > ofGetHeight()){ py = ofGetHeight(); vy *= -1; beat.play(); } // (3) slow down velocity: vx *= 0.996f; vy *= 0.996f; // (4) we use velocity for volume of the samples: float vel = sqrt(vx*vx + vy*vy); ow.setVolume(MIN(vel/5.0f, 1)); beat.setVolume(MIN(vel/5.0f, 1)); dog.setVolume(MIN(vel/5.0f, 1)); rooster.setVolume(MIN(vel/5.0f, 1)); // (5) grab the fft, and put in into a "smoothed" array, // by taking maximums, as peaks and then smoothing downward float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft for (int i = 0;i < nBandsToGet; i++){ // let the smoothed value sink to zero: fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } }
//-------------------------------------------------------------- void ofApp::update(){ float time = ofGetElapsedTimef(); float x = time*0.1 + 30; for (int i=0;i<VOICES; i++) { float y = i * 0.02; float volume = ofNoise(x,y); voicePlayer[i].setVolume(volume); } ofSoundUpdate(); }
void CEQView::soundUpdate() { ofSoundUpdate(); float * val = ofSoundGetSpectrum(m_nBandsToGet); for (int i = 0; i<m_nBandsToGet; i++) { //let the smoothed value sink to zero m_fftSmoothed[i] *= 0.96f; //Creates an animated drop back to zero if (m_fftSmoothed[i] < val[i]) m_fftSmoothed[i] = val[i]; } }
void ofApp::updateSound(){ ofSoundUpdate(); float * val = ofSoundGetSpectrum(nBandsToGet); for (int i = 0;i < nBandsToGet; i++){ fftSmoothed[i] *= 0.96f; if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } }
//-------------------------------------------------------------- void testApp::update() { // Mise à jour des sons ofSoundUpdate(); int nRead = 0; // Mise à jour des vidéos for (int idx=0; idx<NBVIDS; idx++) { vids[idx].update(); } // Lecture Série ! memset(bytesReadString, 0, 12); int byte1; if (bSerialInited) { if (serial.available()>0) { byte1 = serial.readByte(); // printf("byte1 : %d\n", byte1); nRead = serial.readBytes(bytesReturned, 4); memcpy(bytesReadString, bytesReturned, nRead); // printf("suite : %s (int[0] = %d)\n", bytesReadString, bytesReadString[0]); if (byte1==88 && bytesReadString[0]!=0) { // accX accXLu = atoi(bytesReadString); accX *= 0.985; accX += 0.015 * float(accXLu); } if (byte1==89 && bytesReadString[0]!=0) { // accX accYLu = atoi(bytesReadString); accY *= 0.985; accY += 0.015 * float(accYLu); } } }; // Mise à jour accéléromètre if (accX >= 400.0 && accX <= 510.0) { if (!sounds[4].getIsPlaying()) { sounds[4].play(); } float speed = (accX - 400.0) / 110.0; float pan = (accX - 425.0) / 200.0; if (speed<-0.5) speed = -0.5; if (speed>0.5) speed = 0.5; if (pan<-1) pan = -1; if (pan>1) pan = 1; sounds[4].setSpeed( 0.5f + speed); sounds[4].setPan( 0.5f + pan); //printf("Play Cerf - speed : %.2f\n"); } else { //printf("Stop Cerf !!!\n"); if (sounds[4].getIsPlaying()) { sounds[4].stop(); } } }
//-------------------------------------------------------------- void testApp::update(){ ofSoundUpdate(); if(!chune.getIsPlaying()) { chune.play(); } // (5) grab the fft, and put in into a "smoothed" array, // by taking maximums, as peaks and then smoothing downward float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft for (int i = 0;i < nBandsToGet; i++){ // let the smoothed calue sink to zero: fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } for(int i = 0; i<3; i++) avgSound[i] = 0; // smooth fft and calc average volume for (int i = 0;i < nBandsToGet; i++){ fftSmoothed[i] *= 0.96f; if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; if(i < (nBandsToGet/3)) avgSound[0] += fftSmoothed[i]; if(i < (nBandsToGet/3)*2 && i > (nBandsToGet/2)) avgSound[1] += fftSmoothed[i]; if(i > (nBandsToGet/3)*2) avgSound[2] += fftSmoothed[i]; } // calculate average loudness of the music for "volume" avgSound[0] /= nBandsToGet; vidGrabber.update(); if (vidGrabber.isFrameNew()) { tex1=vidGrabber.getTextureReference(); } float centroidTop = 0; float centroidBottom = 0; for (int i = 0; i < nBandsToGet/2; i++) { centroidBottom += fftSmoothed[i]; centroidTop += (fftSmoothed[i]*i); } centroid = centroidTop/centroidBottom; centroid = centroid/(nBandsToGet/2); // cout << centroid; // cout << " --- "; }
//-------------------------------------------------------------- void ofApp::update(){ ofSoundUpdate(); if(arraySounds[currentSoundIndex].getPosition() >= 0.95){ arraySounds[currentSoundIndex].stop(); arraySounds[currentSoundIndex].setPosition(0.0f); currentSoundIndex++; if(currentSoundIndex >= numberOfSounds){ currentSoundIndex = 0; } arraySounds[currentSoundIndex].play(); } }
//-------------------------------------------------------------- void testApp::update(){ ofSoundUpdate(); float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft for (int i = 0;i < nBandsToGet; i++){ // let the smoothed calue sink to zero: fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } movie.update(); if(movie.isFrameNew()){ if(drawRuttEtra){ vidPixels = movie.getPixelsRef(); } } float p = movie.getPosition(); //printf("%f\n",p); // Broadcast current position information of movie if ((!started || count % howOften == 0)) { ofxOscMessage m; m.setAddress( "/movie/position" ); m.addFloatArg(p); m.addFloatArg(yStep); m.addFloatArg(xStep); m.addIntArg(drawRuttEtra); sender1.sendMessage(m); sender2.sendMessage(m); started = true; } count++; }
//-------------------------------------------------------------- void audioPlayer::update(int newRectX, int newRectY, string newLargeAudioDir){ largeAudioDir = newLargeAudioDir; if (largeAudioDir != largeAudioDirTest) { large.unloadSound(); large.loadSound(largeAudioDir); largeAudioDirTest = largeAudioDir; } //ofxSimpleSlider-----------------_ float pctPos = 0;//sliderPosition.getValue(); float pctSpeed = 1;//sliderSpeed.getValue(); float pctVolume = 0.75;//sliderVolume.getValue(); largeAudioPosition = pctPos; largeAudioSpeed = pctSpeed; largeAudioVolume = pctVolume; //----------ofxSimpleSlider-------_ getLargePositionMS = large.getPositionMS(); getLargePosition = large.getPosition();// just to have a 0-1 Position getLargeSpeed = large.getSpeed(); getLargeVolume = large.getVolume(); if (isPlay == true) { large.play(); //large.setPositionMS(largeAudioPosition); large.setPosition(largeAudioPosition); large.setSpeed(largeAudioSpeed); large.setVolume(largeAudioVolume); isPlay = false; } if (large.getIsPlaying()) { playColor.set(255, 0, 255, 255); }else { playColor.set(100, 100, 255, 255); } if (isPaused == true) { large.setPaused(true); pausedColor.set(255, 0, 255, 255); isPlay = false; }else { pausedColor.set(100, 100, 255, 255); large.setPaused(false); } // update the sound playing system: ofSoundUpdate(); }
//-------------------------------------------------------------- void ofApp::update(){ //Update sound engine ofSoundUpdate(); //Get current spectrum with N bands float *val = ofSoundGetSpectrum( N ); //We should not release memory of val, //because it is managed by sound engine //Update our smoothed spectrum, //by slowly decreasing its values and getting maximum with val //So we will have slowly falling peaks in spectrum for ( int i=0; i<N; i++ ) { spectrum[i] *= 0.97; //Slow decreasing spectrum[i] = max( spectrum[i], val[i] ); } //Update particles using spectrum values //Computing dt as a time between the last //and the current calling of update() float time = ofGetElapsedTimef(); float dt = time - time0; dt = ofClamp( dt, 0.0, 0.1 ); time0 = time; //Store the current time //Update Rad and Vel from spectrum //Note, the parameters in ofMap's were tuned for best result //just for current music track Rad = ofMap( spectrum[ bandRad ], 1, 3, 400, 800, true ); Vel = ofMap( spectrum[ bandVel ], 0, 0.1, 0.05, 0.5 ); //Update particles positions for (int j=0; j<n; j++) { tx[j] += Vel * dt; //move offset ty[j] += Vel * dt; //move offset //Calculate Perlin's noise in [-1, 1] and //multiply on Rad p[j].x = ofSignedNoise( tx[j] ) * Rad; p[j].y = ofSignedNoise( ty[j] ) * Rad; } if (bg_transparent > 0){ bg_transparent = 255 - time * 3.5; } else{ bg_transparent = 0; } }
//-------------------------------------------------------------- void testApp::update(){ howareyou.update(); menuNOSTALGIC.update(); menuINTROSPECTIVE.update(); menuLOST.update(); menuDETERMINED.update(); fadeOutVid.update(); updateVideos(); playSong(songMood); ofSoundUpdate(); if (fadeOutVid.getIsMovieDone()) { fadeOutVid.closeMovie(); switch (moodSelected) { case 1 : nostalgic[randomNostalgic].play(); nostalgic[randomNostalgic].setLoopState(OF_LOOP_NONE); break; case 2 : introspective[randomIntrospective].play(); introspective[randomIntrospective].setLoopState(OF_LOOP_NONE); break; case 3 : lost[randomLost].play(); lost[randomLost].setLoopState(OF_LOOP_NONE); break; case 4 : determined[randomDetermined].play(); determined[randomDetermined].setLoopState(OF_LOOP_NONE); break; } } }
//-------------------------------------------------------------- void ofApp::update(){ //Update sound engine ofSoundUpdate(); //Get current spectrum with N bands float *val = ofSoundGetSpectrum( N ); //We should not release memory of val, //because it is managed by sound engine //Update our smoothed spectrum, //by slowly decreasing its values and getting maximum with val //So we will have slowly falling peaks in spectrum for ( int i=0; i<N; i++ ) { spectrum[i] *= 0.97; //Slow decreasing spectrum[i] = max( spectrum[i], val[i] ); } }
void testApp::update() { context.update(); user.update(); ofSoundUpdate(); // find the hands via openni for (int i = 0; i < user.getTrackedUsers().size(); i++) { ofxTrackedUser* tracked = user.getTrackedUser(i); if (tracked != NULL && tracked->left_lower_arm.found && tracked->right_lower_arm.found) { // star the music if(!valkyries.getIsPlaying()) { valkyries.play(); } //cout << "Tracked hands of user: "******"flapPower"); flappers[i].gravity = panel.getValueF("gravity"); flappers[i].update(); } }
//-------------------------------------------------------------- void ofApp::update(){ kinect.update(); ofSoundUpdate(); if (kinect.isFrameNewDepth()){ // auto-set crop/warp of kinect image to projection size if not done yet if (!bWarped && ofGetElapsedTimef() > 10){ autoSetKinectWarp(); } // quad-warp new kinect frame to match projection warpKinect(); } // update each layer with depth image for thresholding for (int l=0; l<layers.size(); l++){ layers[l].update(kinectWarp); } playSoundbites(); // plays mixed audio tracks according to time and rate of layer visibility // calibrate depth mode - sets thresholds based on GUI if (mode == CALIBRATEDEPTH){ layers[0].setThresholds(topSlider, thresh0Slider); layers[1].setThresholds(thresh0Slider, thresh1Slider); layers[2].setThresholds(thresh1Slider, thresh2Slider); layers[3].setThresholds(thresh2Slider, bottomSlider); } // kinect image registration/warping mode if (mode == AUTOKINECT){ autoSetKinectWarp(); } }
//-------------------------------------------------------------- void testApp::update() { step += 0.0001; if (step > 1) { step -= 1; } ofSoundUpdate(); float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft for (int i = 0;i < nBandsToGet; i++){ // let the smoothed value sink to zero: fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } }
//-------------------------------------------------------------- void testApp::update(){ ofSoundUpdate(); string str = ""; str += ofToString(sp.getPositionMS()) + ", " + ofToString(ofGetFrameNum()) + ", "; float* val = ofSoundGetSpectrum(nBandsToGet); for (int i = 0;i < nBandsToGet; i++){ fftSmoothed[i] *= 0.96f; if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; str += ofToString(val[i]) + ((i == nBandsToGet - 1) ? "\n" : ", "); } file.open(ofToDataPath("soundData.text"), ofFile::Append); ofBuffer buff; buff = str; file.writeFromBuffer(buff); file.close(); }
void Ball::update(){ //Sound ------- ofSoundUpdate(); float * value = ofSoundGetSpectrum(bands); for (int i = 0; i < bands; i++){ fftSmooth[i] *= 0.9f; //controls how fast dies down if (fftSmooth[i] < value[i]) { fftSmooth[i] = value[i]; } } //Movement------ sine = sin(ofGetElapsedTimef() * speed+5) * sinPar; cosine = cos(ofGetElapsedTimef() * speed+5) * cosPar; sine2 = sin(ofGetElapsedTimef() * speed) * sinPar2; cosine2 = cos(ofGetElapsedTimef() * speed) * cosPar2; }
//-------------------------------------------------------------- void testApp::update(){ updateArduino(); ofSoundUpdate(); int currentTime = ofGetElapsedTimef(); if (currentTime > (timeElasped+cycleTime)) { // slow down the random number generator to prevent audio glitching randomGurgle = ofRandom(0,NUM_GURGLE); randomSound = ofRandom(0,NUM_BREATHE); timeElasped = currentTime; cout << "Random Sound# " << randomSound << " Random Gurgle #" << randomGurgle << endl; } // slow down the update of the random gurgle inhaleExhaleSound[randomSound].setSpeed(breathespeed); inhaleExhaleSound[randomSound].setMultiPlay(false); inhaleExhaleSound[randomSound].play(); }
//-------------------------------------------------------------- void ofApp::update(){ // update the sound playing system: ofSoundUpdate(); // (5) grab the fft, and put in into a "smoothed" array, // by taking maximums, as peaks and then smoothing downward float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft for (int i = 0;i < nBandsToGet; i++){ // let the smoothed calue sink to zero fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } // ws.play(); serialTest = serial.available(); if (serialTest) { cout << "blahh" << endl; } //@add 2015/10/20 ######################################## serialString = ""; serialString = ofxGetSerialString(serial,'\n'); //read until end of line if (serialString.length() > 0) { readTime = ofGetElapsedTimef(); ofLogVerbose() << "serialString = " << serialString << "\n"; } }
//-------------------------------------------------------------- void AudioPlayer::update(){ // update the sound playing system: ofSoundUpdate(); // (5) grab the fft, and put in into a "smoothed" array, // by taking maximums, as peaks and then smoothing downward float * val = ofSoundGetSpectrum(nBandsToGet); // request 128 values for fft for (int i = 0;i < nBandsToGet; i++){ // let the smoothed calue sink to zero: fftSmoothed[i] *= 0.96f; // take the max, either the smoothed or the incoming: if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i]; } updateColor(BG_R_, BG_G_, BG_B_); float BG_R = BG_R_; float BG_G = BG_G_; float BG_B = BG_B_; amplifyColor(BG_R, BG_G, BG_B); ofBackground(BG_R,BG_G,BG_B); }
//-------------------------------------------------------------- void ofApp::update(){ if (0<time && time <=50) { soundFreq =220; } if (50<time && time <=100) { soundFreq =440; } if (100<time && time <=150) { soundFreq =880; } if (150<time && time <=200) { soundFreq =440; } if (200<time && time <=250) { soundFreq =220; } if (250<time && time <=300) { soundFreq =220; } if (300<time && time <=350) { soundFreq =440; } if (350<time && time <=400) { soundFreq =880; } if (400<time && time <=450) { soundFreq =440; } if (450<time && time <=500) { soundFreq =220; } ofSoundUpdate(); time++; }
//-------------------------------------------------------------- void testApp::update(){ ofSoundUpdate(); }