diff options
| author | mick grierson <mickgrierson@gmail.com> | 2015-10-27 17:05:12 +0000 |
|---|---|---|
| committer | mick grierson <mickgrierson@gmail.com> | 2015-10-27 17:05:12 +0000 |
| commit | 60341ac292bb9ba6f1d33632f8fd8e767c6a99d4 (patch) | |
| tree | dd801de535997f2f6ff4fc6faab8cfc86c003b7a /openFrameworks/ofxMaxim/libs/maxiAtoms.h | |
| parent | bb210658ed2aa4eafa790197f84f3e24df22351b (diff) | |
clean up
Diffstat (limited to 'openFrameworks/ofxMaxim/libs/maxiAtoms.h')
| -rw-r--r-- | openFrameworks/ofxMaxim/libs/maxiAtoms.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/openFrameworks/ofxMaxim/libs/maxiAtoms.h b/openFrameworks/ofxMaxim/libs/maxiAtoms.h new file mode 100644 index 0000000..1782d55 --- /dev/null +++ b/openFrameworks/ofxMaxim/libs/maxiAtoms.h @@ -0,0 +1,91 @@ +/* + * gabor.h + * mp + * + * Created by Chris on 01/11/2011. + * Copyright 2011 Goldsmiths Creative Computing. All rights reserved. + * + */ + + +#include <iostream> +#include "maximilian.h" +#include <list> +#include <vector> +#include "maxiGrains.h" + + +using namespace std; + +typedef vector<float> flArr; + +enum maxiAtomTypes { + GABOR +}; + +struct maxiAtom { + maxiAtomTypes atomType; + float length; + float position; + float amp; + static bool atomSortPositionAsc(maxiAtom* a, maxiAtom* b) {return a->position < b->position;} +}; + +struct maxiGaborAtom : maxiAtom { + float frequency; + float phase; +}; + +//create atoms +class maxiCollider { +public: + static inline void createGabor(flArr &atom, const float freq, const float sampleRate, const unsigned int length, + float phase, const float kurtotis, const float amp); + static maxiGrainWindowCache<gaussianWinFunctor> envCache; +}; + + +//queue atoms into an audio stream +class maxiAccelerator { +public: + maxiAccelerator(); + void addAtom(flArr &atom, unsigned int offset=0); + void fillNextBuffer(float *buffer, unsigned int bufferLength); + inline long getSampleIdx(){return sampleIdx;} +private: + long sampleIdx; + struct queuedAtom { + flArr atom; + long startTime; + unsigned int pos; + }; + typedef list<queuedAtom> queuedAtomList; + queuedAtomList atomQueue; +}; + +/*load a book in MPTK XML format + http://mptk.irisa.fr/ + + how to create a book: + mpd -n 1000 -R 10 -d ./dic_gabor_two_scales.xml glockenspiel.wav book.xml +*/ +class maxiAtomBook { +public: + ~maxiAtomBook(); + typedef vector<maxiAtom*> maxiAtomBookData; + unsigned int numSamples; + unsigned int sampleRate; + maxiAtomBookData atoms; + //commented out for now, need to resolve tinyxml linker issues - we need tinyxml in the distrib, but it clashes if you also import ofxXmlSettings +// static bool loadMPTKXmlBook(string filename, maxiAtomBook &book); + +}; + +class maxiAtomBookPlayer { +public: + maxiAtomBookPlayer(); + void play(maxiAtomBook &book, maxiAccelerator &atomStream, float *output, int bufferSize); +private: + unsigned int atomIdx; +}; + |
