---
url: /dyad/stable/stdlib/BlockComponents/components/Sources.Sine.md
description: >-
  Dyad Sources.Sine docs.  Generates a sine wave signal with configurable
  parameters.
---

# `Sources.Sine` {#Sources.Sine}

Generates a sine wave signal with configurable parameters.

The component produces a sinusoidal output according to:

$$y = \text{offset} + \text{amplitude} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{shift_time}) + \text{phase})$$

When `time < start_time`, the output depends on the `continuous` parameter:

* `continuous = true` (default): output equals `offset + amplitude * sin(2π * frequency * (start_time - shift_time) + phase)`, ensuring value continuity at `start_time` (backwards compatible)

* `continuous = false`: output equals `offset`

By default `shift_time = start_time` (backwards compatible). Set `shift_time = 0` for absolute time reference where `phase` has its exact physical meaning.

Note: when `shift_time = start_time`, the `start_time` parameter introduces a hidden phase shift of `2π * frequency * start_time`. Use `shift_time = 0` to avoid this.

This component extends from [`BlockComponents.Interfaces.Signal`](../types/Interfaces.Signal.md)

## Usage {#Usage}

`BlockComponents.Sources.Sine(start_time=0.0, offset=0.0, amplitude, frequency, phase=0.0, shift_time=start_time, continuous=true)`

## Parameters: {#Parameters:}

|         Name |                                                                                                             Description | Units | Default value |
| ------------:| -----------------------------------------------------------------------------------------------------------------------:| -----:| -------------:|
| `start_time` |                                                          Time at which the signal starts changing from its offset value |     s |           0.0 |
|     `offset` |                                                                               Constant value added to the signal output |     – |           0.0 |
|  `amplitude` |                                                                                             Peak value of the sine wave |     – |               |
|  `frequency` |                                                                                          Number of cycles per time unit |    Hz |               |
|      `phase` |                                                                                   Angular displacement of the sine wave |   rad |           0.0 |
| `shift_time` |    Time origin for the waveform (default: start_time for backwards compatibility; set to 0 for absolute time reference) |     s |    start_time |
| `continuous` | If true, output is continuous at start_time by holding at the start value; if false, output is offset before start_time |     – |          true |

## Connectors {#Connectors}

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

## Behavior {#Behavior}

$$ \begin{align}
y\left( t \right) &= ifelse\left( \mathtt{continuous}, \mathtt{amplitude} ~ ifelse\left( t \geq \mathtt{start_time}, \sin\left( \mathtt{phase} + 6.2832 ~ \mathtt{frequency} ~ \left(  - \mathtt{shift_time} + t \right) \right), \sin\left( \mathtt{phase} + 6.2832 ~ \mathtt{frequency} ~ \left(  - \mathtt{shift_time} + \mathtt{start_time} \right) \right) \right), ifelse\left( t \geq \mathtt{start_time}, \mathtt{amplitude} ~ \sin\left( \mathtt{phase} + 6.2832 ~ \mathtt{frequency} ~ \left(  - \mathtt{shift_time} + t \right) \right), 0 \right) \right) + \mathtt{offset}
\end{align}
$$

## Source {#Source}

````dyad
"""
Generates a sine wave signal with configurable parameters.

The component produces a sinusoidal output according to:

```math
y = \text{offset} + \text{amplitude} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{shift\_time}) + \text{phase})
```

When `time < start_time`, the output depends on the `continuous` parameter:
- `continuous = true` (default): output equals `offset + amplitude * sin(2π * frequency * (start_time - shift_time) + phase)`, ensuring value continuity at `start_time` (backwards compatible)
- `continuous = false`: output equals `offset`

By default `shift_time = start_time` (backwards compatible). Set `shift_time = 0` for
absolute time reference where `phase` has its exact physical meaning.

Note: when `shift_time = start_time`, the `start_time` parameter introduces a hidden
phase shift of `2π * frequency * start_time`. Use `shift_time = 0` to avoid this.
"""
component Sine
  extends BlockComponents.Interfaces.Signal
  "Peak value of the sine wave"
  parameter amplitude::Real
  "Number of cycles per time unit"
  parameter frequency::Frequency
  "Angular displacement of the sine wave"
  parameter phase::Angle = 0.0
  "Time origin for the waveform (default: start_time for backwards compatibility; set to 0 for absolute time reference)"
  parameter shift_time::Time = start_time
  "If true, output is continuous at start_time by holding at the start value; if false, output is offset before start_time"
  parameter continuous::Boolean = true
relations
  y = offset + ifelse(continuous, amplitude * ifelse(time >= start_time, sin(2 * π * frequency * (time - shift_time) + phase), sin(2 * π * frequency * (start_time - shift_time) + phase)), ifelse(time >= start_time, amplitude * sin(2 * π * frequency * (time - shift_time) + phase), 0.0))
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Sine.svg"}
  }
}
end
````

````dyad
"""
Generates a sine wave signal with configurable parameters.

The component produces a sinusoidal output according to:

```math
y = \text{offset} + \text{amplitude} \cdot \sin(2\pi \cdot \text{frequency} \cdot (\text{time} - \text{shift\_time}) + \text{phase})
```

When `time < start_time`, the output depends on the `continuous` parameter:
- `continuous = true` (default): output equals `offset + amplitude * sin(2π * frequency * (start_time - shift_time) + phase)`, ensuring value continuity at `start_time` (backwards compatible)
- `continuous = false`: output equals `offset`

By default `shift_time = start_time` (backwards compatible). Set `shift_time = 0` for
absolute time reference where `phase` has its exact physical meaning.

Note: when `shift_time = start_time`, the `start_time` parameter introduces a hidden
phase shift of `2π * frequency * start_time`. Use `shift_time = 0` to avoid this.
"""
component Sine
  "Real-valued output connector for the component"
  y = RealOutput() {
    "Dyad": {
      "placement": {
        "icon": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0},
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      }
    }
  }
  "Time at which the signal starts changing from its offset value"
  parameter start_time::Time = 0.0
  "Constant value added to the signal output"
  parameter offset::Real = 0.0
  "Peak value of the sine wave"
  parameter amplitude::Real
  "Number of cycles per time unit"
  parameter frequency::Frequency
  "Angular displacement of the sine wave"
  parameter phase::Angle = 0.0
  "Time origin for the waveform (default: start_time for backwards compatibility; set to 0 for absolute time reference)"
  parameter shift_time::Time = start_time
  "If true, output is continuous at start_time by holding at the start value; if false, output is offset before start_time"
  parameter continuous::Boolean = true
relations
  y = offset + ifelse(continuous, amplitude * ifelse(time >= start_time, sin(2 * π * frequency * (time - shift_time) + phase), sin(2 * π * frequency * (start_time - shift_time) + phase)), ifelse(time >= start_time, amplitude * sin(2 * π * frequency * (time - shift_time) + phase), 0.0))
metadata {
  "Dyad": {
    "labels": [{"label": "$(instance)", "x": 500, "y": 1100, "rot": 0}],
    "icons": {"default": "dyad://BlockComponents/Sine.svg"}
  }
}
end
````

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Abs`](Sources.Sine.md)

  * [`Acos`](Sources.Sine.md)

  * [`Add`](Sources.Sine.md)

  * [`Add3`](Sources.Sine.md)

  * [`Asin`](Sources.Sine.md)

  * [`Atan`](Sources.Sine.md)

  * [`Atan2`](Sources.Sine.md)

  * [`BooleanToInteger`](Sources.Sine.md)

  * [`BooleanToReal`](Sources.Sine.md)

  * [`ContinuousMean`](Sources.Sine.md)

  * [`Cos`](Sources.Sine.md)

  * [`Cosh`](Sources.Sine.md)

  * [`DeadZone`](Sources.Sine.md)

  * [`DerivativeIntegratorTerminator`](Sources.Sine.md)

  * [`Division`](Sources.Sine.md)

  * [`Exp`](Sources.Sine.md)

  * [`Feedback`](Sources.Sine.md)

  * [`IntegerToBoolean`](Sources.Sine.md)

  * [`IntegerToReal`](Sources.Sine.md)

  * [`Integrator`](Sources.Sine.md)

  * [`Limiter`](Sources.Sine.md)

  * [`LinearDependency`](Sources.Sine.md)

  * [`Ln`](Sources.Sine.md)

  * [`Log`](Sources.Sine.md)

  * [`Log10`](Sources.Sine.md)

  * [`Logical`](Sources.Sine.md)

  * [`Max`](Sources.Sine.md)

  * [`Min`](Sources.Sine.md)

  * [`PadeDelay`](Sources.Sine.md)

  * [`PolarToRectangular`](Sources.Sine.md)

  * [`Power`](Sources.Sine.md)

  * [`Product`](Sources.Sine.md)

  * [`Pythagoras`](Sources.Sine.md)

  * [`RealToBoolean`](Sources.Sine.md)

  * [`RealToInteger`](Sources.Sine.md)

  * [`RectangularToPolar`](Sources.Sine.md)

  * [`Sign`](Sources.Sine.md)

  * [`Sin`](Sources.Sine.md)

  * [`Sine`](Sources.Sine.md)

  * [`Sine`](Sources.Sine.md)

  * [`SineModes`](Sources.Sine.md)

  * [`Sinh`](Sources.Sine.md)

  * [`SlewRateLimiter`](Sources.Sine.md)

  * [`Sqrt`](Sources.Sine.md)

  * [`Tan`](Sources.Sine.md)

  * [`Tanh`](Sources.Sine.md)

  * [`VariableLimiter`](Sources.Sine.md)

  * [`WrapAngle`](Sources.Sine.md)
