From: Gabriel Dunne Date: Mon, 9 Dec 2013 23:47:24 +0000 (-0800) Subject: Added Audio Callback X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;p=iosynth.git Added Audio Callback --- diff --git a/src/iosynthApp.cpp b/src/iosynthApp.cpp index 8184e77..140082f 100644 --- a/src/iosynthApp.cpp +++ b/src/iosynthApp.cpp @@ -10,6 +10,12 @@ void iosynthApp::setup() voices.at(i)->setGain(1); voices.at(i)->keyOff(0); } + + reverb.setT60(2); + reverb.setEffectMix(0.35); + mMasterGain = 0.85; + + audio::Output::play(audio::createCallback(this, &iosynthApp::processAudio)); } void iosynthApp::update() @@ -39,6 +45,39 @@ void iosynthApp::draw() } } +void iosynthApp::processAudio( uint64_t inSampleOffset, uint32_t ioSampleCount, audio::Buffer32f *ioBuffer ) { + + for( int i = 0; i < ioSampleCount; i++ ) { + + float sample = 0; + + // render each voice + for (auto v : voices) { + sample += v->tick(); + } + + // delay line + sample += maxiDelay.dl(sample, 2048 * 8, .6); // * 0.9125; + + // filter + // sample += maxiFilter.cutoff + + // master reverb + sample = reverb.tick(sample); + + // gate + // sample = fmin(sample, 1); + + // master gain + sample = sample * mMasterGain; + + + ioBuffer->mData[i * ioBuffer->mNumberChannels] = mAudioSamples[0][i] = sample; + ioBuffer->mData[i * ioBuffer->mNumberChannels + 1] = mAudioSamples[1][i] = sample; + } +} + + void iosynthApp::mouseDown( MouseEvent event ) { } diff --git a/src/iosynthApp.h b/src/iosynthApp.h index 69cd467..d358862 100644 --- a/src/iosynthApp.h +++ b/src/iosynthApp.h @@ -46,8 +46,7 @@ public: void update(); void draw(); - void processAudio( uint64_t inSampleOffset, uint32_t ioSampleCount, - audio::Buffer32f *ioBuffer ); + void processAudio( uint64_t inSampleOffset, uint32_t ioSampleCount, audio::Buffer32f *ioBuffer ); void touchesBegan( TouchEvent event ); void touchesMoved( TouchEvent event ); void touchesEnded( TouchEvent event );