void ofApp::audioOut(ofSoundBuffer &buffer){ for (unsigned i = 0; i<bufferSize; i++){ currentSample = osc.sinewave(freq + env.adsr(mod.sinewave(modFreq), env.trigger) * modIndex); mix.stereo(currentSample, outputs, 0.5); buffer[i*buffer.getNumChannels()] = outputs[0]; buffer[i*buffer.getNumChannels()+1] = outputs[1]; } }
void ofApp::audioOut(ofSoundBuffer &buffer){ for (unsigned i = 0; i < bufferSize; i++){ currentSample = osc.saw(frequency) * modulator.sinewave(modSpeed); // currentSample = osc.saw(frequency) * modulator.square(modSpeed); mix.stereo(currentSample, outputs, 0.5); buffer[i*buffer.getNumChannels()] = outputs[0]; buffer[i*buffer.getNumChannels() + 1] = outputs[1]; } }
//-------------------------------------------------------------- void ofApp::audioOut(ofSoundBuffer & buffer){ if(spectrum->playing){ // float *ptr = output; for (int i = 0; i < buffer.getNumFrames(); i++){ wave = 0.0; for(int n=0; n<BIT; n++){ if (amp[n]>0.00001) { phases[n] += 512./(44100.0/(hertzScale[n])); if ( phases[n] >= 511 ) phases[n] -=512; if ( phases[n] < 0 ) phases[n] = 0; //remainder = phases[n] - floor(phases[n]); //wave+=(float) ((1-remainder) * sineBuffer[1+ (long) phases[n]] + remainder * sineBuffer[2+(long) phases[n]])*amp[n]; wave += ( sineBuffer[1 + (long) phases[n]] ) * amp[n]; } } wave/=10.0; if(wave>1.0) wave=1.0; if(wave<-1.0) wave=-1.0; buffer[i * buffer.getNumChannels() ] = wave * volume; buffer[i * buffer.getNumChannels() + 1] = wave * volume; // outp[i] = wave; // *ptr++ = wave * volume; } } else { // for (int i = 0; i < bufferSize; i++){ // output[i*nChannels ] = 0; // output[i*nChannels + 1] = 0; // outp[i] = 0; // } } }
void ofxBasicSoundPlayer::audioOut(ofSoundBuffer& outputBuffer){ if(bIsPlaying){ int nFrames = outputBuffer.getNumFrames(); int nChannels = outputBuffer.getNumChannels(); if (playerNumChannels != nChannels || playerNumFrames != nFrames || playerSampleRate != outputBuffer.getSampleRate()) { audioOutBuffersChanged(nFrames, nChannels, outputBuffer.getSampleRate()); } if(streaming){ int samplesRead = soundFile.readTo(buffer,nFrames); if ( samplesRead==0 ){ bIsPlaying=false; soundFile.seekTo(0); } else{ buffer.stereoPan(volumesLeft.back(),volumesRight.back()); newBufferE.notify(this,buffer); buffer.copyTo(outputBuffer); } }else{ if (positions.size() == 1 && abs(speed - 1)<FLT_EPSILON) { buffer.copyTo(outputBuffer,nFrames,nChannels,positions[0],loop); }else{ for(int i=0;i<(int)positions.size();i++){ //assert( resampledBuffer.getNumFrames() == bufferSize*relativeSpeed[i] ); if(abs(relativeSpeed[i] - 1)<FLT_EPSILON){ buffer.copyTo(resampledBuffer,nFrames,nChannels,positions[i],loop); }else{ buffer.resampleTo(resampledBuffer,positions[i],nFrames,relativeSpeed[i],loop, ofSoundBuffer::Linear); } resampledBuffer.stereoPan(volumesLeft[i],volumesRight[i]); newBufferE.notify(this,resampledBuffer); resampledBuffer.addTo(outputBuffer,0,loop); } } updatePositions(nFrames); } } }
void ofxGSTT::audioIn(ofSoundBuffer & buffer){ //TODO make better use of soundbuffer obj audioIn(&buffer[0], buffer.getNumFrames(), buffer.getNumChannels(), OFXGSTT_DEFAULTDEVICE_ID); //TODO multidevice business }
void ofBaseSoundOutput::audioOut( ofSoundBuffer& buffer ){ audioOut(&buffer[0], buffer.getNumFrames(), buffer.getNumChannels(), buffer.getDeviceID(), buffer.getTickCount()); }