-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
94 lines (84 loc) · 2.57 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
#include <iostream>
#include <fstream>
#include <vector>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include "Sampleizer.h"
#include <string>
#include "boost/tuple/tuple.hpp"
using namespace std;
using namespace boost;
int main (int argc, char * const argv[]) {
srand(time(0)); //resets the randomgen/ only once per runtime!
//some default values
int numberOfFrames = 10;
int frameDuration = 10000;
string inputFilePath = "/Users/voo/Desktop/Beethoven.wav";
string inputSpzFilePath = "/Users/voo/Desktop/input.spz";
string outputFilePath = "/Users/voo/Desktop/output.wav";
int numberOfRepetitions = 0;
int permutation = 0;
int algorithm = 0;
//if invoked via terminal
for (int i=1; i<argc; i++) {
if (i+1!=argc) {
if (string(argv[i]) == "-f") {
numberOfFrames = atoi(argv[i+1]);
}
else if (string(argv[i]) == "-d") {
frameDuration = atoi(argv[i+1]);
}
else if (string(argv[i]) == "-i") {
inputFilePath = argv[i+1];
cout << inputFilePath;
}
else if (string(argv[i]) == "-s") {
inputSpzFilePath = argv[i+1];
}
else if (string(argv[i]) == "-o") {
outputFilePath = argv[i+1];
}
else if (string(argv[i]) == "-r") {
numberOfRepetitions = atoi(argv[i+1]);
}
else if (string(argv[i]) == "-p") {
permutation = atoi(argv[i+1]);
}
else if (string(argv[i]) == "-a") {
algorithm = atoi(argv[i+1]);
}
}
}
//minimal setup
Waveform inputWaveform(inputFilePath);
Envelope env(0.01, 0, 1, 0.01);
Sampleizer s(inputWaveform);
if (algorithm==0) { //linear
s.doLinear(numberOfFrames, frameDuration);
s.convertToWaveform(env).writeWaveformToFile(outputFilePath);
}
else if (algorithm==1) { //random
s.doRandom(numberOfFrames, frameDuration);
s.convertToWaveform(env).writeWaveformToFile(outputFilePath);
}
else if (algorithm==2) { //section
s.doSections(inputSpzFilePath);
s.convertToWaveform(env).writeWaveformToFile(outputFilePath);
}
//time transformation examples
vector<pair<int, double> > pointVector;
pair<int, double> p1 = make_pair(0, 0.2);
pair<int, double> p2 = make_pair(1000, 0.5);
pair<int, double> p3 = make_pair(2000, 3);
pointVector.push_back(p1);
pointVector.push_back(p2);
pointVector.push_back(p3);
Envelope envTime(pointVector);
Waveform timeTransWaveform = inputWaveform.doTimeTransformation(envTime);
timeTransWaveform.writeWaveformToFile("/Users/voo/Desktop/timeTransWF.wav");
//operation example
Waveform summand = inputWaveform + timeTransWaveform + inputWaveform + timeTransWaveform;
summand.writeWaveformToFile("/Users/voo/Desktop/summand.wav");
return 0;
}