---
title: "pulseTrain"
description: "An on/off rhythm: 1 for the first part of each cycle, 0 for the rest."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "motion"
categorySlug: "motion"
categoryTitle: "Motion & timing"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/motion.ts#L88"
---

# pulseTrain

An on/off rhythm: 1 for the first part of each cycle, 0 for the rest.

```ts
pulseTrain(
  t: Expr,
  opts: {period: Expr | number; duty: Expr | number; soften?: number},
): Expr
```

Import `motion` from `shaders/std` and use `motion.pulseTrain`.

`period` is seconds per cycle and `duty` is the on fraction, 0..1. `soften` eases both edges over that fraction of the cycle. Leave it at 0 for a hard blink.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `t` | `Expr` |  |
| `opts` | `{period: Expr \| number; duty: Expr \| number; soften?: number}` |  |

## Example

```ts
const blink = motion.pulseTrain(animatedTime(params), {period: 1.5, duty: 0.3, soften: 0.05})
```

## See also

- [`pulsing`](/docs/primitives/motion/pulsing) — A knob that switches on and off in a rhythm, for any slot that takes a prop.
- [`cycle`](/docs/primitives/motion/cycle) — A repeating cycle as two numbers: `progress` (0..1 through the current cycle) and `index` (which cycle this is).
- [`oscillate`](/docs/primitives/motion/oscillate) — A smooth back-and-forth between `min` and `max`.