Example 2

The next example is the SDF primitive MpyConstFloat, which multiplies its input by a constant and outputs the result.

  1. defprimitive
  2. {
  3.   name        { MpyConstFloat }
  4.   domain      { SDF }
  5.  
  6.   desc
  7.   {
  8.     Multiplication of floating input by a floating constant.
  9.   }
  10.  
  11.   input
  12.   {
  13.     name { Input }
  14.     type {float}
  15.     desc {"Floating multiplier."}
  16.   }
  17.  
  18.   output
  19.   {
  20.     name { Output }
  21.     type {float}
  22.     desc {"Floating product."}
  23.   }
  24.  
  25.   defparameter
  26.   {
  27.     name        { Multiplier }
  28.     type        {float}
  29.     default     {"1.0"}
  30.     desc        {"Constant floating multiplier."}
  31.   }
  32.  
  33.   location { SDF main library }
  34.  
  35.   go
  36.   {
  37.     Output%0 << double(Multiplier) * double(Input%0);
  38.   }
  39. }
  40.