-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
128 lines (102 loc) · 2.84 KB
/
main.cpp
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
127
128
#include <iostream>
#include <AudioParameterFloat.h>
#include <CircularBuffer.h>
#include <DigitalDelayLine.h>
#include <Oscillator.h>
#include <RangedAudioParameter.h>
#include <AudioParameterFloat.h>
#include <AudioObject.h>
#include <DopplerPitchShifter.h>
#include <DopplerOctave.h>
#include <FilterZ.h>
#include <ModulationFilter.h>
#include <FeedbackDelayNetwork.h>
#include <CrossConvolution.h>
#include <UnitGain.h>
#include "Vendor/MLD.hpp"
#include "Vendor/AudioFile.h"
void renderAlgorithm()
{
//DigitalDelayLine dl0(262144, 0);
//dl0.ParameterCtrl(1, 0);
//dl0.ParameterCtrl(2, 64);
//DigitalDelayLine dl1(262144, 0);
//dl1.ParameterCtrl(1, 70);
//dl1.ParameterCtrl(2, 80);
//unsigned int NodeSize = 2;
//AudioObject* audioNodes[8];
//audioNodes[0] = &dl0;
//audioNodes[1] = &dl1;
//DopplerOctave obj(0);
//Oscillator obj;
//ModulationFilter obj;
//FeedbackDelayNetwork obj(0);
CrossConvolution obj(0);
//UnitGain obj(0);
unsigned int NodeSize = 1;
AudioObject* audioNodes[8];
audioNodes[0] = &obj;
AudioFile<double> audioFile;
audioFile.load("Extra/Protection.wav");
std::cout << "Before Processing..." << std::endl;
audioFile.printSummary();
std::cout << "" << std::endl;
int channels = audioFile.getNumChannels();
int numSamples = audioFile.getNumSamplesPerChannel();
int blockSize = 256;
int iteration = (numSamples / blockSize) + 1;
AudioFile<double>::AudioBuffer buffer;
buffer.resize(channels);
for (int i = 0; i < channels; i++)
{
buffer[i].resize(iteration * blockSize);
}
for (int i = 0; i < iteration; i++)
{
double* currentFrame = &audioFile.samples[0][i*blockSize];
for (int index = 0; index < NodeSize; index++)
{
audioNodes[index]->Process(currentFrame, blockSize);
}
for (int j = 0; j < blockSize; j++)
{
buffer[0][i * blockSize + j] = currentFrame[j];
buffer[1][i * blockSize + j] = currentFrame[j];
}
}
bool ok = audioFile.setAudioBuffer(buffer);
audioFile.save("Render/render-output.wav", AudioFileFormat::Wave);
std::cout << "After Processing..." << std::endl;
audioFile.printSummary();
std::cout << "" << std::endl;
obj.Release();
}
void memoryLeakDetector()
{
memoryld::memory_monitoring();
//std::cout << "" << std::endl;
//DigitalDelayLine dl(32768, 0);
//dl.Release();
//Oscillator osc;
//osc.Release();
//DopplerPitchShifter ps(0);
//ps.Release();
//DopplerOctave oct(0);
//oct.Release();
memoryld::memory_check();
}
void main()
{
renderAlgorithm();
//memoryLeakDetector();
//FilterDesigner lp;
//lp.model = 1;
//lp.setParameter(1200, 0.707, 0);
//float* coefficient = lp.getCoefficients();
//std::cout << coefficient[0] << std::endl;
//std::cout << coefficient[1] << std::endl;
//std::cout << coefficient[2] << std::endl;
//std::cout << coefficient[3] << std::endl;
//std::cout << coefficient[4] << std::endl;
//std::cout << coefficient[5] << std::endl;
}