-
Notifications
You must be signed in to change notification settings - Fork 44
/
RenderEngine.h
126 lines (96 loc) · 3.9 KB
/
RenderEngine.h
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
==============================================================================
RenderEngine.h
Created: 19 Feb 2017 9:47:15pm
Author: tollie
==============================================================================
*/
#ifndef RENDERENGINE_H_INCLUDED
#define RENDERENGINE_H_INCLUDED
#include <random>
#include <array>
#include <iomanip>
#include <sstream>
#include <string>
#include "Maximilian/maximilian.h"
#include "Maximilian/libs/maxiFFT.h"
#include "Maximilian/libs/maxiMFCC.h"
#include "../JuceLibraryCode/JuceHeader.h"
#include <boost/python.hpp>
using namespace juce;
typedef std::vector<std::pair<int, float>> PluginPatch;
typedef std::vector<std::array<double, 13>> MFCCFeatures;
typedef std::vector<std::pair<int, std::string>> ParameterNameList;
typedef std::pair<OwnedArray<PluginDescription>, KnownPluginList> PluginsInfo;
typedef std::vector<std::pair<std::string, int>> PluginNames;
class RenderEngine
{
public:
RenderEngine (int sr,
int bs,
int ffts) :
sampleRate(sr),
bufferSize(bs),
fftSize(ffts),
plugin(nullptr)
{
maxiSettings::setup (sampleRate, 1, bufferSize);
}
virtual ~RenderEngine()
{
if (plugin != nullptr)
{
plugin->releaseResources();
delete plugin;
}
}
std::string getAvailablePluginsXml(const std::string& path);
void fillAvailablePluginsInfo(const std::string& path,
AudioPluginFormatManager& pluginFormatManager,
OwnedArray<PluginDescription>& pluginDescriptions,
KnownPluginList& pluginList
);
bool loadPlugin (const std::string& path, int index = 0);
void setPatch (const PluginPatch patch);
const PluginPatch getPatch();
void renderPatch (const uint8 midiNote,
const uint8 midiVelocity,
const double noteLength,
const double renderLength);
void renderWav(boost::python::object wav);
const MFCCFeatures getMFCCFrames();
const MFCCFeatures getNormalisedMFCCFrames (const std::array<double, 13>& mean,
const std::array<double, 13>& variance);
const std::vector<double> getRMSFrames();
const size_t getPluginParameterSize();
ParameterNameList getPluginParametersDescription();
bool overridePluginParameter (const int index,
const float value);
bool removeOverridenParameter (const int index);
const std::vector<double> getAudioFrames();
bool writeToWav(const std::string& path);
private:
void fillAudioFeatures (const AudioSampleBuffer& data,
maxiFFT& fft);
void ifTimeSetNoteOff (const double noteLength,
const double sampleRate,
const int bufferSize,
const uint8 midiChannel,
const uint8 midiPitch,
const uint8 midiVelocity,
const int currentBufferIndex,
MidiBuffer& bufferToNoteOff);
void fillAvailablePluginParameters (PluginPatch& params);
double sampleRate;
int bufferSize;
int fftSize;
maxiMFCC mfcc;
AudioPluginInstance* plugin;
PluginPatch pluginParameters;
PluginPatch overridenParameters;
MFCCFeatures mfccFeatures;
std::vector<double> processedMonoAudioPreview;
std::vector<double> rmsFrames;
double currentRmsFrame;
};
#endif // RENDERENGINE_H_INCLUDED