Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Commit 404ce34

Browse files
author
Amsakan Bavan
committed
Implemented player functionality.
1 parent 84698a9 commit 404ce34

File tree

16 files changed

+478
-353
lines changed

16 files changed

+478
-353
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
[submodule "lib/abseil-cpp"]
88
path = lib/abseil-cpp
99
url = https://github.com/abseil/abseil-cpp
10+
[submodule "lib/qtbase"]
11+
path = lib/qtbase
12+
url = https://github.com/qt/qtbase

.idea/editor.xml

Lines changed: 238 additions & 238 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/CLI.hh

Lines changed: 0 additions & 24 deletions
This file was deleted.

include/CLI/Arguments.hh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// Created by abav on 17.07.2025.
3+
//
4+
5+
#ifndef ARGUMENTS_HH
6+
#define ARGUMENTS_HH
7+
#include <string>
8+
#include <unordered_map>
9+
10+
namespace CLI {
11+
namespace Arguments {
12+
struct CLIArguments {
13+
std::string fileName;
14+
float filterFrequency;
15+
};
16+
17+
enum CLIArgumentProperty {
18+
FILE,
19+
FREQUENCY
20+
};
21+
22+
extern std::unordered_map<std::string, CLIArgumentProperty> propertyMap;
23+
CLIArguments parseArguments(int argc, char** argv);
24+
}
25+
};
26+
#endif //ARGUMENTS_HH

include/CLI/CLI.hh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//
2+
// Created by abav on 17.07.2025.
3+
//
4+
5+
#ifndef CLI_HH
6+
#define CLI_HH
7+
namespace CLI {
8+
void run(int argc, char** argv);
9+
};
10+
#endif //CLI_HH

include/Filter.hh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// Created by abav on 17.07.2025.
3+
//
4+
5+
#ifndef FILTER_HH
6+
#define FILTER_HH
7+
#include <vector>
8+
9+
namespace Filter {
10+
void filter(std::vector<float>& audio, float filterFrequency);
11+
}
12+
#endif //FILTER_HH

src/CLI/Arguments.cc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// Created by abav on 17.07.2025.
3+
//
4+
//
5+
// Created by abav on 17.07.2025.
6+
//
7+
#include "CLI/Arguments.hh"
8+
9+
#include <iostream>
10+
#include <vector>
11+
#include <absl/strings/str_split.h>
12+
13+
namespace CLI {
14+
namespace Arguments {
15+
std::unordered_map<std::string, CLIArgumentProperty> propertyMap = {
16+
{"file", FILE},
17+
{"freq", FREQUENCY}
18+
};
19+
20+
void parseArgument(std::vector<std::string> splittedArgument, CLIArguments& arguments) {
21+
CLIArgumentProperty property = propertyMap[splittedArgument.at(0)];
22+
std::string value = splittedArgument[1];
23+
24+
switch (property) {
25+
case FILE: {
26+
arguments.fileName = value;
27+
break;
28+
}
29+
30+
case FREQUENCY: {
31+
arguments.filterFrequency = std::stof(value);
32+
break;
33+
}
34+
}
35+
}
36+
37+
CLIArguments parseArguments(int argc, char** argv) {
38+
CLIArguments arguments{};
39+
std::vector<std::string> args{argv, argv + argc};
40+
41+
if (args.size() < 3) {
42+
std::cerr << "Invalid usage!\n";
43+
std::cerr << "\tsimpleFilter file=<fileName> freq=<filterFrequency in Hz>\n";
44+
}
45+
46+
for (std::string arg : args) {
47+
std::vector<std::string> splittedArgument = absl::StrSplit(arg, '=');
48+
49+
if (splittedArgument.size() > 1) {
50+
parseArgument(splittedArgument, arguments);
51+
}
52+
}
53+
54+
return arguments;
55+
}
56+
}
57+
};

src/CLI/CLI.cc

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,24 @@
11
//
22
// Created by abav on 17.07.2025.
33
//
4-
#include "CLI.hh"
4+
#include "CLI/CLI.hh"
5+
#include "CLI/Arguments.hh"
56

67
#include <iostream>
78
#include <vector>
89
#include <absl/strings/str_split.h>
910

1011
#include "FileReader.hh"
12+
#include "Filter.hh"
1113
#include "Player.hh"
1214

13-
namespace CLI {
14-
std::unordered_map<std::string, ArgumentProperty> propertyMap = {
15-
{"file", FILE},
16-
{"freq", FREQUENCY}
17-
};
18-
void parseArgument(std::vector<std::string> splittedArgument, Arguments& arguments) {
19-
ArgumentProperty property = propertyMap[splittedArgument.at(0)];
20-
std::string value = splittedArgument[1];
21-
22-
switch (property) {
23-
case FILE: {
24-
arguments.fileName = value;
25-
break;
26-
}
27-
28-
case FREQUENCY: {
29-
arguments.filterFrequency = std::stof(value);
30-
break;
31-
}
32-
}
33-
}
34-
Arguments parseArguments(int argc, char** argv) {
35-
Arguments arguments{};
36-
std::vector<std::string> args{argv, argv + argc};
37-
38-
if (args.size() < 3) {
39-
std::cerr << "Invalid usage!\n";
40-
std::cerr << "\tsimpleFilter file=<fileName> freq=<filterFrequency in Hz>\n";
41-
}
42-
43-
for (std::string arg : args) {
44-
std::vector<std::string> splittedArgument = absl::StrSplit(arg, '=');
45-
46-
if (splittedArgument.size() > 1) {
47-
parseArgument(splittedArgument, arguments);
48-
}
49-
}
50-
51-
return arguments;
52-
}
53-
54-
void run(int argc, char** argv) {
55-
Arguments arguments = parseArguments(argc, argv);
56-
std::vector<float> audio = FileReader::readFile(arguments.fileName);
57-
Player::play(audio);
58-
}
15+
void CLI::run(int argc, char** argv) {
16+
Arguments::CLIArguments arguments = Arguments::parseArguments(argc, argv);
17+
std::vector<float> audio = FileReader::readFile(arguments.fileName);
18+
/*
19+
std::cout << "Doing filtering..\n";
20+
Filter::filter(audio, arguments.filterFrequency);
21+
std::cout << "Done.\n";
22+
*/
23+
Player::play(audio);
5924
};

src/CLI/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
add_library(CLI
2+
Arguments.cc
23
CLI.cc
34
)
45

56
target_link_libraries(CLI
67
FileReader
8+
Filter
79
Player
810
absl::strings
911
)

0 commit comments

Comments
 (0)