コード例 #1
0
ファイル: vst.c プロジェクト: BackupTheBerlios/galan
PRIVATE LADSPA_Data get_default( ControlDescriptor *control, LADSPA_PortRangeHintDescriptor hint ) {

    if( LADSPA_IS_HINT_HAS_DEFAULT( hint ) ) {

	if( LADSPA_IS_HINT_DEFAULT_MINIMUM( hint ) )
	    return control->min;
	if( LADSPA_IS_HINT_DEFAULT_LOW( hint ) )
	    return control->min * 0.75 + control->max * 0.25;
	if( LADSPA_IS_HINT_DEFAULT_MIDDLE( hint ) )
	    return control->min * 0.5 + control->max * 0.5;
	if( LADSPA_IS_HINT_DEFAULT_HIGH( hint ) )
	    return control->min * 0.25 + control->max * 0.75;
	if( LADSPA_IS_HINT_DEFAULT_MAXIMUM( hint ) )
	    return control->max;
	if( LADSPA_IS_HINT_DEFAULT_0( hint ) )
	    return 0.0;
	if( LADSPA_IS_HINT_DEFAULT_1( hint ) )
	    return 1.0;
	if( LADSPA_IS_HINT_DEFAULT_100( hint ) )
	    return 100.0;
	if( LADSPA_IS_HINT_DEFAULT_440( hint ) )
	    return 440.0;

	printf( "plugins says it has default... but i cant find out.\n" );
	return 0.0;

    } else 
	return 0.0;

}
コード例 #2
0
ファイル: plugin.c プロジェクト: ivan-dives/audacious-plugins
static ControlData * parse_control (const LADSPA_Descriptor * desc, int port)
{
    g_return_val_if_fail (desc->PortNames[port], NULL);
    const LADSPA_PortRangeHint * hint = & desc->PortRangeHints[port];

    ControlData * control = g_slice_new (ControlData);
    control->port = port;
    control->name = g_strdup (desc->PortNames[port]);
    control->is_toggle = LADSPA_IS_HINT_TOGGLED (hint->HintDescriptor) ? 1 : 0;

    control->min = LADSPA_IS_HINT_BOUNDED_BELOW (hint->HintDescriptor) ? hint->LowerBound :
     LADSPA_IS_HINT_BOUNDED_ABOVE (hint->HintDescriptor) ? hint->UpperBound - 100 : -100;
    control->max = LADSPA_IS_HINT_BOUNDED_ABOVE (hint->HintDescriptor) ? hint->UpperBound :
     LADSPA_IS_HINT_BOUNDED_BELOW (hint->HintDescriptor) ? hint->LowerBound + 100 : 100;

    if (LADSPA_IS_HINT_SAMPLE_RATE (hint->HintDescriptor))
    {
        control->min *= 96000;
        control->max *= 96000;
    }

    if (LADSPA_IS_HINT_DEFAULT_0 (hint->HintDescriptor))
        control->def = 0;
    else if (LADSPA_IS_HINT_DEFAULT_1 (hint->HintDescriptor))
        control->def = 1;
    else if (LADSPA_IS_HINT_DEFAULT_100 (hint->HintDescriptor))
        control->def = 100;
    else if (LADSPA_IS_HINT_DEFAULT_440 (hint->HintDescriptor))
        control->def = 440;
    else if (LADSPA_IS_HINT_DEFAULT_MINIMUM (hint->HintDescriptor))
        control->def = control->min;
    else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (hint->HintDescriptor))
        control->def = control->max;
    else if (LADSPA_IS_HINT_DEFAULT_LOW (hint->HintDescriptor))
    {
        if (LADSPA_IS_HINT_LOGARITHMIC (hint->HintDescriptor))
            control->def = expf (0.75 * logf (control->min) + 0.25 * logf (control->max));
        else
            control->def = 0.75 * control->min + 0.25 * control->max;
    }
    else if (LADSPA_IS_HINT_DEFAULT_HIGH (hint->HintDescriptor))
    {
        if (LADSPA_IS_HINT_LOGARITHMIC (hint->HintDescriptor))
            control->def = expf (0.25 * logf (control->min) + 0.75 * logf (control->max));
        else
            control->def = 0.25 * control->min + 0.75 * control->max;
    }
    else
    {
        if (LADSPA_IS_HINT_LOGARITHMIC (hint->HintDescriptor))
            control->def = expf (0.5 * logf (control->min) + 0.5 * logf (control->max));
        else
            control->def = 0.5 * control->min + 0.5 * control->max;
    }

    return control;
}
コード例 #3
0
LADSPA_Data				WiredLADSPAInstance::GetDefaultValue(t_gui_port *GuiPort, LADSPA_PortRangeHintDescriptor Descriptor)
{
	if (LADSPA_IS_HINT_HAS_DEFAULT(Descriptor))
	{
		if(LADSPA_IS_HINT_DEFAULT_MINIMUM(Descriptor))
			return GuiPort->LowerBound;
		else if (LADSPA_IS_HINT_DEFAULT_LOW(Descriptor))
		{
			if (LADSPA_IS_HINT_LOGARITHMIC(Descriptor))
				return (LADSPA_Data) expf(logf(GuiPort->LowerBound) * 0.75 + logf(GuiPort->UpperBound) * 0.25);
			else
				return (LADSPA_Data) GuiPort->LowerBound * 0.75 + GuiPort->UpperBound * 0.25;
		}
		else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(Descriptor))
		{
			if (LADSPA_IS_HINT_LOGARITHMIC(Descriptor))
				return (LADSPA_Data) expf(logf(GuiPort->LowerBound) * 0.5 + logf(GuiPort->UpperBound) * 0.5);
			else
				return (LADSPA_Data) GuiPort->LowerBound * 0.5 + GuiPort->UpperBound * 0.5;
		}
		else if (LADSPA_IS_HINT_DEFAULT_HIGH(Descriptor))
		{
			if (LADSPA_IS_HINT_LOGARITHMIC(Descriptor))
				return (LADSPA_Data) expf(logf(GuiPort->LowerBound) * 0.25 + logf(GuiPort->UpperBound) * 0.75);
			else
				return (LADSPA_Data) GuiPort->LowerBound * 0.25 + GuiPort->UpperBound * 0.75;
		}
		else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(Descriptor))
			return GuiPort->UpperBound;
		else if (LADSPA_IS_HINT_DEFAULT_0(Descriptor))
			return 0.0f;
		else if (LADSPA_IS_HINT_DEFAULT_1(Descriptor))
			return 1.0f;
		else if (LADSPA_IS_HINT_DEFAULT_100(Descriptor))
			return 100.0f;
		else if (LADSPA_IS_HINT_DEFAULT_440(Descriptor))
			return 440.0f;
	}
	return GuiPort->LowerBound;
}
コード例 #4
0
ファイル: af_ladspa.c プロジェクト: Ancaro/stepmania
static void set_default_ctl_value(LADSPAContext *s, int ctl,
                                  unsigned long *map, LADSPA_Data *values)
{
    const LADSPA_PortRangeHint *h = s->desc->PortRangeHints + map[ctl];
    const LADSPA_Data lower = h->LowerBound;
    const LADSPA_Data upper = h->UpperBound;

    if (LADSPA_IS_HINT_DEFAULT_MINIMUM(h->HintDescriptor)) {
        values[ctl] = lower;
    } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(h->HintDescriptor)) {
        values[ctl] = upper;
    } else if (LADSPA_IS_HINT_DEFAULT_0(h->HintDescriptor)) {
        values[ctl] = 0.0;
    } else if (LADSPA_IS_HINT_DEFAULT_1(h->HintDescriptor)) {
        values[ctl] = 1.0;
    } else if (LADSPA_IS_HINT_DEFAULT_100(h->HintDescriptor)) {
        values[ctl] = 100.0;
    } else if (LADSPA_IS_HINT_DEFAULT_440(h->HintDescriptor)) {
        values[ctl] = 440.0;
    } else if (LADSPA_IS_HINT_DEFAULT_LOW(h->HintDescriptor)) {
        if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
            values[ctl] = exp(log(lower) * 0.75 + log(upper) * 0.25);
        else
            values[ctl] = lower * 0.75 + upper * 0.25;
    } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(h->HintDescriptor)) {
        if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
            values[ctl] = exp(log(lower) * 0.5 + log(upper) * 0.5);
        else
            values[ctl] = lower * 0.5 + upper * 0.5;
    } else if (LADSPA_IS_HINT_DEFAULT_HIGH(h->HintDescriptor)) {
        if (LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor))
            values[ctl] = exp(log(lower) * 0.25 + log(upper) * 0.75);
        else
            values[ctl] = lower * 0.25 + upper * 0.75;
    }
}
コード例 #5
0
/* initialize the ladspavidbodeshifter's class */
static void
gst_ladspa_vid_bodeshifter_class_init (GstLadspaVidBodeshifterClass * klass)
{
  GObjectClass *gobject_class;
  GstElementClass *gstelement_class;
  int i=0,param_index=0;
  char param_str[256];
  LADSPA_Data default_value;

  memset(&klass->plugin,0,sizeof(ladspa_plugin));
  printf("init plugin\n");

  ladspa_load_plugin("/usr/lib/ladspa/bode_shifter_1431.so",&klass->plugin);

  gobject_class = (GObjectClass *) klass;
  gstelement_class = (GstElementClass *) klass;

  gobject_class->set_property = gst_ladspa_vid_bodeshifter_set_property;
  gobject_class->get_property = gst_ladspa_vid_bodeshifter_get_property;

  g_object_class_install_property (gobject_class, PROP_SILENT,
      g_param_spec_boolean ("silent", "Silent", "Produce verbose output ?",
          FALSE, G_PARAM_READWRITE));

  for(i=0;i<klass->plugin.pd->PortCount;i++) {
	  if( ( klass->plugin.pd->PortDescriptors[i] & LADSPA_PORT_CONTROL)
			  && ( klass->plugin.pd->PortDescriptors[i] & LADSPA_PORT_INPUT ) ) {

		  printf("param_index %i\n",param_index);
		  sprintf(param_str,"param%i",param_index);

		  default_value=0.0;
		  if( ( LADSPA_IS_HINT_DEFAULT_MINIMUM(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )
				 || ( LADSPA_IS_HINT_DEFAULT_LOW(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )
				 || ( LADSPA_IS_HINT_DEFAULT_MIDDLE(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )
			  ) {
			  default_value = klass->plugin.pd->PortRangeHints[i].LowerBound;
		  }
		  if( ( LADSPA_IS_HINT_DEFAULT_HIGH(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )
				 || ( LADSPA_IS_HINT_DEFAULT_MAXIMUM(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )
			  ) {
			  default_value = klass->plugin.pd->PortRangeHints[i].UpperBound;
		  }
		  if( ( LADSPA_IS_HINT_DEFAULT_0(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )) {
			  default_value = 0.0;
		  }
		  if( ( LADSPA_IS_HINT_DEFAULT_1(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )) {
			  default_value = 1.0;
		  }
		  if( ( LADSPA_IS_HINT_DEFAULT_100(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )) {
			  default_value = 100.0;
		  }
		  if( ( LADSPA_IS_HINT_DEFAULT_440(klass->plugin.pd->PortRangeHints[i].HintDescriptor) )) {
			  default_value = 440.0;
		  }

		  printf("default_value %f\n",default_value);
		  g_object_class_install_property (gobject_class, PROP_DYNAMIC + param_index,
		      g_param_spec_float (param_str, param_str, klass->plugin.pd->PortNames[i],
		    		  klass->plugin.pd->PortRangeHints[i].LowerBound,
		    		  klass->plugin.pd->PortRangeHints[i].UpperBound,
		    		  default_value,
		    		  G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));

		  param_index++;
	  }
  }
/*
  g_object_class_install_property (gobject_class, PROP_RATE,
      g_param_spec_long ("rate", "Rate", "LADSPA sample frequency",
    		  1,128000,44100,
    		  G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
  g_object_class_install_property (gobject_class, PROP_DELAY,
      g_param_spec_float ("delay", "Delay", "Delay base (ms)",
    		  0.1, 25.0, 0.5,
    		  G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
  g_object_class_install_property (gobject_class, PROP_MAX_SLOW,
      g_param_spec_float ("max_slow", "Max slowdown (ms)", "Max slowdown (ms)",
    		  0.0, 10.0, 0.1,
    		  G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
  g_object_class_install_property (gobject_class, PROP_LFO,
      g_param_spec_float ("lfo", "LFO", "LFO frequency (Hz)",
    		  0.05, 100.0, 0.1,
    		  G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
  g_object_class_install_property (gobject_class, PROP_FEEDBACK,
      g_param_spec_float ("feedback", "Feedback", "Feedback",
    		  -1.0, 1.0, -0.3,
    		  G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
*/
}
コード例 #6
0
//==============================================================================
void DssiPlugin::setDefaultProgram ()
{
    if (ladspa == 0)
        return;

    // TODO - keep in a function instead !
    for (int i = 0; i < pars.size (); i++)
    {
        const LADSPA_PortRangeHint* hint = & ladspa->PortRangeHints [pars [i]];

        float lower = hint->LowerBound *
                      (LADSPA_IS_HINT_SAMPLE_RATE (hint->HintDescriptor) ? samplingRate : 1.0f);
        float upper = hint->UpperBound *
                      (LADSPA_IS_HINT_SAMPLE_RATE (hint->HintDescriptor) ? samplingRate : 1.0f);

        if (LADSPA_IS_HINT_HAS_DEFAULT (hint->HintDescriptor))
        {
            if (LADSPA_IS_HINT_DEFAULT_0 (hint->HintDescriptor))
            {
                normalized [i] = 0.0f;
                params [i] = 0.0f;
            }
            if (LADSPA_IS_HINT_DEFAULT_1 (hint->HintDescriptor))
            {
                normalized [i] = 1.0f;
                params [i] = 1.0f;
            }
            if (LADSPA_IS_HINT_DEFAULT_100 (hint->HintDescriptor))
            {
                normalized [i] = 100.0f;
                params [i] = 0.5f;
            }
            if (LADSPA_IS_HINT_DEFAULT_440 (hint->HintDescriptor))
            {
                normalized [i] = 440.0f;
                params [i] = 0.5f;
            }

            if (LADSPA_IS_HINT_BOUNDED_BELOW(hint->HintDescriptor)
                && LADSPA_IS_HINT_DEFAULT_MINIMUM (hint->HintDescriptor))
            {
                normalized [i] = lower;
                params [i] = 0.0f;
            }

            if (LADSPA_IS_HINT_BOUNDED_BELOW(hint->HintDescriptor)
                && LADSPA_IS_HINT_DEFAULT_MINIMUM (hint->HintDescriptor))
            {
                normalized [i] = lower;
                params [i] = 0.0f;
            }

            if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint->HintDescriptor)
                && LADSPA_IS_HINT_DEFAULT_MAXIMUM (hint->HintDescriptor))
            {
                normalized [i] = upper;
                params [i] = 1.0f;
            }

            if (LADSPA_IS_HINT_BOUNDED_BELOW(hint->HintDescriptor))
            {
                if (LADSPA_IS_HINT_LOGARITHMIC(hint->HintDescriptor)
                    && lower > 0.0f && upper > 0.0f)
                {
                    if (LADSPA_IS_HINT_DEFAULT_LOW(hint->HintDescriptor)) {
                        normalized [i] = expf(logf(lower) * 0.75f + logf(upper) * 0.25f);
                        params [i] = 0.25f;
                    } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint->HintDescriptor)) {
                        normalized [i] = expf(logf(lower) * 0.5f + logf(upper) * 0.5f);
                        params [i] = 0.5f;
                    } else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint->HintDescriptor)) {
                        normalized [i] = expf(logf(lower) * 0.25f + logf(upper) * 0.75f);
                        params [i] = 0.75f;
                    }
                }
                else
                {
                    if (LADSPA_IS_HINT_DEFAULT_LOW(hint->HintDescriptor)) {
                        normalized [i] = lower * 0.75f + upper * 0.25f;
                        params [i] = 0.25f;
                    } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint->HintDescriptor)) {
                        normalized [i] = lower * 0.5f + upper * 0.5f;
                        params [i] = 0.5f;
                    } else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint->HintDescriptor)) {
                        normalized [i] = lower * 0.25f + upper * 0.75f;
                        params [i] = 0.75f;
                    }
                }
            }
        }
        else
        {
            normalized [i] = 0.0f;
            params [i] = 0.0f;
        }
    }
}
コード例 #7
0
ファイル: LadspaEffect.cpp プロジェクト: ruthmagnus/audacity
LadspaEffect::LadspaEffect(const LADSPA_Descriptor *data,
                           const std::set<wxString>& categories)
    : mCategories(categories) {

    mData = data;
    pluginName = LAT1CTOWX(mData->Name);

    fInBuffer = NULL;
    fOutBuffer = NULL;

    inputs = 0;
    outputs = 0;
    numInputControls = 0;
    mLength = 0;

    unsigned long p;

    inputPorts = new unsigned long [mData->PortCount];
    outputPorts = new unsigned long [mData->PortCount];
    inputControls = new float [mData->PortCount];
    outputControls = new float [mData->PortCount];

    for(p=0; p<mData->PortCount; p++) {
        LADSPA_PortDescriptor d = mData->PortDescriptors[p];
        if (LADSPA_IS_PORT_AUDIO(d)) {
            if (LADSPA_IS_PORT_INPUT(d)) {
                inputPorts[inputs] = p;
                inputs++;
            }
            else if (LADSPA_IS_PORT_OUTPUT(d)) {
                outputPorts[outputs] = p;
                outputs++;
            }
        }
        if (LADSPA_IS_PORT_CONTROL(d) &&
                LADSPA_IS_PORT_INPUT(d)) {
            numInputControls++;

            float val = float(1.0);
            LADSPA_PortRangeHint hint = mData->PortRangeHints[p];

            if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) &&
                    val < hint.LowerBound)
                val = hint.LowerBound;

            if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) &&
                    val > hint.UpperBound)
                val = hint.UpperBound;

            if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint.HintDescriptor))
                val = hint.LowerBound;

            if (LADSPA_IS_HINT_DEFAULT_LOW(hint.HintDescriptor))
                val = hint.LowerBound * 0.75f + hint.UpperBound * 0.25f;

            if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint.HintDescriptor))
                val = hint.LowerBound * 0.5f + hint.UpperBound * 0.5f;

            if (LADSPA_IS_HINT_DEFAULT_HIGH(hint.HintDescriptor))
                val = hint.LowerBound * 0.25f + hint.UpperBound * 0.75f;

            if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint.HintDescriptor))
                val = hint.UpperBound;

            if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor))
                val *= mProjectRate;

            if (LADSPA_IS_HINT_DEFAULT_0(hint.HintDescriptor))
                val = 0.0f;

            if (LADSPA_IS_HINT_DEFAULT_1(hint.HintDescriptor))
                val = 1.0f;

            if (LADSPA_IS_HINT_DEFAULT_100(hint.HintDescriptor))
                val = 100.0f;

            if (LADSPA_IS_HINT_DEFAULT_440(hint.HintDescriptor))
                val = 440.0f;

            inputControls[p] = val;
        }
    }

    flags = PLUGIN_EFFECT;
    if (inputs == 0)
        flags |= INSERT_EFFECT;
    else if (outputs == 0)
        flags |= ANALYZE_EFFECT;
    else
        flags |= PROCESS_EFFECT;
}
コード例 #8
0
ファイル: plugin_desc.c プロジェクト: aib/mlt
LADSPA_Data
plugin_desc_get_default_control_value (plugin_desc_t * pd, unsigned long port_index, guint32 sample_rate)
{
  LADSPA_Data upper, lower;
  LADSPA_PortRangeHintDescriptor hint_descriptor;
  
  hint_descriptor = pd->port_range_hints[port_index].HintDescriptor;
  
  /* set upper and lower, possibly adjusted to the sample rate */
  if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) {
    upper = pd->port_range_hints[port_index].UpperBound * (LADSPA_Data) sample_rate;
    lower = pd->port_range_hints[port_index].LowerBound * (LADSPA_Data) sample_rate;
  } else {
    upper = pd->port_range_hints[port_index].UpperBound;
    lower = pd->port_range_hints[port_index].LowerBound;
  }
  
  if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor))
    {
      if (lower < FLT_EPSILON)
        lower = FLT_EPSILON;
    }
    

  if (LADSPA_IS_HINT_HAS_DEFAULT(hint_descriptor)) {
      
           if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_descriptor)) {
    
      return lower;
       
    } else if (LADSPA_IS_HINT_DEFAULT_LOW(hint_descriptor)) {
        
      if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
        return exp(log(lower) * 0.75 + log(upper) * 0.25);
      } else {
        return lower * 0.75 + upper * 0.25;
      }

    } else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_descriptor)) {
        
      if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
        return exp(log(lower) * 0.5 + log(upper) * 0.5);
      } else {
        return lower * 0.5 + upper * 0.5;
      }

    } else if (LADSPA_IS_HINT_DEFAULT_HIGH(hint_descriptor)) {
      
      if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor)) {
        return exp(log(lower) * 0.25 + log(upper) * 0.75);
      } else {
        return lower * 0.25 + upper * 0.75;
      }
      
    } else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_descriptor)) {
      
      return upper;
    
    } else if (LADSPA_IS_HINT_DEFAULT_0(hint_descriptor)) {
      
      return 0.0;
      
    } else if (LADSPA_IS_HINT_DEFAULT_1(hint_descriptor)) {
      
      if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) {
        return (LADSPA_Data) sample_rate;
      } else {
        return 1.0;
      }
      
    } else if (LADSPA_IS_HINT_DEFAULT_100(hint_descriptor)) {
      
      if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) {
        return 100.0 * (LADSPA_Data) sample_rate;
      } else {
        return 100.0;
      }
      
    } else if (LADSPA_IS_HINT_DEFAULT_440(hint_descriptor)) {
      
      if (LADSPA_IS_HINT_SAMPLE_RATE(hint_descriptor)) {
        return 440.0 * (LADSPA_Data) sample_rate;
      } else {
        return 440.0;
      }
      
    }  
      
  } else { /* try and find a reasonable default */
        
           if (LADSPA_IS_HINT_BOUNDED_BELOW(hint_descriptor)) {
      return lower;
    } else if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint_descriptor)) {
      return upper;
    }
  }

  return 0.0;
}
コード例 #9
0
ファイル: gstladspa.c プロジェクト: collects/gst-plugins-bad
static GParamSpec *
gst_ladspa_class_get_param_spec (GstLADSPAClass * klass, gint portnum)
{
  LADSPA_Descriptor *desc;
  GParamSpec *ret;
  gchar *name;
  gint hintdesc, perms;
  gfloat lower, upper, def;

  desc = klass->descriptor;

  name = gst_ladspa_class_get_param_name (klass, portnum);
  perms = G_PARAM_READABLE;
  if (LADSPA_IS_PORT_INPUT (desc->PortDescriptors[portnum]))
    perms |= G_PARAM_WRITABLE | G_PARAM_CONSTRUCT;
  if (LADSPA_IS_PORT_CONTROL (desc->PortDescriptors[portnum]))
    perms |= GST_PARAM_CONTROLLABLE;

  /* short name for hint descriptor */
  hintdesc = desc->PortRangeHints[portnum].HintDescriptor;

  if (LADSPA_IS_HINT_TOGGLED (hintdesc)) {
    ret = g_param_spec_boolean (name, name, name, FALSE, perms);
    g_free (name);
    return ret;
  }

  if (LADSPA_IS_HINT_BOUNDED_BELOW (hintdesc))
    lower = desc->PortRangeHints[portnum].LowerBound;
  else
    lower = -G_MAXFLOAT;

  if (LADSPA_IS_HINT_BOUNDED_ABOVE (hintdesc))
    upper = desc->PortRangeHints[portnum].UpperBound;
  else
    upper = G_MAXFLOAT;

  if (LADSPA_IS_HINT_SAMPLE_RATE (hintdesc)) {
    /* FIXME! */
    lower *= 44100;
    upper *= 44100;
  }

  if (LADSPA_IS_HINT_INTEGER (hintdesc)) {
    lower = CLAMP (lower, G_MININT, G_MAXINT);
    upper = CLAMP (upper, G_MININT, G_MAXINT);
  }

  /* default to lower bound */
  def = lower;

#ifdef LADSPA_IS_HINT_HAS_DEFAULT
  if (LADSPA_IS_HINT_HAS_DEFAULT (hintdesc)) {
    if (LADSPA_IS_HINT_DEFAULT_0 (hintdesc))
      def = 0.0;
    else if (LADSPA_IS_HINT_DEFAULT_1 (hintdesc))
      def = 1.0;
    else if (LADSPA_IS_HINT_DEFAULT_100 (hintdesc))
      def = 100.0;
    else if (LADSPA_IS_HINT_DEFAULT_440 (hintdesc))
      def = 440.0;
    if (LADSPA_IS_HINT_DEFAULT_MINIMUM (hintdesc))
      def = lower;
    else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM (hintdesc))
      def = upper;
    else if (LADSPA_IS_HINT_LOGARITHMIC (hintdesc)) {
      if (LADSPA_IS_HINT_DEFAULT_LOW (hintdesc))
        def = exp (0.75 * log (lower) + 0.25 * log (upper));
      else if (LADSPA_IS_HINT_DEFAULT_MIDDLE (hintdesc))
        def = exp (0.5 * log (lower) + 0.5 * log (upper));
      else if (LADSPA_IS_HINT_DEFAULT_HIGH (hintdesc))
        def = exp (0.25 * log (lower) + 0.75 * log (upper));
    } else {
      if (LADSPA_IS_HINT_DEFAULT_LOW (hintdesc))
        def = 0.75 * lower + 0.25 * upper;
      else if (LADSPA_IS_HINT_DEFAULT_MIDDLE (hintdesc))
        def = 0.5 * lower + 0.5 * upper;
      else if (LADSPA_IS_HINT_DEFAULT_HIGH (hintdesc))
        def = 0.25 * lower + 0.75 * upper;
    }
  }
#endif /* LADSPA_IS_HINT_HAS_DEFAULT */

  if (lower > upper) {
    gfloat tmp;

    /* silently swap */
    tmp = lower;
    lower = upper;
    upper = tmp;
  }

  def = CLAMP (def, lower, upper);

  if (LADSPA_IS_HINT_INTEGER (hintdesc)) {
    ret = g_param_spec_int (name, name, name, lower, upper, def, perms);
  } else {
    ret = g_param_spec_float (name, name, name, lower, upper, def, perms);
  }

  g_free (name);

  return ret;
}
コード例 #10
0
int lp_ladspa_knob_float::init(const LADSPA_Descriptor *descriptor,
				 unsigned long port,
				 int samplerate)
{
	LADSPA_Data f_val, f_low, f_high;

	if(descriptor == 0){
		std::cerr << "lp_ladspa_slider_int::" << __FUNCTION__ << ": pdescriptor is Null\n";
		return -1;
	}

	pv_samplerate = samplerate;

	LADSPA_PortRangeHintDescriptor hints;
	hints = descriptor->PortRangeHints[port].HintDescriptor;

	LADSPA_PortRangeHint range_hints;
	range_hints = descriptor->PortRangeHints[port];

	if(LADSPA_IS_HINT_BOUNDED_BELOW(hints)){
		f_val = range_hints.LowerBound;
		if(LADSPA_IS_HINT_SAMPLE_RATE(hints) && f_val != 0){
			f_val = f_val * (LADSPA_Data)pv_samplerate;
		}
		pv_low_val = (double)f_val;
		f_low = f_val;
	}else{
		// Set a default val
		pv_low_val = pv_default_low_val;
		f_low = (LADSPA_Data)pv_default_low_val;
	}

	if(LADSPA_IS_HINT_BOUNDED_ABOVE(hints)){
		f_val = range_hints.UpperBound;
		if(LADSPA_IS_HINT_SAMPLE_RATE(hints) && f_val != 0){
			f_val = f_val * (LADSPA_Data)pv_samplerate;
		}
		pv_high_val = (double)f_val;
		f_high = f_val;
	}else{
		// Set a default val
		pv_high_val = pv_default_high_val;
		f_high = (LADSPA_Data)pv_default_high_val;
	}

	if(LADSPA_IS_HINT_LOGARITHMIC(hints)){
		pv_is_log = true;
		// verifiy we have somthing else than 0
		if(pv_low_val == 0){
			pv_low_val = pv_default_low_val;
		}
		if(pv_high_val == 0){
			pv_high_val = pv_default_high_val;
		}
		// Set the log scale
		kb_val->setScaleEngine(log10_scale_engine);
		kb_val->setScale(pv_low_val, pv_high_val);
		// Set this range to the spinbox
		sp_val->setRange(pv_low_val, pv_high_val);

		// Calcule the slider range
		double d_low, d_high;
		d_low = log10(pv_low_val);
		d_high = log10(pv_high_val);

		// Set range to the slider
		kb_val->setRange(d_low, d_high);
	}else{
		// Set range to the slider and spinbox
		kb_val->setRange(pv_low_val, pv_high_val);
		sp_val->setRange(pv_low_val, pv_high_val);
	}

	// Store the range in f_val's
	f_low = (LADSPA_Data)pv_low_val;
	f_high = (LADSPA_Data)pv_high_val;

	// Default values
	if(LADSPA_IS_HINT_HAS_DEFAULT(hints)){
		if(LADSPA_IS_HINT_DEFAULT_MINIMUM(hints)){
			pv_def_val = pv_low_val;
		}
		if(LADSPA_IS_HINT_DEFAULT_MAXIMUM(hints)){
			pv_def_val = pv_high_val;
		}
		if(LADSPA_IS_HINT_DEFAULT_LOW(hints)){
			if(LADSPA_IS_HINT_LOGARITHMIC(hints)){
				f_val = exp(log(f_low)*0.75f + log(f_high)*0.25f);
			}else{
				f_val = (f_low*0.75f + f_high*0.25f);
			}
		}
		if(LADSPA_IS_HINT_DEFAULT_MIDDLE(hints)){
			if(LADSPA_IS_HINT_LOGARITHMIC(hints)){
				f_val = exp(log(f_low)*0.5f + log(f_high)*0.5f);
			}else{
				f_val = (f_low*0.5f + f_high*0.5f);
			}
		}
		if(LADSPA_IS_HINT_DEFAULT_HIGH(hints)){
			if(LADSPA_IS_HINT_LOGARITHMIC(hints)){
				f_val = exp(log(f_low)*0.25f + log(f_high)*0.75f);
			}else{
				f_val = (f_low*0.25f + f_high*0.75f);
			}
		}
		if(LADSPA_IS_HINT_DEFAULT_0(hints)){
			f_val = 0.0f;
		}
		if(LADSPA_IS_HINT_DEFAULT_1(hints)){
			f_val = 1.0f;
		}
		if(LADSPA_IS_HINT_DEFAULT_100(hints)){
			f_val = 100.0f;
		}
		if(LADSPA_IS_HINT_DEFAULT_440(hints)){
			f_val = 440.0f;
		}
		// Set default value
		pv_def_val = (double)f_val;
	}else{
		pv_def_val = pv_low_val;
	}

	txt_name->setText(descriptor->PortNames[port]);

	// set the middle value
	set_def_val();
	emit_changed(pv_def_val);

	return 0;
}
コード例 #11
0
ファイル: LadspaEffect.cpp プロジェクト: dot-Sean/audio
bool LadspaEffect::SetHost(EffectHostInterface *host)
{
   mHost = host;

   if (!Load())
   {
      return false;
   }

   mInputPorts = new unsigned long [mData->PortCount];
   mOutputPorts = new unsigned long [mData->PortCount];
   mInputControls = new float [mData->PortCount];
   mOutputControls = new float [mData->PortCount];

   for (unsigned long p = 0; p < mData->PortCount; p++)
   {
      LADSPA_PortDescriptor d = mData->PortDescriptors[p];

      // Collect the audio ports
      if (LADSPA_IS_PORT_AUDIO(d))
      {
         if (LADSPA_IS_PORT_INPUT(d)) 
         {
            mInputPorts[mAudioIns++] = p;
         }
         else if (LADSPA_IS_PORT_OUTPUT(d))
         {
            mOutputPorts[mAudioOuts++] = p;
         }
      }
      // Determine the port's default value
      else if (LADSPA_IS_PORT_CONTROL(d) && LADSPA_IS_PORT_INPUT(d))
      {
         mInteractive = true;

         LADSPA_PortRangeHint hint = mData->PortRangeHints[p];
         float val = float(1.0);
         float lower = hint.LowerBound;
         float upper = hint.UpperBound;

         if (LADSPA_IS_HINT_SAMPLE_RATE(hint.HintDescriptor))
         {
            lower *= mSampleRate;
            upper *= mSampleRate;
         }

         if (LADSPA_IS_HINT_BOUNDED_BELOW(hint.HintDescriptor) && val < lower)
         {
            val = lower;
         }

         if (LADSPA_IS_HINT_BOUNDED_ABOVE(hint.HintDescriptor) && val > upper)
         {
            val = upper;
         }

         if (LADSPA_IS_HINT_DEFAULT_MINIMUM(hint.HintDescriptor))
         {
            val = lower;
         }

         if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint.HintDescriptor))
         {
            val = upper;
         }

         if (LADSPA_IS_HINT_DEFAULT_LOW(hint.HintDescriptor))
         {
            if (LADSPA_IS_HINT_LOGARITHMIC(hint.HintDescriptor))
            {
               val = exp(log(lower)) * 0.75f + log(upper) * 0.25f;
            }
            else
            {
               val = lower * 0.75f + upper * 0.25f;
            }
         }

         if (LADSPA_IS_HINT_DEFAULT_MIDDLE(hint.HintDescriptor))
         {
            if (LADSPA_IS_HINT_LOGARITHMIC(hint.HintDescriptor))
            {
               val = exp(log(lower)) * 0.5f + log(upper) * 0.5f;
            }
            else
            {
               val = lower * 0.5f + upper * 0.5f;
            }
         }

         if (LADSPA_IS_HINT_DEFAULT_HIGH(hint.HintDescriptor))
         {
            if (LADSPA_IS_HINT_LOGARITHMIC(hint.HintDescriptor))
            {
               val = exp(log(lower)) * 0.25f + log(upper) * 0.75f;
            }
            else
            {
               val = lower * 0.25f + upper * 0.75f;
            }
         }

         if (LADSPA_IS_HINT_DEFAULT_0(hint.HintDescriptor))
         {
            val = 0.0f;
         }

         if (LADSPA_IS_HINT_DEFAULT_1(hint.HintDescriptor))
         {
            val = 1.0f;
         }

         if (LADSPA_IS_HINT_DEFAULT_100(hint.HintDescriptor))
         {
            val = 100.0f;
         }

         if (LADSPA_IS_HINT_DEFAULT_440(hint.HintDescriptor))
         {
            val = 440.0f;
         }

         mNumInputControls++;
         mInputControls[p] = val;
      }
      else if (LADSPA_IS_PORT_CONTROL(d) && LADSPA_IS_PORT_OUTPUT(d))
      {
         mInteractive = true;

         mNumOutputControls++;
         mOutputControls[p] = 0.0;
 
         // Ladspa effects have a convention of providing latency on an output
         // control port whose name is "latency".
         if (strcmp(mData->PortNames[p], "latency") == 0)
         {
            mLatencyPort = p;
         }
      }
   }

   // mHost will be null during registration
   if (mHost)
   {
      mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mUserBlockSize, 8192);
      mBlockSize = mUserBlockSize;

      bool haveDefaults;
      mHost->GetPrivateConfig(wxT("Default"), wxT("Initialized"), haveDefaults, false);
      if (!haveDefaults)
      {
         SaveParameters(wxT("Default"));
         mHost->SetPrivateConfig(wxT("Default"), wxT("Initialized"), true);
      }

      LoadParameters(wxT("Current"));
   }

   return true;
}
コード例 #12
0
ファイル: pluginaclientlad.C プロジェクト: knutj/cinelerra
void PluginAClientConfig::initialize(PluginServer *server)
{
	delete_objects();

	const LADSPA_Descriptor *lad_desc = server->lad_descriptor;
	const LADSPA_PortDescriptor *port_desc = lad_desc->PortDescriptors;
	const LADSPA_PortRangeHint *lad_hint = lad_desc->PortRangeHints;
	int port_count = lad_desc->PortCount;
	for(int i = 0; i < port_count; i++) {
		if( !LADSPA_IS_PORT_INPUT(port_desc[i]) ) continue;
		if( !LADSPA_IS_PORT_CONTROL(port_desc[i]) ) continue;
		++total_ports;
	}

	port_data = new LADSPA_Data[total_ports];
	port_type = new int[total_ports];

	for(int port = 0, i = 0; i < port_count; i++) {
		if( !LADSPA_IS_PORT_INPUT(port_desc[i]) ) continue;
		if( !LADSPA_IS_PORT_CONTROL(port_desc[i]) ) continue;
// Convert LAD default to default value
		float value = 0.0;
		LADSPA_PortRangeHintDescriptor hint_desc = lad_hint->HintDescriptor;

// Store type of port for GUI use
		port_type[port] = PORT_NORMAL;
		if( LADSPA_IS_HINT_SAMPLE_RATE(hint_desc) /* &&
		    LADSPA_IS_HINT_BOUNDED_ABOVE(hint_desc) &&
		    LADSPA_IS_HINT_BOUNDED_BELOW(hint_desc) */ ) // LAD frequency table
			port_type[port] = PORT_FREQ_INDEX;
		else if(LADSPA_IS_HINT_TOGGLED(hint_desc))
			port_type[port] = PORT_TOGGLE;
		else if(LADSPA_IS_HINT_INTEGER(hint_desc))
			port_type[port] = PORT_INTEGER;

// Get default of port using crazy hinting system
		if( LADSPA_IS_HINT_DEFAULT_0(hint_desc) )
			value = 0.0;
		else if( LADSPA_IS_HINT_DEFAULT_1(hint_desc) )
			value = 1.0;
		else if( LADSPA_IS_HINT_DEFAULT_100(hint_desc) )
			value = 100.0;
		else if( LADSPA_IS_HINT_DEFAULT_440(hint_desc) )
			value = port_type[port] == PORT_FREQ_INDEX ?
				 440.0 / 44100 : 440.0;
		else if( LADSPA_IS_HINT_DEFAULT_MAXIMUM(hint_desc) )
			value = lad_hint->UpperBound;
		else if( LADSPA_IS_HINT_DEFAULT_MINIMUM(hint_desc) )
			value = lad_hint->LowerBound;
		else if( LADSPA_IS_HINT_DEFAULT_LOW(hint_desc) )
			value = LADSPA_IS_HINT_LOGARITHMIC(hint_desc) ?
				exp(log(lad_hint->LowerBound) * 0.25 +
					log(lad_hint->UpperBound) * 0.75) :
				lad_hint->LowerBound * 0.25 +
					lad_hint->UpperBound * 0.75;
		else if( LADSPA_IS_HINT_DEFAULT_MIDDLE(hint_desc) )
			value = LADSPA_IS_HINT_LOGARITHMIC(hint_desc) ?
				exp(log(lad_hint->LowerBound) * 0.5 +
					log(lad_hint->UpperBound) * 0.5) :
				lad_hint->LowerBound * 0.5 +
					lad_hint->UpperBound * 0.5;
		else if( LADSPA_IS_HINT_DEFAULT_HIGH(hint_desc) )
			value = LADSPA_IS_HINT_LOGARITHMIC(hint_desc) ?
				exp(log(lad_hint->LowerBound) * 0.75 +
					log(lad_hint->UpperBound) * 0.25) :
				lad_hint->LowerBound * 0.75 +
					lad_hint->UpperBound * 0.25;

		port_data[port] = value;
		++port;
	}
}