Mercurial > hg > human-echolocation-java-webapp
changeset 11:2129d2bac6cb
working on the servlet: calling the simulateBinauralSignals function on the doGet method.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 29 Nov 2013 15:48:07 +0000 |
parents | dd2c566cdaf9 |
children | 594fcd75a5ed |
files | webapp/WEB-INF/src/HumanEchoServlet.java |
diffstat | 1 files changed, 29 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/webapp/WEB-INF/src/HumanEchoServlet.java Fri Nov 29 15:47:15 2013 +0000 +++ b/webapp/WEB-INF/src/HumanEchoServlet.java Fri Nov 29 15:48:07 2013 +0000 @@ -4,10 +4,12 @@ import javax.servlet.ServletException; import javax.servlet.ServletConfig; import java.io.IOException; + import uk.ac.soton.isvr.*; import com.mathworks.toolbox.javabuilder.MWJavaObjectRef; import com.mathworks.toolbox.javabuilder.MWNumericArray; +import com.mathworks.toolbox.javabuilder.MWStructArray; import com.mathworks.toolbox.javabuilder.MWException; public class HumanEchoServlet extends HttpServlet { @@ -32,28 +34,43 @@ } } + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - // Test parameter - MWNumericArray test = new MWNumericArray(Integer.parseInt(request.getParameter("test"))); + // todo: validate/normalise distance + int dist = Integer.parseInt(request.getParameter("dist")); + MWStructArray Input = null; + HumanEcho echo; - double[][] square = new double[0][]; + try { + echo = new HumanEcho(); - // double[][] square = new double[0][]; - // WebFigure figure = null; -/* - try { - // refers to the mcode function gen_echo.m - Object[] result = echo.gen_echo(1, test); + // Matlab structure: + // Input = struct('dist', 0.9, 'azim', 0, 'orient', 'horz', 'dirweight', 0.2, 'outputfname', 'foo.wav') - MWNumericArray array = (MWNumericArray)result[0]; - square = (double[][])array.toArray(); + String[] InputStructFields = {"dist", "azim", "orient", "dirweight", "outputfname"}; + Input = new MWStructArray(1, 1, InputStructFields); + Input.set("dist", 1, Double.valueOf(dist)); + Input.set("azim", 1, Double.valueOf(0)); + Input.set("orient", 1, "horz"); + Input.set("dirweight", 1, Double.valueOf(0.2)); + // the ofname should depend on the parameters + StringBuilder sb = new StringBuilder(); + sb.append("e_d"); + sb.append(dist); + sb.append(".wav"); + String outputfname = sb.toString(); + + Input.set("outputfname", 1, outputfname); + + // todo: before calling should test if wav already exists.. + Object[] result = echo.simulateBinauralSignals(Input); } catch(MWException e) { e.printStackTrace(); } + /* StringBuffer buffer = new StringBuffer(); buffer.append("<BR>");