# Oscillator

> Selected waveform kernels, continuous morphing, harmonic shapes and phase/gate control; an optional MIDI input plays notes in the Toy's tuning.

Source: https://docs.tune.toys/nodes/std.oscillator/

A full-featured sound source with eight waveforms, a morph control, detune and phase. It has no audio input; an optional MIDI input plays it from notes.

## What it does

The oscillator generates a tone at Frequency, shaped by Type. The waveforms are Morph, Sine, Triangle, Saw, Pulse, Double saw, Organ and Harmonic bell. Morph blends continuously between sine, triangle, saw and pulse, evaluating only the two neighboring waves. Saw and pulse edges are band-limited to reduce aliasing. Detune offsets the pitch in cents, Phase sets the starting position of the cycle, and a rising Gate edge restarts the wave from that position.

With a cable into its `midi` input, the oscillator plays the newest held note instead of Frequency: the note's pitch comes from the Toy's tuning, Detune still offsets it, pitch bend moves it by up to Bend range semitones, and Glide slides between notes. Releasing the newest note falls back to the newest still-held one; after the last release the pitch stays where it was, so a downstream envelope can fade it out. Before the first note, Frequency sets the pitch. The MIDI input does not gate the sound: pair it with an [Envelope](https://docs.tune.toys/nodes/std.envelope/) whose Gate comes from [MIDI to control](https://docs.tune.toys/nodes/midi.to-control/). Inside a [polyphonic group](https://docs.tune.toys/concepts/voices/) each voice's oscillator sees only that voice's note.

## When to use it

Use it as the main source of a synth patch, as a test signal, or for several detuned voices. Pair it with an [Envelope](https://docs.tune.toys/nodes/std.envelope/) for notes and a [Filter](https://docs.tune.toys/nodes/std.svf/) to shape the tone. To play chords with your own oscillator, filter and envelope, put them in a group and give it [voices](https://docs.tune.toys/concepts/voices/).

## Ports

<!-- ports:start -->

| Port    | Direction | Signal | Lanes                   |
| ------- | --------- | ------ | ----------------------- |
| `midi`  | Input     | MIDI   | 16 MIDI channels        |
| `audio` | Output    | Audio  | Inferred from the cable |

<!-- ports:end -->

## Parameters

<!-- parameters:start -->

| Parameter     | Label       | Range         | Default | Unit   | Scale  | Notes                                                                                                                                                                          |
| ------------- | ----------- | ------------- | ------- | ------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `frequency`   | Frequency   | 20 to 20000   | 220     | Hz     | log    | Fundamental pitch, capped below Nyquist; detune uses cents.                                                                                                                    |
| `amplitude`   | Level       | 0 to 0.5      | 0.12    | linear | linear | Output gain.                                                                                                                                                                   |
| `shape`       | Morph       | 0 to 3        | 0       |        | linear | Continuous sine/triangle/saw/pulse morph; only its two neighboring waveforms are evaluated. Shown when `type` is 0.                                                            |
| `pulse_width` | Pulse width | 0.05 to 0.95  | 0.5     |        | linear | Pulse duty cycle with a frequency-dependent safe edge width. Shown when `type` is 0 or 4.                                                                                      |
| `type`        | Type        | 0 to 7        | 0       |        | linear | Selects the implemented algorithm. Choices are discrete and are not LFO targets. Choices: 0 Morph, 1 Sine, 2 Triangle, 3 Saw, 4 Pulse, 5 Double saw, 6 Organ, 7 Harmonic bell. |
| `phase`       | Phase       | 0 to 1        | 0       | cycles | linear | Cycle offset; Gate rising edges restart phase from this position.                                                                                                              |
| `detune`      | Detune      | -1200 to 1200 | 0       | cents  | linear | Pitch offset in cents.                                                                                                                                                         |
| `gate`        | Gate        | 0 to 1        | 1       |        | linear | On or off. A rising edge retriggers; held on runs the oscillator or envelope. A control cable switches it at 0.5.                                                              |
| `bend_range`  | Bend range  | 0 to 48       | 2       | st     | linear | Semitones a full pitch bend on the MIDI input moves the note, up or down.                                                                                                      |
| `glide_ms`    | Glide       | 0 to 2000     | 0       | ms     | linear | Time constant of the slide from one MIDI note's pitch to the next; 0 jumps.                                                                                                    |

<!-- parameters:end -->

### Frequency (`frequency`)

The fundamental pitch, from 20 to 20000 Hz, capped below Nyquist.

### Level (`amplitude`)

Output gain from 0 to 0.5.

### Morph (`shape`)

Used when Type is Morph. 0 is sine, 1 is triangle, 2 is saw, 3 is pulse.

### Pulse width (`pulse_width`)

The pulse duty cycle, 0.05 to 0.95. It applies to Morph and Pulse. Edges are kept safe at high frequencies.

### Type (`type`)

Chooses the waveform. A discrete choice.

### Phase (`phase`)

A cycle offset from 0 to 1. A rising Gate restarts the wave from this position.

### Detune (`detune`)

A pitch offset from -1200 to 1200 cents (one octave each way).

### Gate (`gate`)

Defaults to on, so the oscillator runs. A rising edge retriggers the phase.

### Bend range (`bend_range`)

How far a full pitch bend on the `midi` input moves the note, 0 to 48 semitones each way. 2 is the usual keyboard range; set it to the MPE bend of a polyphonic group (48 by default) when you play it from an MPE controller.

### Glide (`glide_ms`)

The time constant, in milliseconds, of the slide from one MIDI note's pitch to the next. 0 jumps straight to each note; the first note always starts at its own pitch.

## Tips

- Detune two oscillators by a few cents and sum them for a thick tone.
- Use Pulse with a low Pulse width for a nasal, reedy sound.
- Keep Level low, then raise the monitor level.
- With a MIDI cable, a Frequency knob does nothing until you disconnect it: notes own the pitch.

## See also

[Envelope](https://docs.tune.toys/nodes/std.envelope/), [Filter](https://docs.tune.toys/nodes/std.svf/), [MIDI to control](https://docs.tune.toys/nodes/midi.to-control/), [Voices](https://docs.tune.toys/concepts/voices/).
