-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cxx
61 lines (46 loc) · 1.77 KB
/
main.cxx
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
/*
Copyright (C) 2014 Harry van Haaren <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lvtwohost.hxx"
#include <sndfile.hh>
#include <string>
int main(int argc, char** argv)
{
float* audioIn = new float[44100 * 5];
float* audioOut = new float[44100 * 10];
SndfileHandle outfile( "lvtwohostTest.wav" , SFM_WRITE, SF_FORMAT_WAV | SF_FORMAT_FLOAT , 2 , 44100);
// instantiate LV2 host class
std::string pluginURI = "http://www.openavproductions.com/artyfx#roomy";
Lv2Host* host = new Lv2Host( 0, 44100, 1024, pluginURI );
// process buffer size
int nframes = 128;
SndfileHandle infile("test.wav");
infile.read(audioIn, 44100 * 10);
float** audioBuffers = host->getAudioBuffers();
for (int i = 0; i < ceil(44100 * 5 / 128); i++) {
// copy input
std::copy(&audioIn[i * 128], &audioIn[i * 128] + 128, audioBuffers[0]);
host->process(nframes);
// copy output
for (int x = 0; x < 128; x++) {
audioOut[i * 256 + 2 * x] = audioBuffers[1][x];
audioOut[i * 256 + 1 + 2 * x] = audioBuffers[1][x];
}
}
// save audio to disk
outfile.write(audioOut, 44100 * 10);
// cleanup
delete host;
delete[] audioIn;
delete[] audioOut;
return 0;
}