Mercurial > hg > ambi-plugin
view Unit Testing/SoundFieldUnitTest/main.cpp @ 0:2fa9c10568d1
Initial setup.
author | martinm_home <martin.morrell@eecs.qmul.ac.uk> |
---|---|
date | Tue, 14 Aug 2012 09:34:15 +0100 |
parents | |
children |
line wrap: on
line source
#include <iostream> #include "Decoder.h" #include <cmath> using namespace std; int main (int argc, char * const argv[]) { string answer; int test_choice; do{ double azimuth, elevation; Decoder myDecoder; cout << "Provide Azimuth then Elevation\n"; cin >> azimuth >> elevation; double w_in = 1/sqrt(2); double x_in = cos(myDecoder.degRad(azimuth)) * cos(myDecoder.degRad(elevation)); double y_in = sin(myDecoder.degRad(azimuth)) * cos(myDecoder.degRad(elevation)); double z_in = sin(myDecoder.degRad(elevation)); cout << endl << "w_in = " << w_in << endl; cout << "x_in = " << x_in << endl; cout << "y_in = " << y_in << endl; cout << "z_in = " << z_in << endl << endl; cout << "Selection\n 1=Rotation\n 2=Tilt\n 3=Tumble\n 4=Dominance\n 5=Press\n 6=Push\n 7=Focus\n 8=xyDecode\n 9=msDecode\n"; cin >> test_choice; switch (test_choice) { case 1: //Test Rotation cout << "Enter rotation in degrees:\n"; cin >> myDecoder.Rotate; myDecoder.rotateField(x_in, y_in); break; case 2: //Test Tilt cout << "Enter tilt in degrees:\n"; cin >> myDecoder.Tilt; myDecoder.tiltField(y_in, z_in); break; case 3: //Test Tumble cout << "Enter tumble in degrees:\n"; cin >> myDecoder.Tumble; myDecoder.tumbleField(x_in, z_in); break; case 4: //Test Tumble cout << "Enter Zoom factor, -100 to 100:\n"; cin >> myDecoder.Zoom; myDecoder.dominanceZoom(w_in, x_in, y_in, z_in); break; case 5: //Test Press cout << "Enter Zoom factor, -100 to 100:\n"; cin >> myDecoder.Zoom; myDecoder.pressZoom(w_in, x_in, y_in, z_in); break; case 6: //Test Push cout << "Enter Zoom factor, -100 to 100:\n"; cin >> myDecoder.Zoom; myDecoder.pushZoom(w_in, x_in, y_in, z_in); break; case 7: //Test Focus cout << "Enter Zoom factor, -100 to 100:\n"; cin >> myDecoder.Zoom; myDecoder.focusZoom(w_in, x_in, y_in, z_in); break; case 8: //Stereo Decode XY cout << "Enter Width and Pattern\n"; cin >> myDecoder.Width >> myDecoder.Pattern; myDecoder.xyDecode(w_in, x_in, y_in, z_in); break; case 9: //Stereo Decode MS cout << "Enter Width and Pattern\n"; cin >> myDecoder.Width >> myDecoder.Pattern; myDecoder.msDecode(w_in, x_in, y_in, z_in); break; default: break; } cout << endl << "w new = " << w_in << endl; cout << "x new = " << x_in << endl; cout << "y new = " << y_in << endl; cout << "z new = " << z_in << endl; double azimuth_out = atan2(y_in, x_in); double elevation_out = atan2(z_in, sqrt(pow(x_in,2) + pow(y_in,2))); cout << endl << "Calculate azimuth = " << myDecoder.radDeg(azimuth_out) <<endl; cout << "Calculate elevation = " << myDecoder.radDeg(elevation_out) <<endl; if (test_choice==8 || test_choice==9) { cout << endl << "Output Left = " << myDecoder.outputL; cout << endl << "Output Right = " << myDecoder.outputR <<endl; } cout << endl << "Repeat? y for yes.\n"; cin >> answer; cout << endl; } while(answer == "y"); return 0; }