Control * Runner::create_control( const std::string & control_path ) { if (isRunning()) { MRSERR("Marsyas::Thread::System:: can not start tracking controls while running."); return 0; } Marsyas::MarControlPtr sys_control = m_system->getControl( control_path ); if (sys_control.isInvalid()) { MRSERR("Marsyas::Thread::System:: Can not track control - invalid path: " << control_path); return 0; } AtomicControl *atomic_control; std::string sys_control_type = sys_control->getType(); if(sys_control_type == "mrs_bool") atomic_control = new AtomicControlT<bool>(sys_control); else if(sys_control_type == "mrs_real") atomic_control = new AtomicControlT<mrs_real>(sys_control); else if(sys_control_type == "mrs_natural") atomic_control = new AtomicControlT<mrs_natural>(sys_control); else if(sys_control_type == "mrs_string") atomic_control = new AtomicControlT<mrs_string>(sys_control); else if(sys_control_type == "mrs_realvec") atomic_control = new AtomicControlT<mrs_realvec>(sys_control); else { MRSERR( "Marsyas::Thread::System:: Can not track control - unsupported type: " << sys_control_type.c_str() ); return 0; } Control * control = new Control(this, control_path, atomic_control); m_shared->controls.insert(std::pair<std::string, Control*>(control_path, control)); return control; }
mrs_real TranscriberExtract::addFileSource(MarSystem* net, const std::string infile) { if (infile == EMPTYSTRING) { MRSERR("Please specify a sound file."); return 0; } net->addMarSystem(mng.create("SoundFileSource", "src")); net->updControl("SoundFileSource/src/mrs_string/filename", infile); net->linkControl("mrs_bool/hasData", "SoundFileSource/src/mrs_bool/hasData"); return net->getctrl("SoundFileSource/src/mrs_real/osrate")->to<mrs_real>(); }
static any get_control_value( const MarControlPtr & control ) { std::string control_type = control->getType(); if(control_type == "mrs_bool") return any( control->to<bool>() ); else if(control_type == "mrs_real") return any( control->to<mrs_real>() ); else if(control_type == "mrs_natural") return any( control->to<mrs_natural>() ); else if(control_type == "mrs_string") return any( control->to<mrs_string>() ); else if(control_type == "mrs_realvec") return any( control->to<mrs_realvec>() ); else { MRSERR( "Marsyas::Thread::System:: Can not get control value - unsupported type: " << control_type.c_str() ); return any(); } }
static void set_control_value( MarControlPtr & control, const any & value, bool update = true ) { std::string control_type = control->getType(); if(control_type == "mrs_bool") set_control_value<bool>(control, value, update); else if(control_type == "mrs_real") set_control_value<mrs_real>(control, value, update); else if(control_type == "mrs_natural") set_control_value<mrs_natural>(control, value, update); else if(control_type == "mrs_string") set_control_value<mrs_string>(control, value, update); else if(control_type == "mrs_realvec") set_control_value<mrs_realvec>(control, value, update); else { MRSERR( "Marsyas::Thread::System:: Can not set control value - unsupported type: " << control_type.c_str() ); return; } }