Counter

Count rising edges of a trigger lane, with step, limit, wrap and reset. Lane 1 is the normalised count, lane 2 the raw count.

  • Control
  • Since 0.2.0
  • counter
  • trigger
  • step
  • sequence

Open in TuneToys

Counter as the Patch draws it, at default values: inlets on the left, outlets on the right.

Counter counts the rising edges of a trigger lane, with a step, a limit, wrapping and a reset input.

What it does#

Each rising edge on trigger adds Step to the count; a negative Step counts down. The count is kept between 0 and Limit: with Clamp it stops at the limit, with Wrap it returns to 0 once it passes it. A rising edge on reset returns the count to its start. The output has two lanes: lane 1 is the count divided by Limit, from 0 to 1, and lane 2 is the raw count.

Events#

The wrap outlet sends an event: it is 1 for one block whenever a step carries the count past Limit or below 0, whether Wrap brings it back to 0 or Clamp holds it at the edge, and 0 otherwise. A reset never counts as a wrap. Cable it into a trigger input, such as another Counter or Sample and hold, to do something once per lap.

When to use it#

Use it for scoreboards, step counters and anything that advances on events. Feed it from Compare in Trigger mode, or straight from a square Control LFO as a clock. Use lane 1 for a normalised position and lane 2 for the whole number.

Ports#

PortDirectionSignalLanes
triggerInputControl1
resetInputControl1
controlOutputControl2
wrapOutputControl1

Parameters#

ParameterLabelRangeDefaultUnitScaleNotes
limitLimit1 to 100010linearCount value that maps to 1 on the normalised lane and where wrapping or clamping happens.
stepStep-10 to 101linearAmount added on each trigger; negative counts down.
wrapWrap0 to 10linearWrap past the limit back to 0 instead of clamping. Choices: 0 Clamp, 1 Wrap.

Limit (limit)#

The count that maps to 1 on the normalised lane, and where wrapping or clamping happens. 1 to 1000, whole numbers.

Step (step)#

The amount added on each trigger, -10 to 10. Negative counts down.

Wrap (wrap)#

Clamp holds the count at the limit; Wrap returns it to 0 instead. A discrete choice.

Tips#

  • Use Select lanes to pick the normalised or raw lane.
  • Both inputs are single lanes, so cable one lane into each.
  • wrap is a one-block pulse, like Compare in Trigger mode: cable it into a trigger, not into a parameter that should glide.

See also#

Compare, Sample and hold, Control LFO, Select lanes, Cables.

Help patches

Each help patch is an ordinary Toy that teaches one idea. The diagram shows the Patch; the preview shows its Frame. Open it in TuneToys to play and edit it.

1. Count a clock

beginner Teaches: limit, step, wrap

A square LFO clocks a counter with a limit, step and wrap.

Patch: Oscillator audio output connected to Patch outputs audio input. Control LFO control output connected to Counter trigger input.
Connections as text
  • Oscillator audio output connected to Patch outputs audio input
  • Control LFO control output connected to Counter trigger input
  • Each rising edge of the square LFO adds Step to the count.
  • Lane 1 is the count divided by Limit; lane 2 is the raw count.
  • Wrap returns to 0 past Limit; Clamp holds there.
Frame preview: Count a clockFrame “Count a clock” with 4 elements: text heading, knob Limit, knob Step, segmented Wrap.COUNT A CLOCK8Limit1StepClampWrapWrap
Frame preview (static). Controls show their default values.

Open in TuneToys

2. Act once per lap

intermediate Teaches: limit, wrap, control-lanes

A clock steps a counter that shapes the level; every time the count wraps, the wrap outlet samples a new pitch from a slow LFO.

Patch: Oscillator audio output connected to Gain audio input. Gain audio output connected to Patch outputs audio input. Control LFO “clock” control output connected to Counter trigger input. Counter control output connected to Select lanes control input. Select lanes control output connected to Gain @level input. Control LFO “drift” control output connected to Sample and hold control input. Counter wrap output connected to Sample and hold trigger input. Sample and hold control output connected to Scale control input. Scale control output connected to Oscillator @frequency input.
Connections as text
  • Oscillator audio output connected to Gain audio input
  • Gain audio output connected to Patch outputs audio input
  • Control LFO “clock” control output connected to Counter trigger input
  • Counter control output connected to Select lanes control input
  • Select lanes control output connected to Gain @level input
  • Control LFO “drift” control output connected to Sample and hold control input
  • Counter wrap output connected to Sample and hold trigger input
  • Sample and hold control output connected to Scale control input
  • Scale control output connected to Oscillator @frequency input
  • The square clock steps the counter four times a second.
  • wrap is 1 for one block when a step passes the limit (or zero); it triggers Sample and hold.
  • The held slow-LFO value is scaled to a pitch window and cabled into frequency.
Frame preview: Act once per lapFrame “Act once per lap” with 4 elements: text heading, text hint, knob Limit, segmented Wrap.ACT ONCE PER LAPA 4 Hz clock steps the counter, whose normalised lane sets the level. Each lap …4LimitClampWrapWrap
Frame preview (static). Controls show their default values.

Open in TuneToys

  • Compare Turn any signal into a gate or trigger by comparing it to a threshold or to another signal, lane by lane, with hysteresis and tolerance.
  • Sample and hold Capture the input lanes whenever the trigger lane rises and hold them until the next trigger.
  • Control LFO A free-running or tempo-synced low-frequency oscillator on a control lane, 0 to 1, with depth, offset, phase, skew, random shapes and a reset input.

Edit this page on GitHub

esc

↑ ↓ move↩ open⌘↩ new tabesc close