4444#include " apf/cxx_thread_policy.h"
4545#include " loudspeakerrenderer.h"
4646
47- #include " ../src/source .h"
47+ #include " ../src/legacy_source .h"
4848
4949template <typename Renderer>
5050class SsrMex
@@ -208,6 +208,7 @@ class SsrMex
208208
209209 _out_channels = _engine->get_output_list ().size ();
210210
211+ assert (_source_ids.size () == 0 );
211212 for (mwSize i = 0 ; i < _in_channels; ++i)
212213 {
213214 apf::parameter_map source_params;
@@ -216,8 +217,7 @@ class SsrMex
216217 {
217218 source_params.set (" properties_file" , filename_list[i]);
218219 }
219- // TODO: specify ID?
220- _engine->add_source (source_params);
220+ _source_ids.push_back (_engine->add_source (" " , source_params));
221221 }
222222
223223 _inputs.resize (_in_channels);
@@ -367,7 +367,7 @@ class SsrMex
367367 APF_MEX_ERROR_NO_FURTHER_INPUTS (command);
368368 APF_MEX_ERROR_ONE_OPTIONAL_OUTPUT (command);
369369
370- std::vector<Loudspeaker > ls_list;
370+ std::vector<LegacyLoudspeaker > ls_list;
371371 _engine->get_loudspeakers (ls_list);
372372
373373 if (command == " loudspeaker_position" )
@@ -395,6 +395,16 @@ class SsrMex
395395 }
396396 }
397397
398+ // zero-based index
399+ std::string _get_source_id (mwSize index)
400+ {
401+ if (index < 0 || static_cast <mwSize>(_source_ids.size ()) <= index)
402+ {
403+ return {};
404+ }
405+ return _source_ids[index];
406+ }
407+
398408 void _source_position (int & nrhs, const mxArray**& prhs)
399409 {
400410 APF_MEX_ERROR_FURTHER_INPUT_NEEDED (" 'source_position'" );
@@ -419,7 +429,7 @@ class SsrMex
419429 {
420430 // TODO: handle 3D coordinates
421431
422- auto * source = _engine->get_source (i + 1 );
432+ auto * source = _engine->get_source (_get_source_id (i) );
423433 // TODO: check if source == nullptr
424434 source->position = Position (coordinates[i*2 ], coordinates[i*2 +1 ]);
425435 }
@@ -443,7 +453,7 @@ class SsrMex
443453
444454 for (mwSize i = 0 ; i < _in_channels; ++i)
445455 {
446- auto * source = _engine->get_source (i + 1 );
456+ auto * source = _engine->get_source (_get_source_id (i) );
447457 // TODO: check if source == nullptr
448458 source->orientation = Orientation (angles[i]); // degree
449459 }
@@ -470,7 +480,7 @@ class SsrMex
470480
471481 for (mwSize i = 0 ; i < _in_channels; ++i)
472482 {
473- auto * source = _engine->get_source (i + 1 );
483+ auto * source = _engine->get_source (_get_source_id (i) );
474484 source->mute = mute[i]; // logical
475485 }
476486 }
@@ -493,13 +503,14 @@ class SsrMex
493503
494504 for (int i = 0 ; i < _in_channels; ++i)
495505 {
496- Source ::model_t model = Source ::unknown;
506+ LegacySource ::model_t model = LegacySource ::unknown;
497507 if (!apf::str::S2A (model_list[i], model))
498508 {
499509 mexPrintf (" Model string '%s':" , model_list[i].c_str ());
500510 mexErrMsgTxt (" Couldn't convert source model string!" );
501511 }
502- _engine->get_source (i + 1 )->model = model;
512+ _engine->get_source (_get_source_id (i))->model
513+ = model == LegacySource::plane ? " plane" : " point" ;
503514 }
504515 }
505516
@@ -549,6 +560,7 @@ class SsrMex
549560 std::unique_ptr<Renderer> _engine;
550561 mwSize _in_channels, _out_channels, _block_size;
551562 std::vector<sample_type*> _inputs, _outputs;
563+ std::vector<std::string> _source_ids;
552564};
553565
554566#endif
0 commit comments