From 68ee8eba9c3834604d220f4bf56e7e9d506a77a7 Mon Sep 17 00:00:00 2001 From: mick grierson Date: Sun, 26 Jul 2015 23:57:38 +0100 Subject: Some initial changes that are long overdue part 1 --- libs/maxiAtoms.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 libs/maxiAtoms.h (limited to 'libs/maxiAtoms.h') 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 +#include "maximilian.h" +#include +#include +#include "maxiGrains.h" + + +using namespace std; + +typedef vector 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 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 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 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; +}; + -- cgit v1.3