Пример #1
0
/*
 * Setup sizes of the various vectors.
 */
static void mdlInitializeSizes (SimStruct *S)
{
	/* Количество параметров. */
	ssSetNumSFcnParams (S, 0);
	if (ssGetNumSFcnParams (S) != ssGetSFcnParamsCount (S)) {
		/* Simulink сообщит о несоответствии параметров */
		return;
	}

	ssSetNumContStates (S, 0);
	ssSetNumDiscStates (S, 0);

	/*
	 * Входы.
	 */
	if (! ssSetNumInputPorts (S, 4))
		return;
	set_input_port (S, 0, SS_BOOLEAN);	/* rn0 */
	set_input_port (S, 1, SS_BOOLEAN);	/* rn1 */
	set_input_port (S, 2, SS_BOOLEAN);	/* rn2 */
	set_input_port (S, 3, SS_BOOLEAN);	/* rn3 */

	/*
	 * Выходы.
	 */
	if (! ssSetNumOutputPorts (S, 1))
		return;
	set_output_port (S, 0, SS_BOOLEAN);	/* tx */

	ssSetNumSampleTimes (S, 1);
	ssSetNumRWork (S, 0);
	ssSetNumIWork (S, 0);
	ssSetNumPWork (S, 1);
	ssSetNumModes (S, 0);
	ssSetNumNonsampledZCs (S, 0);

	/* Take care when specifying exception free code - see sfuntmpl_doc.c */
	ssSetOptions (S, SS_OPTION_EXCEPTION_FREE_CODE |
			 SS_OPTION_USE_TLC_WITH_ACCELERATOR |
			 SS_OPTION_WORKS_WITH_CODE_REUSE |
			 SS_OPTION_DISCRETE_VALUED_OUTPUT);
}
Пример #2
0
void Mixer_Strip::set_nb_channel(int _nb_channel)
{
  int result = 0, i = 0;
  std::stringstream port_name;
  jack_port_t *tmp_port_out = NULL, *tmp_port_in = NULL;

  if (nb_channel==_nb_channel) return;

  nb_channel = _nb_channel;
  input_port.resize(nb_channel, NULL);
  output_port.resize(nb_channel, NULL);
  rms_level.resize(nb_channel, 0.0);
  max_level.resize(nb_channel, 0.0);

  if (nb_channel==1) 
    {
      type = mono;
      typeLabel->setText(tr("mono"));

      for(i=0; i<input_port.size(); i++)
	{
	  result = jack_port_unregister(client, input_port[i]);
	  if (result)
	    std::cerr << qPrintable(tr("QTJMix: problem while unregistering the input port of the mixer strip ")) << i << "." << std::endl;
	  
	  result = jack_port_unregister(client, output_port[i]);
	  if (result)
	    std::cerr << qPrintable(tr("QTJMix: problem while unregistering the output port of the mixer strip ")) << i << "." << std::endl;
	}
      
      input_port.resize(1, NULL);
      output_port.resize(1, NULL);
      
      // Create input port
      port_name.str("");
      port_name << "mixer_" << strip_id << "_m_in";
#ifdef ENABLE_JACK
      tmp_port_in = jack_port_register(client, port_name.str().c_str(),
				       JACK_DEFAULT_AUDIO_TYPE,
				       JackPortIsInput, 0);
#endif
      
      // Create output port
      port_name.str("");
      port_name << "mixer_" << strip_id << "_m_out";
#ifdef ENABLE_JACK
      tmp_port_out = jack_port_register(client, port_name.str().c_str(),
					JACK_DEFAULT_AUDIO_TYPE,
					JackPortIsOutput, 0);
#endif

#ifdef ENABLE_JACK
      if ((tmp_port_in == NULL) || (tmp_port_out == NULL))
	{
          std::cerr << qPrintable(tr("no more JACK ports available")) << std::endl;
	  exit (1);
        }
#endif
      
      set_input_port(0, tmp_port_in);
      set_output_port(0, tmp_port_out);
      rms_level.resize(1, 0.0);
      rms_level_n_1.resize(1, 0.0);
      max_level.resize(1, 0.0);
      max_level_n_1.resize(1, 0.0);
      panDial->setEnabled(false);
    }
  else
    {
      type = stereo;
      typeLabel->setText(tr("stereo"));

      for(i=0; i<input_port.size(); i++)
	{
	  result = jack_port_unregister(client, input_port[i]);
	  if (result)
	    std::cerr << qPrintable(tr("QTJMix: problem while unregistering the input port of the mixer strip ")) << i << "." << std::endl;
	  
	  result = jack_port_unregister(client, output_port[i]);
	  if (result)
	    std::cerr << qPrintable(tr("QTJMix: problem while unregistering the output port of the mixer strip ")) << i << "." << std::endl;
	}
      
      input_port.resize(2, NULL);
      output_port.resize(2, NULL);

      // Create left input port
      port_name.str("");
      port_name << "mixer_" << strip_id << "_l_in";
#ifdef ENABLE_JACK
      tmp_port_in = jack_port_register(client, port_name.str().c_str(),
				       JACK_DEFAULT_AUDIO_TYPE,
				       JackPortIsInput, 0);
#endif
      
      // Create left output port
      port_name.str("");
      port_name << "mixer_" << strip_id << "_l_out" << strip_id;
#ifdef ENABLE_JACK
      tmp_port_out = jack_port_register(client, port_name.str().c_str(),
					JACK_DEFAULT_AUDIO_TYPE,
					JackPortIsOutput, 0);
#endif

#ifdef ENABLE_JACK
      if ((tmp_port_in == NULL) || (tmp_port_out == NULL))
	{
          std::cerr << qPrintable(tr("no more JACK ports available")) << std::endl;
	  exit (1);
        }
#endif
      
      set_input_port(0, tmp_port_in);
      set_output_port(0, tmp_port_out);

      // Create right input port
      port_name.str("");
      port_name << "mixer_" << strip_id << "_r_in";
#ifdef ENABLE_JACK
      tmp_port_in = jack_port_register(client, port_name.str().c_str(),
				       JACK_DEFAULT_AUDIO_TYPE,
				       JackPortIsInput, 0);
#endif
      
      // Create right output port
      port_name.str("");
      port_name << "mixer_" << strip_id << "_r_out";
#ifdef ENABLE_JACK
      tmp_port_out = jack_port_register(client, port_name.str().c_str(),
					JACK_DEFAULT_AUDIO_TYPE,
					JackPortIsOutput, 0);
#endif

#ifdef ENABLE_JACK
      if ((tmp_port_in == NULL) || (tmp_port_out == NULL))
	{
          std::cerr << qPrintable(tr("no more JACK ports available")) << std::endl;
	  exit (1);
        }
#endif
      
      set_input_port(1, tmp_port_in);
      set_output_port(1, tmp_port_out);

      rms_level.resize(2, 0.0);
      rms_level_n_1.resize(2, 0.0);
      max_level.resize(2, 0.0);
      max_level_n_1.resize(2, 0.0);
      panDial->setEnabled(true);
    }
}