aboutsummaryrefslogtreecommitdiffstats
path: root/ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp')
-rw-r--r--ofxMaxim/ofxMaximExamples007OSX/maxiAtomSynthesis/src/mp.cpp27
1 files changed, 20 insertions, 7 deletions
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];
}