changeset 587:d59c0d65624b

some more refactor, and stubbed more unit test.
author Ulf.Hammarqvist@gmail.com
date Thu, 11 Oct 2012 21:28:34 +0000
parents f3dde307f4b8
children 1668e8e09a71
files branches/carfac_cpp/include/CARFAC.h branches/carfac_cpp/include/unit_conversion.h branches/carfac_cpp/makefile branches/carfac_cpp/src/CAR.cpp branches/carfac_cpp/src/CARFAC.cpp branches/carfac_cpp/src/unit_conversion.cpp branches/carfac_cpp/unittest/AGC_unittest.cpp branches/carfac_cpp/unittest/CARFAC_unittest.cpp branches/carfac_cpp/unittest/CAR_unittest.cpp branches/carfac_cpp/unittest/Ear_unittest.cpp branches/carfac_cpp/unittest/IHC_unittest.cpp branches/carfac_cpp/unittest/unit_conversion_unittest.cpp
diffstat 12 files changed, 51 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/branches/carfac_cpp/include/CARFAC.h	Thu Oct 11 20:55:03 2012 +0000
+++ b/branches/carfac_cpp/include/CARFAC.h	Thu Oct 11 21:28:34 2012 +0000
@@ -12,7 +12,6 @@
 class CARFAC{
 public:
   CARFAC(int, CAR_parameters*, IHC_parameters*, AGC_parameters*, int);
-  static float ERB_Hz(float, float, float);
 
   float fs_;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/branches/carfac_cpp/include/unit_conversion.h	Thu Oct 11 21:28:34 2012 +0000
@@ -0,0 +1,6 @@
+#ifndef UNIT_CONVERSION_H_
+#define UNIT_CONVERSION_H_
+
+float ERB_Hz(float, float, float);
+
+#endif
--- a/branches/carfac_cpp/makefile	Thu Oct 11 20:55:03 2012 +0000
+++ b/branches/carfac_cpp/makefile	Thu Oct 11 21:28:34 2012 +0000
@@ -23,7 +23,7 @@
 CPPFLAGS += -I$(SRC_HEADERDIR) -I$(GTEST_DIR)/include
 CXXFLAGS += -g -Wall -Wextra -std=gnu++0x #IMPORTANT note gnu++0x
 
-UNITS = CARFAC AGC CAR Ear IHC #Add build units here (without the .cpp)
+UNITS = CARFAC AGC CAR Ear IHC unit_conversion #Add build units here (without the .cpp)
 SRC_OBJ = $(addprefix $(SRC_DIR)/, $(addsuffix .o, $(UNITS)))
 
 GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \
@@ -39,10 +39,12 @@
 example_program : libcarfac
 	# likely some example executable that runs the whole thing...
 
-unittest: CARFAC_unittest AGC_unittest
+unittest: $(foreach unit, $(UNITS), $(addsuffix _unittest, $(unit)))
 	$(foreach binary, $^, ./$(addsuffix $(EXE_EXTENSION), $(binary));)
 	
-CARFAC_unittest : $(SRC_TESTDIR)/CARFAC_unittest.o $(SRC_OBJ)
+CARFAC_unittest : $(SRC_OBJ)
+CAR_unittest : $(SRC_OBJ) #$(SRC_DIR)/unit_conversion.o
+Ear_unittest : $(SRC_OBJ)
 
 clean :
 	rm -f *.o *.a src/*.o unittest/*.o *_unittest* *.dll *.exe
--- a/branches/carfac_cpp/src/CAR.cpp	Thu Oct 11 20:55:03 2012 +0000
+++ b/branches/carfac_cpp/src/CAR.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -2,6 +2,7 @@
 #include "CARFAC_common.h"
 #include "CARFAC.h"
 #include <cmath>
+#include "unit_conversion.h"
 
 CAR_parameters::CAR_parameters():
 	  velocity_scale_(0.2),
@@ -49,7 +50,7 @@
       x = theta[i]/kPi;
       zr_coeffs_[i] = kPi * (x - ff * x*x*x);
 
-      min_zeta_mod = (car_params_p->min_zeta_ + 0.25 * (CARFAC::ERB_Hz(
+      min_zeta_mod = (car_params_p->min_zeta_ + 0.25 * (ERB_Hz(
                       pole_freqs[i], car_params_p->erb_break_freq_,
                       car_params_p->erb_q_) / pole_freqs[i]
                      - car_params_p->min_zeta_));
--- a/branches/carfac_cpp/src/CARFAC.cpp	Thu Oct 11 20:55:03 2012 +0000
+++ b/branches/carfac_cpp/src/CARFAC.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -5,7 +5,7 @@
 #include "IHC.h"
 #include "AGC.h"
 #include "Ear.h"
-
+#include "unit_conversion.h"
 #include "CARFAC_common.h"
 
 CARFAC::CARFAC(int fs,
@@ -30,7 +30,3 @@
   Ear ear = Ear(car_params, ihc_params, agc_params, pole_freqs_, n_ch_, fs);
   ears_.assign(n_ears_, ear);
 }
-
-float CARFAC::ERB_Hz(float cf_hz, float erb_break_freq, float erb_q){
-  return (erb_break_freq + cf_hz) / erb_q;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/branches/carfac_cpp/src/unit_conversion.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -0,0 +1,5 @@
+#include "unit_conversion.h"
+
+float ERB_Hz(float cf_hz, float erb_break_freq, float erb_q){
+  return (erb_break_freq + cf_hz) / erb_q;
+}
--- a/branches/carfac_cpp/unittest/AGC_unittest.cpp	Thu Oct 11 20:55:03 2012 +0000
+++ b/branches/carfac_cpp/unittest/AGC_unittest.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -1,4 +1,7 @@
+#include "CARFAC_common.h"
 #include "AGC.h"
 #include "gtest/gtest.h"
 
 // Do tests here
+TEST(AGCDesignTest, Stub) {
+}
--- a/branches/carfac_cpp/unittest/CARFAC_unittest.cpp	Thu Oct 11 20:55:03 2012 +0000
+++ b/branches/carfac_cpp/unittest/CARFAC_unittest.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -21,9 +21,7 @@
   IHC_parameters ihc_params = IHC_parameters();
   AGC_parameters agc_params = AGC_parameters();
 
-  int fs = kDefaultFs;
-
-  CARFAC fooCarfac = CARFAC(fs, &car_params, &ihc_params, &agc_params, 2);
+  CARFAC fooCarfac = CARFAC(kDefaultFs, &car_params, &ihc_params, &agc_params, 2);
   EXPECT_EQ(fooCarfac.n_ears_, fooCarfac.ears_.size());
 }
 
@@ -32,12 +30,10 @@
   IHC_parameters ihc_params = IHC_parameters();
   AGC_parameters agc_params = AGC_parameters();
 
-  int fs = kDefaultFs;
-
   car_params.erb_per_step_ = 2*0.5; //not sure if this is the best way to design this test... I'm just doing _something_ here.
   float expected_max_channels_per_octave = 10.56/2;
   float tolerance = 0.25;
 
-  CARFAC fooCarfac = CARFAC(fs, &car_params, &ihc_params, &agc_params, 1);
+  CARFAC fooCarfac = CARFAC(kDefaultFs, &car_params, &ihc_params, &agc_params, 1);
   ASSERT_NEAR(fooCarfac.max_channels_per_octave_, expected_max_channels_per_octave, tolerance);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/branches/carfac_cpp/unittest/CAR_unittest.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -0,0 +1,7 @@
+#include "CARFAC_common.h"
+#include "CAR.h"
+#include "gtest/gtest.h"
+
+// Do tests here
+TEST(CARDesignTest, Stub) {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/branches/carfac_cpp/unittest/Ear_unittest.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -0,0 +1,7 @@
+#include "CARFAC_common.h"
+#include "Ear.h"
+#include "gtest/gtest.h"
+
+// Do tests here
+TEST(EarDesignTest, Stub) {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/branches/carfac_cpp/unittest/IHC_unittest.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -0,0 +1,7 @@
+#include "CARFAC_common.h"
+#include "IHC.h"
+#include "gtest/gtest.h"
+
+// Do tests here
+TEST(IHCDesignTest, Stub) {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/branches/carfac_cpp/unittest/unit_conversion_unittest.cpp	Thu Oct 11 21:28:34 2012 +0000
@@ -0,0 +1,6 @@
+#include "unit_conversion.h"
+#include "gtest/gtest.h"
+
+// Do tests here
+TEST(ERBHz, Stub) {
+}