diff options
| author | mick grierson <mickgrierson@gmail.com> | 2015-07-26 23:57:38 +0100 |
|---|---|---|
| committer | mick grierson <mickgrierson@gmail.com> | 2015-07-26 23:57:38 +0100 |
| commit | 68ee8eba9c3834604d220f4bf56e7e9d506a77a7 (patch) | |
| tree | c021e67cc0ebc042a896259c2e508b8b60ad6c6d /libs/maxiAtoms.h | |
| parent | cb3e92e75b1492bc1434431e975d1acf145c84fc (diff) | |
Some initial changes that are long overdue part 1
Diffstat (limited to 'libs/maxiAtoms.h')
| -rw-r--r-- | libs/maxiAtoms.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/libs/maxiAtoms.h b/libs/maxiAtoms.h new file mode 100644 index 0000000..1782d55 --- /dev/null +++ b/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; +}; + |
