1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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;
};
|