From 48339d583909a6b6133e0e365957cf0e74dd2ab7 Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Tue, 8 Nov 2011 17:59:04 +0000 Subject: Atom playback example --- .../maxiAtomSynthesis/src/mp.cpp | 27 ++++++++++++++++------ .../maxiAtomSynthesis/src/mp.h | 3 ++- 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src') diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp index b8e5ffd..1164aba 100644 --- a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp +++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp @@ -1,5 +1,6 @@ #include "mp.h" + //-------------------------------------------------------------- void mp::setup(){ ofEnableAlphaBlending(); @@ -11,22 +12,34 @@ void mp::setup(){ atomBuffer.resize(512); - + + maxiAtomBook::loadMPTKXmlBook(ofToDataPath("/tmp/book.xml"), book); + sort(book.atoms.begin(), book.atoms.end(), maxiAtom::atomSortPositionAsc); ofxMaxiSettings::setup(44100, 2, 512); ofSoundStreamSetup(maxiSettings::channels,0,this, maxiSettings::sampleRate, maxiSettings::bufferSize, 4);/* Call this last ! */ } + + //-------------------------------------------------------------- void mp::update(){ flArr test; - maxiAtoms::createGabor(test, maxiMap::linexp((float)mouseX/ofGetWidth(), 0, 1, 100, 10000) * (1.0 + (ofRandomuf() * 0.2)), - maxiSettings::sampleRate, - maxiMap::linlin((float)mouseY / ofGetHeight(), 0, 1, 2000, 40000) * (1.0 + (ofRandomuf() * 0.3)), - ofRandomf() * PI, 0.3, 0.05); - atStream.addAtom(test); +// maxiCollider::createGabor(test, maxiMap::linexp((float)mouseX/ofGetWidth(), 0, 1, 100, 10000) * (1.0 + (ofRandomuf() * 0.2)), +// maxiSettings::sampleRate, +// maxiMap::linlin((float)mouseY / ofGetHeight(), 0, 1, 2000, 40000) * (1.0 + (ofRandomuf() * 0.3)), +// ofRandomf() * PI, 0.3, 0.05); +// atomStream.addAtom(test); + static int atomIdx=0; +// static void createGabor(flArr &atom, const float freq, const float sampleRate, const uint length, +// const float phase, const float kurtotis, const float amp); + maxiGaborAtom *atom = (maxiGaborAtom*) book.atoms[atomIdx % book.atoms.size()]; + cout << atom->frequency << endl; + maxiCollider::createGabor(test, maxiMap::linexp(atom->frequency, 0, 0.2, 20, 20000), 44100, atom->length, atom->phase, 0.3, atom->amp / 40.0); + atomStream.addAtom(test); + atomIdx++; } //-------------------------------------------------------------- @@ -36,7 +49,7 @@ void mp::draw(){ void mp::audioRequested (float * output, int bufferSize, int nChannels){ memset(&atomBuffer[0], 0, sizeof(float) * bufferSize); - atStream.fillNextBuffer(&(atomBuffer[0]), bufferSize); + atomStream.fillNextBuffer(&(atomBuffer[0]), bufferSize); for (int i = 0; i < bufferSize; i++){ output[i*nChannels ] = output[i*nChannels + 1] = atomBuffer[i]; } diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h index 00d185e..5a3021d 100644 --- a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h +++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h @@ -25,7 +25,8 @@ class mp : public ofBaseApp{ void audioRequested (float * input, int bufferSize, int nChannels); /* output method */ // pyOSCDebug pyd; - maxiAtomStream atStream; + maxiAccelerator atomStream; + maxiAtomBook book; flArr atomBuffer; -- cgit v1.3