-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
94 lines (84 loc) · 3.53 KB
/
main.cpp
File metadata and controls
94 lines (84 loc) · 3.53 KB
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 <exception>
#include <fstream>
#include "PCMWavData.h"
#include "globalFunction.h"
#define _CRT_SECURE_NO_WARNINGS
/*
1. window duration (ms)
3. PLR (%) - Packet Loss Rate
4. MBLL (packets) - Mean Burst Loss Length
5. path to input file
6. path to output file
*/
/*
framing(int window_size, PCMWavData objWav)
gilbertModel(double PLR, int MBLL, int liczbaOkien)
convolutionModeldWavFile(szererg_gilberta, dane_framing, window_size_in_ms, obj);
void zapiszWav(std::vector< std::vector<double> > dane, int okno_size, string pathToOutFile)
*/
int main(int argc, char* argv[])
{
int window_size_in_ms = 0;
int PLR = 0;
int MBLL = 0;
std::string in_file;
std::string out_file;
if(!(argc != 1 || argc != 6))
{
std::cerr<<"Incorrect arguments"<<std::endl;
return 0;
}
if(argc == 1)
{
std::cout << "The IP transmission may cause many different packet errors. "
<< "Among others, packets can be lost, damaged or delayed. "
<< "Most of the IP traffic is under control of TCP protocol, "
<< "which provides solution of packet retransmission. "
<< "However, the VoIP technology uses UDP protocol that "
<< "doesn’t provide any recovery method. "
<< "The investigation of packet loss phenomenon reveals that "
<< "voice packets are lost in bursts. The IP traffic is described "
<< "by a two-state simple Gilbert model, which allows using only "
<< "two parameters to describe the loss process."
<< "\n\nParameters: \n"
<< "window duration - [int] in milisekunds\n"
<< "PLR (%) - [int] Packet Loss Rate\n"
<< "MBLL (packets) - [int] Mean Burst Loss Length\n"
<< "path to audio - [string] only standard header PCM is allowed\n"
<< "path to output - [string]"
<< "\n\nExample: \n"
<< "./gilbertmodel 20 10 5 audio.wav audio-proces.wav\n";
}
if((argc == 6))
{
window_size_in_ms = atoi(argv[1]);
//window_size_in_ms = 20;
PLR = atoi(argv[2]);
//PLR = 10;
MBLL = atoi(argv[3]);
//MBLL = 5;
in_file = toPosixNotation((std::string)(argv[4]));
//in_file = "\\1_M1_target30s_A.wav";
out_file = toPosixNotation((std::string)(argv[5]));
//out_file = "1_M1_target30s_A_20_10_5.wav";
//std::cout<< window_size_in_ms <<std::endl;
//std::cout<< PLR <<std::endl;
//std::cout<< MBLL <<std::endl;
//std::cout<< in_file <<std::endl;
//std::cout<< out_file <<std::endl;
PCMWavData obj = loadWaveFile(in_file);
std::vector< std::vector<double> > dane_framing = framing(window_size_in_ms, obj);
std::vector<short> szererg_gilberta = gilbertModel(PLR, MBLL, dane_framing.size());
std::vector<double> y = walidacjaGilbertModel(szererg_gilberta);
std::vector< std::vector<double> > convolvedDane = convolutionModeldWavFile(szererg_gilberta, dane_framing, window_size_in_ms, obj);
obj.zapiszWav(convolvedDane, window_size_in_ms, out_file);
int i = 0;
std::cout<<" Estimated parameters:\n";
std::cout<<" PLR "<<y[0]<<std::endl;
std::cout<<" MBLL " <<y[1]<<std::endl;
std::cout<<" Task was finished"<<std::endl;
}
//system("PAUSE");
return 0;
}