comparison src/HumanEchoServlet.java @ 47:398a53b30079

Fixes to struct fields
author Chris Cannam
date Fri, 28 Feb 2014 15:37:02 +0000
parents 84d02afe28e6
children ebfb3b91fb06
comparison
equal deleted inserted replaced
46:84d02afe28e6 47:398a53b30079
77 } 77 }
78 } 78 }
79 79
80 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 80 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
81 81
82 System.err.println("In doGet");
83
82 // todo: validate/normalise distance 84 // todo: validate/normalise distance
83 int dist = Integer.parseInt(request.getParameter("dist")); 85 int dist = Integer.parseInt(request.getParameter("dist"));
84 86
85 logger.info("String azim is: " + request.getParameter("azim")); 87 logger.info("String azim is: " + request.getParameter("azim"));
86 Float azim = Float.parseFloat(request.getParameter("azim")); 88 Float azim = Float.parseFloat(request.getParameter("azim"));
88 MWStructArray Input = null; 90 MWStructArray Input = null;
89 HumanEcho echo; 91 HumanEcho echo;
90 92
91 String outputfname = new String(); 93 String outputfname = new String();
92 94
93 System.err.println("In doGet"); 95 System.err.println("Got dist and azim");
94 96
95 try { 97 try {
96 //!!! erch, shouldn't be creating a new one on each request as well as a global one 98 //!!! erch, shouldn't be creating a new one on each request as well as a global one
97 echo = new HumanEcho(); 99 echo = new HumanEcho();
98 100
101 103
102 System.err.println("Done some logging"); 104 System.err.println("Done some logging");
103 System.err.println(System.getProperty("catalina.base")); 105 System.err.println(System.getProperty("catalina.base"));
104 106
105 // Matlab structure: 107 // Matlab structure:
106 // Input = struct('dist', 0.9, 'azim', 0, 'orient', 'horz', 'dirweight', 0.2, 'outputfname', 'foo.wav') 108 // Input = struct('dist', 0.9, 'azim', 0, 'orient', 'horz', 'dirweight', 0.2, 'outdir', '/tmp/wav', 'outname', 'foo.wav')
107 109
108 String[] InputStructFields = {"dist", "azim", "orient", "dirweight", "outputfname"}; 110 String[] InputStructFields = {"dist", "azim", "orient", "dirweight", "outdir", "outname"};
111
109 Input = new MWStructArray(1, 1, InputStructFields); 112 Input = new MWStructArray(1, 1, InputStructFields);
110 Input.set("dist", 1, Double.valueOf(dist)); 113 Input.set("dist", 1, Double.valueOf(dist));
111 Input.set("azim", 1, Double.valueOf(azim)); 114 Input.set("azim", 1, Double.valueOf(azim));
112 Input.set("orient", 1, "horz"); 115 Input.set("orient", 1, "horz");
113 Input.set("dirweight", 1, Double.valueOf(0.2)); 116 Input.set("dirweight", 1, Double.valueOf(0.2));
114
115 Input.set("outdir", 1, wavdir); 117 Input.set("outdir", 1, wavdir);
116 118
117 // the ofname should depend on the parameters 119 // the ofname should depend on the parameters
118 StringBuilder sb = new StringBuilder(); 120 StringBuilder sb = new StringBuilder();
119 sb.append("e_d"); 121 sb.append("e_d");