Component: Scale (DSP Operators)

From Flowcode Help
Jump to navigationJump to search
Author Matrix Ltd
Version 1.1
Category DSP Operators


Scale component

Allows the values in a single buffer to be scaled uniformly. Functions include: Multiply, Divide, LeftShift, RightShift, Float Multiply, Float Divide

Component Source Code

Please click here to download the component source project: FC_Comp_Source_DSP_Scale.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_DSP_Scale.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Here is an example which demonstrates variable scaling based on an analogue input.

FC6 Icon.png Scale

Here are the traces as seen on the data recorder window.

DSPScale.jpg


The RightShift macro is a very efficient means of performing a division but only for values which are a power of 2.

The LeftShift macro is a very efficient means of performing a multiplication but only for values which are a power of 2.


LeftShift(1) = Multiply by 2 / RightShift(1) = Divide by 2

LeftShift(2) = Multiply by 4 / RightShift(2) = Divide by 4

LeftShift(3) = Multiply by 8 / RightShift(3) = Divide by 8

LeftShift(4) = Multiply by 16 / RightShift(4) = Divide by 16








Macro reference

Calculate

Fc9-comp-macro.png Calculate
Performs the selected scaling on a value from the input buffer and passes to the output buffer. 
Fc9-void-icon.png - VOID Return


CalculateArray

Fc9-comp-macro.png CalculateArray
Performs the selected scaling on an entire buffer. 
Fc9-void-icon.png - VOID Return


SetScalerFloat

Fc9-comp-macro.png SetScalerFloat
Sets the Float scaler to be used when calling the calculate function. 
Fc9-f32-icon.png - FLOAT Scaler
 
Fc9-void-icon.png - VOID Return


SetScalerInteger

Fc9-comp-macro.png SetScalerInteger
Sets the Integer scaler to be used when calling the calculate function. 
Fc9-s16-icon.png - INT Scaler
 
Fc9-void-icon.png - VOID Return


Property reference

Fc9-prop-icon.png Properties
Fc9-type-16-icon.png Connect To
DSP component with output buffer to collect our data from. 
Fc9-type-21-icon.png Buffer Size
Number of individual elements the buffer can store, default 1. 
Fc9-type-16-icon.png Buffer Type
Sets the buffer data type. 
Fc9-type-16-icon.png Direction
Sets the data direction flow of the component 
Fc9-conn-icon.png Scaling
Fc9-type-16-icon.png Scale Type
Defines the type of calculation performed on the input buffer to obtain the output value. A left shift is essentially an optimised multiply with the multiplier being the 2^scaler A right shift is essentially an optimised divide with the divider being the 2^scaler  
Fc9-type-7-icon.png Rollover
Allow the output buffer to rollover. For example 128 * 2 = 256 which would equate to 0 using an 8-bit buffer with rollover enabled. With rollover disabled the output would be set to 255 which is the max representable value. 
Fc9-type-14-icon.png Initial Integer Scaler