From 67a2545c51a866219e3809c7a7d1ae01997fb812 Mon Sep 17 00:00:00 2001 From: Chris Kiefer Date: Tue, 8 Nov 2011 18:27:49 +0000 Subject: More atom playback --- ofxMaxim/ofxMaxim/libs/maxiAtoms.h | 1 + .../maxiAtomSynthesis/.gitignore | 2 ++ .../maxiAtomSynthesis/bin/.gitignore | 1 + .../maxiAtomSynthesis/bin/data/.gitignore | 3 +++ .../maxiAtomSynthesis/src/mp.cpp | 20 ++++++++++++++------ .../maxiAtomSynthesis/src/mp.h | 2 ++ 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/.gitignore create mode 100644 ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/.gitignore create mode 100644 ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/data/.gitignore diff --git a/ofxMaxim/ofxMaxim/libs/maxiAtoms.h b/ofxMaxim/ofxMaxim/libs/maxiAtoms.h index ec054b8..d420ea1 100644 --- a/ofxMaxim/ofxMaxim/libs/maxiAtoms.h +++ b/ofxMaxim/ofxMaxim/libs/maxiAtoms.h @@ -45,6 +45,7 @@ public: maxiAccelerator(); void addAtom(flArr &atom); void fillNextBuffer(float *buffer, unsigned int bufferLength); + inline long getSampleIdx(){return sampleIdx;} private: long sampleIdx; struct queuedAtom { diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/.gitignore b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/.gitignore new file mode 100644 index 0000000..9ef9604 --- /dev/null +++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/.gitignore @@ -0,0 +1,2 @@ +build + diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/.gitignore b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/.gitignore new file mode 100644 index 0000000..13d94f8 --- /dev/null +++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/.gitignore @@ -0,0 +1 @@ +*.app diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/data/.gitignore b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/data/.gitignore new file mode 100644 index 0000000..0a9e2b1 --- /dev/null +++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/bin/data/.gitignore @@ -0,0 +1,3 @@ +# Ignore everything in here apart from the .gitignore file +* +!.gitignore \ No newline at end of file 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++){ diff --git a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h index 5a3021d..9bc87f3 100644 --- a/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h +++ b/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.h @@ -29,5 +29,7 @@ class mp : public ofBaseApp{ maxiAtomBook book; flArr atomBuffer; + flArr atomData; + }; -- cgit v1.3