Commit f5affd57 authored by Bernardo Hummes's avatar Bernardo Hummes
Browse files

weird code without my function so that katell is repi

parent 422f0688
......@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.16)
project(EML)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra -std=c++20")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra -ggdb -std=c++20")
add_subdirectory(Extraction)
#add_subdirectory(CART)
......
......@@ -10,48 +10,48 @@ std::map<FTYPE, DataVector> stft(DataVector &signal) {
auto stddev = DataVector(FFT_SIZE);
for (DataVector::const_iterator it; it != signal.end(); it+=N) {
// get the two overlapping chuncks from the sliding window
std::vector<Complex> v1(it, it+N);
std::vector<Complex> v2(it+N/2, it+N+N/2);
auto w = hamming_window();
windowing(w, v1);
windowing(w, v2);
// compute the fft
ite_dit_fft(v1);
ite_dit_fft(v2);
// compute the magnitude fft's output (which is a complex, with angle and phase)
DataVector v1_abs = DataVector(N);
DataVector v2_abs = DataVector(N);
for (std::size_t i=0; i<v1.size(); i++) {
v1_abs.push_back(abs(v1[i]));
v2_abs.push_back(abs(v2[i]));
}
// compute the average of the magnitudes
auto chunck_1_avg = std::accumulate(v1_abs.begin(), v1_abs.end(), 0)/v1_abs.size();
auto chunck_2_avg = std::accumulate(v1_abs.begin(), v1_abs.end(), 0)/v1_abs.size();
avg.push_back(chunck_1_avg);
avg.push_back(chunck_2_avg);
// use the average to compute the std deviation
auto chunck_1_stddev = 0;
auto chunck_2_stddev = 0;
for (std::size_t i=0; i < v1_abs.size(); i++) {
chunck_1_stddev += pow(v1_abs.at(i) - chunck_1_avg, 2);
chunck_2_stddev += pow(v2_abs.at(i) - chunck_1_avg, 2);
}
stddev.push_back(chunck_1_stddev);
stddev.push_back(chunck_2_stddev);
}
// for (DataVector::const_iterator it; it != signal.end()-N-1; it+=N) {
//
// // get the two overlapping chuncks from the sliding window
// std::vector<Complex> v1(it, it+N);
// std::vector<Complex> v2(it+N/2, it+N+N/2);
//
// auto w = hamming_window();
// windowing(w, v1);
// windowing(w, v2);
//
// // compute the fft
// ite_dit_fft(v1);
// ite_dit_fft(v2);
//
// // compute the magnitude fft's output (which is a complex, with angle and phase)
// DataVector v1_abs = DataVector(N);
// DataVector v2_abs = DataVector(N);
//
// for (std::size_t i=0; i<v1.size(); i++) {
// v1_abs.push_back(abs(v1[i]));
// v2_abs.push_back(abs(v2[i]));
// }
//
// // compute the average of the magnitudes
// auto chunck_1_avg = std::accumulate(v1_abs.begin(), v1_abs.end(), 0)/v1_abs.size();
// auto chunck_2_avg = std::accumulate(v1_abs.begin(), v1_abs.end(), 0)/v1_abs.size();
//
// avg.push_back(chunck_1_avg);
// avg.push_back(chunck_2_avg);
//
// // use the average to compute the std deviation
// auto chunck_1_stddev = 0;
// auto chunck_2_stddev = 0;
//
// for (std::size_t i=0; i < v1_abs.size(); i++) {
// chunck_1_stddev += pow(v1_abs.at(i) - chunck_1_avg, 2);
// chunck_2_stddev += pow(v2_abs.at(i) - chunck_1_avg, 2);
// }
//
// stddev.push_back(chunck_1_stddev);
// stddev.push_back(chunck_2_stddev);
// }
std::map<FTYPE, DataVector> features;
//insert bins average and stddev in features
......
......@@ -7,12 +7,13 @@
int main() {
auto beg = std::chrono::high_resolution_clock::now();
auto dirs = alpha_dir_listing("../../data/");
auto dirs = alpha_dir_listing("../data/");
std::vector<std::filesystem::path> training_files;
std::vector<std::filesystem::path> testing_files;
// Select random files of each music style
for (auto dir_path: dirs) {
std::cout << dir_path << std::endl;
auto files = alpha_files_listing(dir_path);
std::vector<std::filesystem::path> training;
std::vector<std::filesystem::path> testing;
......
......@@ -47,8 +47,6 @@ struct Wave_header {
U32 magic_num;
U32 offset;
U32 data_size;
};
DataVector readAuFile(const std::string fileName) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment