public class TSignalGenerator : TSignal
Generates signals in real time.
Use this component as a function parser for signal generator applications. The component features a stack based vectorized function evaluator. This component allows you to generate very complex signals ten to hundred times times faster then a simple function evaluator. The component has a component editor TSignalGeneratorDialog.
Signal expressions are defined at design time via the TSignalGeneratorDialog or at runtime by creating TFuncSignalRecord items and adding them to the Sounds.Template list. Expressions use postfix notation (HP calculator style): functions push results onto the stack and operators combine the top two stack entries. Set Length and SamplingFrequency before calling Update.
The FloatPrecision property controls the output precision (mvSingle or mvDouble). Set it before calling Update. It is applied to the output Data vector and to all internal work vectors used during signal generation.
TFuncSignalRecord parameter mapping for each TFuncSignalType:
funSine: P1 = frequency [Hz], P2 = phase [degrees], P3 = amplitude.
funTriangle: P1 = frequency [Hz], P2 = phase [degrees], P3 = amplitude, P4 = asymmetry.
funSquare: P1 = frequency [Hz], P2 = phase [degrees], P3 = amplitude, P4 = DC offset.
funImpulse: P1 = high time, P2 = low time, P3 = raise time, P4 = fall time, P5 = amplitude.
funUnitImpulse: No parameters. Generates a single impulse at sample 0.
funRandGauss: P1 = mean, P2 = standard deviation.
funRandUniform: P1 = low bound, P2 = high bound.
funChirp: P1 = starting frequency f_1 [Hz], P3 = starting amplitude a_1, P4 = DC offset d,
P5 = ending frequency f_2 [Hz], P6 = ending amplitude a_2, P7 = period [s]. The instantaneous frequency sweeps linearly from f_1 to f_2 across the n-sample buffer; with f_s the sampling frequency the sample i is x[i] = (a_1(n-i)+a_2 i)/n sinBig(big(1/2alpha i + betabig) iBig) + d, beta=(2pi f_1)/f_s, alpha=(2pi (f_2-f_1))/(f_s n). The amplitude envelope ramps linearly from a_1 to a_2 over the buffer.
funConstant: P1 = constant value, P2 = imaginary part (if complex).
funNone: No signal.
funInput0..funInput7: References TSignalFilter.Inputs property.
TSignalGeneratorDialog
Properties
| Name | Type | Description |
|---|---|---|
| Active | Boolean | Set active to false to suppress the propagation of the Pull request and the subsequent call to the Update method. |
| BandWidth | Double | Return the bandwidth of the signal. |
| BandwidthH | Double | Returns the upper bandwidth edge of the signal. |
| BandwidthL | Double | Returns the lower bandwidth edge of the signal. |
| BlockAssign | Boolean | Block streaming of specific properties when storing only a "template". |
| ChannelCount | Int32 | Get or set the number of channels multiplexed in the data property. |
| Complex | Boolean | Set this property to true, to request computation using complex numbers. |
| ComputeMessage | String | Contains any error messages encountered while trying to evalute the functions. |
| Continuous | Boolean | If True, the component will pass on the udpate request to the connected component. |
| Data | TVec | Stores the result of the processing. |
| Dt | Double | Time between two consecutive samples. |
| EditorActive | Boolean | Returns True, if the component editor is displayed. |
| FloatPrecision | TMtxFloatPrecision | Set this property to request computation in 32bit/64bit precision with real/complex numbers. |
| FloatPrecisionLock | Boolean | Set this property to true to lock changes to FloatPrecision property. |
| HzRes | Double | Frequency resolution obtained, if an FFT algorithm would be run on the data. |
| Input | TAnalysis | Connector property to obtain a pointer to the TSignal component holding the data to be processed. |
| IsDouble | Boolean | Set this property to false, to request computation in 32bit floating point precision, 64bit, if true. |
| Item | Double | Default property to access values of a real signal. |
| ItemNumber | Int32 | Number to label the object when it is an item in the List. |
| Length | Int32 | Get or set the length of the signal in samples. |
| Marks | TMarkList | Stores the time stamps and amplitude of selected samples. |
| MaxAmplt | Double | Stores the maximum amplitude of the signal found by the MinMax method. |
| MaxX | Double | Use the MaxX property to store the time stamp (in seconds) of the right most sample. |
| MinAmplt | Double | Stores the minimum amplitude of the signal found by the MinMax method. |
| MinX | Double | Use the MinX property to store the time stamp of the left-most sample. |
| OnAfterUpdate | TNotifyEvent | The event is triggered after the call to the Update method. |
| OnBeforeUpdate | TNotifyEvent | The event is triggered just before the call to the Update method. |
| OnDisplayUpdate | TNotifyEvent | The event is triggered after the OnAfterUpdate event. Use this event to update any associated charts or graphs or result tables. |
| OnGetInput | TNotifyEvent | If the Input property is not assigned, the component will call OnGetInput. |
| OnNotifyUpdate | TNotifyEvent | The event is called after a call to InternalUpdate, OnAfterUpdate and OnDisplayUpdate from within the Update method. |
| OnParameterUpdate | TNotifyEvent | The event is triggered when ParamUpdate method is called. The ParamUpdate method is usually called by component editors when a value was changed by the user and the editor was "Live". |
| OnResync | TOnResync | Event triggered when the user calls the ResyncFunction method. |
| PipeState | TPipeState | Returns the state of the pipe after the last update. |
| Prepared | Boolean | Returns true, if all function generators are initialized. |
| Reference | TReferenceList | Stores a list of components that have to be notified, when this component is destroyed. |
| SamplingFrequency | Double | Defines the sampling frequency of the signal. |
| SamplingTime | Double | The length of the signal in seconds. |
| Sounds | TSignalSounds | Signal generator sound definition object. |
| SuspendNotifyUpdate | Boolean | Set this property to True, to prevent calling OnNotifyUpdate from the Update Method. |
| UsesInputs | Boolean | Set it to True to indicate, that valid signals will be connected to the Input or Inputs properties. |
Methods
| Name | Description |
|---|---|
| AllowStreaming | Returns the negatated value of BlockAssign. |
| Append | Appends Sample to the end of the signal. |
| Assign | Assign values of all published properties from Source. |
| AssignTemplate | Assign values of "template-like" published properties from Source. |
| Copy | Copies signal Data and sampling frequency information. |
| Crest | Compute the CREST parameter. |
| EditorClass | To be overriden in descendanr classses. |
| InputsDirty | If all Inputs[i] are dirty the function returns true. |
| InternalPull | When called, the method will pass Update requests recursively to all connected objects. |
| Invalidate | Notifies all connected components that this component has fresh data. |
| LoadFromStream | Load the component from Src stream. |
| LoadTemplateFromFile | Load a template from file. |
| LoadTemplateFromStream | Load a template from stream. |
| MarksToStrings | Convert marks to strings. |
| MinMax | Find minimum and maximum amplitude and store the result in the MinAmplt and MaxAmplt properties. |
| ParamUpdate | The method can be assigned to some other component even handler, as a notification that a parameter has changed and that Self should consider a recalculation. |
| PartialUpdate | Update the function generator with the new parameters from the sounds property item at position i. |
| Peak | Find the maximum deviation of the signal from its mean value. |
| PipeReset | Recursively processes all connected components backward and calls Reset method. |
| Prepare | Initialize the function (sound) to be generated. |
| Pull | Request recalculation of the entire chain of all connected components. |
| PullUntilEnd | Calls Pull until pipeEnd is returned. |
| Reset | Initialize the function (sound) to be generated. |
| ResyncAll | Resets all functions to its initial phase. |
| ResyncFunction | Resets the function at TemplatLineIndex position to its initial phase. |
| SaveTemplateToFile | Save template to file. |
| SaveTemplateToStream | Save template to stream. |
| SaveToStream | Save the component to Dst stream. |
| Size | Assign the size of the signal from Src. |
| Update | Request recalculation of the data and place the result in Self. |
| UpdateNotify | Call this method only, if SuspendNotifyUpdate is True. |
| ValuesToStrings | Convert values to strings. |
Events
| Name | Description |
|---|---|
| OnAfterUpdateEvent | The event is triggered after the call to the Update method. |
| OnBeforeUpdateEvent | The event is triggered just before the call to the Update method. |
| OnDisplayUpdateEvent | The event is triggered after the OnAfterUpdate event. Use this event to update any associated charts or graphs or result tables. |
| OnGetInputEvent | If the Input property is not assigned, the component will call OnGetInput. |
| OnNotifyUpdateEvent | The event is called after a call to InternalUpdate, OnAfterUpdate and OnDisplayUpdate from within the Update method. |
| OnParameterUpdateEvent | The event is triggered when ParamUpdate method is called. The ParamUpdate method is usually called by component editors when a value was changed by the user and the editor was "Live". |
| OnResyncEvent | Event triggered when the user calls the ResyncFunction method. |