Commits

João Felipe Santos  committed 3cd9cd4

Added scripts for building the lib and mex-files for Octave on Linux.

  • Participants
  • Parent commits 78f0985

Comments (0)

Files changed (5)

File CochlearFilterbank/CochlearFilterbank.cpp

 	Eigen::MatrixXd y(input.rows(), filters.size());
 	vector<future<Eigen::VectorXd>> futures;
 	for (unsigned int ch=0; ch < filters.size(); ch++)
-		futures.push_back(async(&CochlearFilterbank::process_channel, this, input, n, ch));
+          futures.push_back(async(launch::async, &CochlearFilterbank::process_channel, this, input, n, ch));
 	for (unsigned int ch=0; ch < filters.size(); ch++)
 	{
 		y.col(ch) = futures[ch].get();

File CochlearFilterbank/Test.cpp

 #include "ModulationFilterBank.h"
 #include <iostream>
 #include <Eigen>
+#ifdef WINDOWS
 #include "timer.h"
+#endif
 
 using namespace std;
 
-#define N_SAMPLES 16000*60*5
-
+#define N_SAMPLES 16000*60*2
 
 int main()
 {
 	
 	// Testing ERBspace
 	Eigen::VectorXd cf_array = cf.ERBspace(150, 16000/2, 23);
-	//cout << cf_array << endl;
-
-	// Testing makeERBFilters
-	//cf.makeERBFilters(16000.0, 23, 150);
+	cout << cf_array << endl;
 
 	// Testing filters
 	Eigen::VectorXd x(Eigen::VectorXd::Zero(N_SAMPLES));
 	x[0] = 1.0; // unit impulse
 
 	// Running filters
-	Timer tt;
-	tt.Start();
 	Eigen::MatrixXd y;
-	y = cf.process(x, N_SAMPLES);
-	tt.Stop();
+#ifdef WINDOWS
+        Timer tt;
+ 	tt.Start();
+#endif
+        y = cf.process(x, N_SAMPLES);
+#ifdef WINDOWS
+ 	tt.Stop();
+        cout << "Total processing time for the cochlear filterbank: " << tt.Elapsed() << " ms." << endl;
+#endif
 #ifdef DEBUG
 	for (int k=0; k < 23; k++)
 	{
 		fclose(f);
 	}
 #endif
-	cout << "Total processing time for the cochlear filterbank: " << tt.Elapsed() << " ms." << endl;
+        cout << "Tested CochlearFilterBank successfully." << endl;
 
-	// Testing the ModulationFilterBank
-	Eigen::VectorXd central_freqs(8);
-	central_freqs = ModulationFilterBank::compute_modulation_cfs(4.0, 128.0, 8);
-	//cout << central_freqs << endl;
-	ModulationFilterBank mf = ModulationFilterBank(16000, 8, central_freqs, 2);
-	// Running filters
-	Eigen::MatrixXd ym;
-	Timer tm;
-	tm.Start();
-	ym = mf.process(x, N_SAMPLES);
-	tm.Stop();
+// 	// Testing the ModulationFilterBank
+ 	Eigen::VectorXd central_freqs(8);
+ 	central_freqs = ModulationFilterBank::compute_modulation_cfs(4.0, 128.0, 8);
+ 	cout << central_freqs << endl;
+ 	ModulationFilterBank mf = ModulationFilterBank(16000, 8, central_freqs, 2);
+ 	// Running filters
+ 	Eigen::MatrixXd ym;
+#ifdef WINDOWS
+        Timer tm;
+ 	tm.Start();
+#endif
+ 	ym = mf.process(x, N_SAMPLES);
+#ifdef WINDOWS
+        tm.Stop();
+        cout << "Total processing time for the modulation filterbank: " << tm.Elapsed() << " ms." << endl;
+#endif
 #ifdef DEBUG
-	for (int k=0; k < 23; k++)
-	{
-		char fname[15];
-		sprintf(fname,"mf%d.txt",k+1);
-		FILE* f = fopen(fname,"w");
-		for (int n=0; n < N_SAMPLES; n++)
-			fprintf(f,"%e\n",ym(n,k));
-		fclose(f);
-	}
+ 	for (int k=0; k < 23; k++)
+ 	{
+ 		char fname[15];
+ 		sprintf(fname,"mf%d.txt",k+1);
+ 		FILE* f = fopen(fname,"w");
+ 		for (int n=0; n < N_SAMPLES; n++)
+ 			fprintf(f,"%e\n",ym(n,k));
+ 		fclose(f);
+ 	}
 #endif
-	cout << "Total processing time for the modulation filterbank: " << tm.Elapsed() << " ms." << endl;
-
-	cin.ignore();
+        cout << "Tested ModulationFilterBank successfully." << endl;
 }
 

File CochlearFilterbank/build.sh

+g++ -g -std=c++11 -o test -I /usr/include/eigen3/Eigen/ Biquad.cpp CochlearFilterbank.cpp ModulationFilterBank.cpp Test.cpp -lpthread -O3

File CochlearFilterbankMex/build.sh

+export CXXFLAGS="-g -O3 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fopenmp -std=c++11"
+mkoctfile --mex CochlearFilterbankMex.cpp ../CochlearFilterbank/CochlearFilterbank.cpp ../CochlearFilterbank/Biquad.cpp -I../CochlearFilterbank/ -I/usr/include/eigen3/Eigen/ -lpthread -L../CochlearFilterbank/

File ModulationFilterbankMex/build.sh

+export CXXFLAGS="-g -O3 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fopenmp -std=c++11"
+mkoctfile --mex ModulationFilterbankMex.cpp ../CochlearFilterbank/ModulationFilterBank.cpp ../CochlearFilterbank/Biquad.cpp -I../CochlearFilterbank/ -I/usr/include/eigen3/Eigen/ -lpthread -L../CochlearFilterbank/