//-------------------------------------------------------------- void ofApp::setup(){ width = 320; // try to grab at this size. height = 240; // oscThread //oscThread.setup(); //oscThread.start(); //AUDIO STUFF ofSoundStreamSetup(2, 0, 44100, BUF1_LEN, 4); ofSoundStreamStart(); //we can now get back a list of devices. vector<ofVideoDevice> devices = grabber.listDevices(); for(int i = 0; i < devices.size(); i++){ if(devices[i].bAvailable){ ofLogNotice() << devices[i].id << ": " << devices[i].deviceName; }else{ ofLogNotice() << devices[i].id << ": " << devices[i].deviceName << " - unavailable "; } } grabber.setDeviceID(0); grabber.setDesiredFrameRate(1); grabber.initGrabber(width, height); currPixels.allocate(width, height, OF_PIXELS_RGB); lastPixels.allocate(width, height, OF_PIXELS_RGB); texture.allocate(currPixels); ofSetVerticalSync(true); }
//-------------------------------------------------------------- void ofApp::setup(){ ofBackground(255, 255, 255); soundFreq =440; phase =0; ofSoundStreamSetup(2, 0, this, 44100, 1024, 4); ofSoundStreamStart(); }
//-------------------------------------------------------------- void ofApp::keyReleased(int key){ if (key==' ') bPlaying = !bPlaying; if (bPlaying) { ofSoundStreamStart(); } else { ofSoundStreamStop(); } if (key==356) { directionX = -speed; } else if (key==358) { directionX = speed; } }
//-------------------------------------------------------------- void testApp::setup(){ // OF shit theFont.loadFont(ofToDataPath("Times New Roman.ttf"), 32); ofBackground(0,0,0,255); ofSetVerticalSync(true); ofSetFrameRate(60); ofEnableAlphaBlending(); ofSetBackgroundAuto(false); // RTcmix audio stuff //sr = 44100; sr = 48000; nbufs = 2; // you can use more for more processing but latency will suffer nchans = 2; // stereo framesize = 512; // sigvs //s_audio_outbuf = (short*)malloc(nchans*framesize*sizeof(short)); // audio buffer (interleaved) s_audio_outbuf = new short[nchans*framesize]; // initialize RTcmix rtcmixmain(); maxmsp_rtsetparams(sr, nchans, framesize, NULL, NULL); // initialize OF audio streaming // ALERT: there is a piece of shit bug in this (related to jack, i think) // make sure to set your audio output in your audio/midi setup to 44100 24-bit. // anything else will cause the thing to reset to 96k 16bit // and all will go haywire and play an octave higher (or whatever) ofSoundStreamSetup(nchans, 0, sr, framesize, nbufs); ofSoundStreamStart(); // launch initial setup score RTcmixInit(); first_vec=1; // we haven't had audio yet // stash previous scaled mouse positions osx = 0.5; osy = 0.5; }
void CloudsMixer::setup(int nChannels, int sampleRate, int bufferSize, int nBuffers) { size_t size = nChannels*bufferSize*sizeof(float); musicArgs.buffer = (float*)malloc(size); musicArgs.bufferSize = bufferSize; musicArgs.nChannels = nChannels; diageticArgs.buffer = (float*)malloc(size); diageticArgs.bufferSize = bufferSize; diageticArgs.nChannels = nChannels; size = nChannels*44100*sizeof(float); // 1 second delay line delayLine.buffer = (float*)malloc(size); delayLine.bufferSize = 44100; delayLine.nChannels = nChannels; delptr = 0; // initialize OF audio streaming ofSoundStreamSetup(nChannels, 0, this, sampleRate, bufferSize, nBuffers); ofSoundStreamStart(); ofAddListener(GetCloudsAudioEvents()->fadeAudioDown, this, &CloudsMixer::fadeDown); ofAddListener(GetCloudsAudioEvents()->fadeAudioUp, this, &CloudsMixer::fadeUp); }