Ejemplo n.º 1
0
EFFECT_LV2* EFFECT_LV2::clone(void) const
{
  EFFECT_LV2* result = new EFFECT_LV2(plugin_desc);
  for(int n = 0; n < number_of_params(); n++) {
    result->set_parameter(n + 1, get_parameter(n + 1));
  }
  return result;
}
Ejemplo n.º 2
0
void EFFECT_BASE::set_samples_per_second(SAMPLE_SPECS::sample_rate_t new_rate)
{
  ECA_LOG_MSG(ECA_LOGGER::user_objects,
	      "Setting samplerate to " +
	      kvu_numtostr(new_rate) + " for object " +
	      name() + ". Old value " +
	      kvu_numtostr(samples_per_second()) + ".");

  /* note: changing the sample rate might change values of
   *       of parameters, so we want to preserve the values */

  if (samples_per_second() != new_rate) {
    std::vector<parameter_t> old_values (number_of_params());
    for(int n = 0; n < number_of_params(); n++) {
      old_values[n] = get_parameter(n + 1);
    }
    
    ECA_SAMPLERATE_AWARE::set_samples_per_second(new_rate);

    for(int n = 0; n < number_of_params(); n++) {
      set_parameter(n + 1, old_values[n]);
    }
  }
}
Ejemplo n.º 3
0
CGBIO_ERROR nvb_reader_impl::get_param_name( unsigned int index, const char **name, bool& is_referenced ) const
{
	if ( index >= number_of_params() )
		return CGBIO_ERROR_INDEX;

	if ( 0 == image_ )
		return CGBIO_ERROR_NO_ERROR;

	const CgBinaryParameter* params = reinterpret_cast<CgBinaryParameter*>( &image_[convert_endianness( header_.parameterArray, endianness_ )] );
	const CgBinaryParameter& pp = params[index];
    is_referenced = convert_endianness( pp.isReferenced, endianness() ) != 0;
	CgBinaryStringOffset nm_offset = convert_endianness( pp.name,endianness() );
	if ( nm_offset != 0 )
		*name = &image_[nm_offset];
	else
		*name = "";
	return CGBIO_ERROR_NO_ERROR;
}
Ejemplo n.º 4
0
CGBIO_ERROR
nvb_reader_impl::get_param( unsigned int index,
			    	 CGtype& type,
			     CGresource& resource,
				 CGenum& variability,
				    int& resource_index,
				 const char ** name,
		     STL_NAMESPACE vector<float>& default_value,
	      STL_NAMESPACE vector<unsigned int>& embedded_constants,
				 const char ** semantic,
				    int& paramno,
				   bool& is_referenced,
				   bool& is_shared ) const
{
    if ( index >= number_of_params() )
	return CGBIO_ERROR_INDEX;

    if ( 0 == image_ )
	return CGBIO_ERROR_NO_ERROR;

    const CgBinaryParameter* params = reinterpret_cast<CgBinaryParameter*>( &image_[convert_endianness( header_.parameterArray, endianness_ )] );
    const CgBinaryParameter& pp = params[index];
    type		= static_cast<CGtype>(convert_endianness( static_cast<unsigned int>( pp.type ),	endianness() ) );
    resource		= static_cast<CGresource>(convert_endianness( static_cast<unsigned int>( pp.res ), endianness() ) );
    variability		= static_cast<CGenum>(convert_endianness( static_cast<unsigned int>( pp.var ),endianness() ) );
    resource_index	= convert_endianness( pp.resIndex,endianness() );
    paramno		= convert_endianness( pp.paramno, endianness() );
    is_referenced	= convert_endianness( pp.isReferenced,endianness() ) != 0;
    is_shared		= convert_endianness( pp.isShared,endianness() ) != 0;
    CgBinaryStringOffset		nm_offset =	convert_endianness( pp.name,endianness() );
    CgBinaryFloatOffset			dv_offset =	convert_endianness( pp.defaultValue,endianness() );
    CgBinaryEmbeddedConstantOffset	ec_offset =	convert_endianness( pp.embeddedConst,endianness() );
    CgBinaryStringOffset		sm_offset =	convert_endianness( pp.semantic,endianness() );
    if ( 0 != nm_offset )
    {
		*name = &image_[nm_offset];
    }
	else
		*name = "";

    if ( 0 != sm_offset )
    {
		*semantic = &image_[sm_offset];
    }
	else
		*semantic = "";
    if ( 0 != dv_offset )
    {
	char *vp = &image_[dv_offset];
	for (int ii = 0; ii < 4; ++ii)
	{
		int tmp;
		memcpy(&tmp,vp+4*ii,4);
		tmp = convert_endianness(tmp,endianness());
		float tmp2;
		memcpy(&tmp2,&tmp,4);
		default_value.push_back( tmp2 );
	}
    }
    if ( 0 != ec_offset )
    {
	void *vp = &image_[ec_offset];
	CgBinaryEmbeddedConstant& ec = *(static_cast<CgBinaryEmbeddedConstant*>( vp ));
	for (unsigned int ii = 0; ii < convert_endianness( ec.ucodeCount, endianness() ); ++ii)
	{
	    unsigned int offset = convert_endianness( ec.ucodeOffset[ii], endianness() );
	    embedded_constants.push_back( offset );
	}
    }
    return CGBIO_ERROR_NO_ERROR;
}