TWOEARS / binaural-simulator

Two!Ears Auditory Model - Binaural simulator module
http://docs.twoears.eu/en/latest/binsim/
GNU General Public License v2.0
27 stars 3 forks source link

PORT: Running two Binaural Simulators simultaneously #3

Closed fietew closed 8 years ago

fietew commented 8 years ago

We had this discussion before, but I can't remember where exactly, so here again ;) I have an example of running two Binaural Simulators after each other. This is in the @train_localisation_model@ directory of the @twoears-examples@ repo. There everything runs fine if you do the following:

>> train;
>> localise

------------------------------------------------------------------
Source direction        Model w QU HRTF       Model w MIT HRTF
------------------------------------------------------------------
   0                 0               NaN
  88                88                90
 175               175               175
-103              -103              -105
------------------------------------------------------------------

Ignore the @NaN@.

Then switch to the @twoBinSims@ branch of the same repo. Now rerun:

% You can skip the training, because you did it above
>> localise

------------------------------------------------------------------
Source direction        Model w QU HRTF       Model w MIT HRTF
------------------------------------------------------------------
   0              -179               NaN
  88                86                90
 175               177               175
-103              -101              -105
------------------------------------------------------------------

As you can see, now we have also localisation errors for the QU HRTF, which was not the case above. But I case the problem is that I'm running two Binaural Simulators at the same time which was not possible if I remeber correctly. Here is some code from @localise.m@:

simQu = simulator.SimulatorConvexRoom('SceneDescriptionQU.xml');
% [...]
simMit = simulator.SimulatorConvexRoom('SceneDescriptionMIT.xml');
% [..]
bbs.setRobotConnect(simQu);
% [..]
bbs.setRobotConnect(simMit);

So, my question is: is it possible to run two Binaural Simulators simultaneously and if not, what do we have to do in order to get this happen?

fietew commented 8 years ago

Since both simulator objects are using the same *.mex file, namely ssr_binaural, they access the same rendering core. One way to handle multiple simulators is to copy the ssr_binaural.mex and rename it, e.g. ssr_binaural_alt.mex. Then set simMit.Renderer = ssr_binaural_alt.

fietew commented 8 years ago

As this is not so elegant from a user point of view it would be nice to have some alternatives. Lets start a list with ideas:

  1. Is there a possibility to got the mex file directly work with multiple simulator objects? What is the limiting factor?
  2. We could add the possibility that ssr_binaural.mex is never called directly, but everytime a tmp mex file is created and .Renderer or another hidden flag set automatically to that file
hagenw commented 8 years ago

In the implementation for the ColorationKS I came up with another simple solution: assume you have to signals you want to compare. Then first listen to the first signal and store the features to compare in the blackboard memory. After that listen to the second signal and compare the features to the stored one.

I think this is more elegant as it it mimics a little bit more human behavior. I'm not sure if there will be another application where we really need two simultaneously running binaural simulators, but from my point of view you can close this issue.

fietew commented 8 years ago

I'm happy!