aboutsummaryrefslogtreecommitdiffstats
path: root/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
diff options
context:
space:
mode:
authorChris Kiefer <chrisk13fer@gmail.com>2011-11-08 18:27:49 +0000
committerChris Kiefer <chrisk13fer@gmail.com>2011-11-08 18:27:49 +0000
commit67a2545c51a866219e3809c7a7d1ae01997fb812 (patch)
tree9c0209aa72934b35ef69eb640fb7b5667bebc85a /ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
parentf413f0d1f91efdc2d19b9ad8b472abfe597f635e (diff)
More atom playback
Diffstat (limited to 'ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp')
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
index 1164aba..7db1374 100644
--- a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
+++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
@@ -11,10 +11,11 @@ void mp::setup(){
// pyd.clear();
- atomBuffer.resize(512);
maxiAtomBook::loadMPTKXmlBook(ofToDataPath("/tmp/book.xml"), book);
sort(book.atoms.begin(), book.atoms.end(), maxiAtom::atomSortPositionAsc);
+ atomBuffer.resize(512);
+ atomData.resize(book.atoms[0]->length);
ofxMaxiSettings::setup(44100, 2, 512);
ofSoundStreamSetup(maxiSettings::channels,0,this, maxiSettings::sampleRate, maxiSettings::bufferSize, 4);/* Call this last ! */
@@ -31,14 +32,11 @@ void mp::update(){
// 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);
-
+ atomStream.addAtom(test);
atomIdx++;
}
@@ -48,6 +46,16 @@ void mp::draw(){
}
void mp::audioRequested (float * output, int bufferSize, int nChannels){
+// long idx = atomStream.getSampleIdx();
+// static int atomIdx = 0;
+// maxiGaborAtom *atom = (maxiGaborAtom*) book.atoms[atomIdx % book.atoms.size()];
+// while(atom->position < (idx + bufferSize) % book.numSamples) {
+// maxiCollider::createGabor(atomData, maxiMap::linexp(atom->frequency, 0, 0.2, 20, 20000), 44100, atom->length, atom->phase, 0.3, atom->amp / 40.0);
+// atomStream.addAtom(atomData);
+// atomIdx++;
+// atom = (maxiGaborAtom*) book.atoms[atomIdx % book.atoms.size()];
+// }
+
memset(&atomBuffer[0], 0, sizeof(float) * bufferSize);
atomStream.fillNextBuffer(&(atomBuffer[0]), bufferSize);
for (int i = 0; i < bufferSize; i++){