FANCO16 / v8 / sound

SIREN

Sixteen operators. Eight filtered-noise generators. One programmable signal path.

This is the complete v8 sound reference. Addresses and register offsets are hexadecimal; counts, bit numbers and physical units are decimal. Words are unsigned, little-endian unless stated otherwise. Every section heading has a permanent link.

Signal path and clocks

Operators + noise Mixers + filters Dry + delay network Master + limiterStereo output

CPU timer IRQs and chip control ticks are separate. The guest writes desired register values; the chip latches the configuration on its fixed control grid. Supported responses then move toward their targets at audio rate. A group of writes must finish before the latch boundary to take effect together.

Instrument recipes, notes, envelopes and automation belong in the guest's 64 KB address space. General program/data RAM and envelope records start at 0600. Chip working state, including delay buffers, lives outside that space. The browser transports the VM's output; synthesis and effects run inside SIREN.

Register chart

Address Block Layout
0040–005F Compact aliases Selected controls for operators 0–2
00D0–00E7 Capture 2 descriptors × 12 bytes
0100–02FF Operators 16 operators × 32 bytes
0300–0327 Operator mixer 8 slots × 5 bytes
0328–0342 Shared filters 3 filters × 9 bytes
0343 Coarse master Low nibble, 0–15
0344–03F3 Delay network 8 lines × 22 bytes; 2 taps per line
03F4–03F5 Control rate Fixed at 600 Hz; writes have no effect
03F6 Status Error bits
03F7 Fine master 0–255
03F8–03FA Output protection Mode, ceiling, release
0480–04FF Shared-source mixer 16 slots × 8 bytes
0500–057F Filtered noise 8 generators × 16 bytes
0580–05FF Reserved Writes stored; no audio effect

Operators

Operator n starts at 0100 + n × 20, for n = 0–15. Each can generate classic waveforms or an additive bank of up to eight partials.

Offset Field Meaning
+00–01 Frequency / pitch Raw frequency word, or musical pitch when FLAGS bit 0 is set
+02–03 Width / stiffness Classic: low 12 bits set pulse duty. Additive: full word × 10−7 sets stiffness
+04 CONTROL Gate, sync, phase-ring, test and waveform selection
+05 AD High nibble attack, low nibble decay
+06 SR High nibble sustain, low nibble release
+07 EXTRA / polarity Classic: sine, constant and combination mode. Additive: bit i inverts partial i's right channel
+08 Modulation Source operator in bits 0–3; method in bits 4–6; bit 7 ignored
+09 Modulation depth 0–255
+0A Self-feedback Phase-feedback amount, 0–255
+0B Shape Phase skew, native-noise color or constant level
+0C–0D Envelope pointer Zero selects ADSR; otherwise points to a nine-byte guest record
+0E FLAGS Pitch format, noise type, restart, envelope curve, legato, structural opt-out, retrigger
+0F NOTE MIDI note 0–127; FF releases
+10 BANK Additive mode, extension mode, feedback mode, preset and partial count
+11 Leader Extension's leader index, low nibble
+12 First partial First harmonic number; zero means one
+13 Weight response One response byte shared by the bank's eight weights
+14–17 Weights Eight nibbles, low nibble first; 0 off, 15 unity
+18–1B Residual tuning Eight signed nibbles, −8…7; four cents per step
+1C–1F Partial pan Eight nibbles; 0 left, 8 center, 15 near right

Waveforms and pitch

CONTROL bit Function
0 Gate: held note when set
1 Sync: reset phase on the selected source's wrap
2 Phase-ring: invert triangle according to the source oscillator's phase
3 Test: hold oscillator/noise clock at reset; output zero
4 / 5 / 6 / 7 Triangle / saw / pulse / noise

EXTRA bit 0 adds sine; bit 1 adds a constant signal. Bits 6–7 select how enabled components combine: 0 average, 1 product, 2 eight-bit XOR, 3 eight-bit AND. No selected components gives silence.

Musical: Hz = 440 × 2^((word − 32768) / 3072)
Raw:     Hz = word × 985248 / 16777216
Pulse:   duty = (width & 4095) / 4096

Musical pitch 8000 is A4, 440 Hz; 0100 is one semitone and 0C00 one octave. Raw zero gives zero frequency. Shape 80 is neutral for sine, triangle and saw; other values warp their phase split. Pulse duty is independent of Shape. A constant uses Shape / 127.5 − 1.

Operator noise has two modes: a 23-bit LFSR clocked sixteen times the oscillator rate, or colored xorshift noise updated on oscillator wraps. Shape controls the colored-noise low-pass. These operator noise modes are separate from the eight filtered-noise generators.

Modulation

Method Action
0 None
1 Phase modulation: source × depth / 64 added to phase
2 Enveloped AM/ring: multiply by 1 − d + d × source, where d = depth / 255
3 Phase sync
4 Pitch modulation, source × depth × 4 musical-pitch steps
5 Pulse-width modulation, source × depth / 512 added to duty
6 Phase-ring
7 Phase sync and phase-ring together

CONTROL sync/ring and the modulation field share one source index. Phase-ring affects triangle only. Modulation reads an operator's enveloped output before mixer gain, so an inaudible operator can still be a modulation source.

Raw-frequency oscillators advance together before their phase connections. Operators then evaluate in index order; an upstream output can be from this sample or the preceding sample according to that order. A structural crossfade supplies one blended modulation signal, not recursively duplicated source chains.

Self-feedback adds the sum of the two preceding feedback samples × amount / 1024 to phase. Additive feedback selection is described below.

Operator FLAGS

Bit Function
0 Musical pitch; clear for raw frequency
1 Colored xorshift operator noise; clear for clocked LFSR
2 Restart oscillator/partial phases on a rising gate or retrigger
3 Exponential ADSR decay/release; attack remains linear
4 Legato NOTE: do not retrigger an already held note
5 Disable automatic structural smoothing for this operator
6 Reserved
7 Write-one envelope retrigger command; self-clearing

NOTE and retrigger

Writing 00–7F sets a MIDI note, selects musical pitch, turns the gate on and requests an envelope retrigger. Legato suppresses retrigger while already held. FF releases. 80–FE is invalid and leaves the last valid desired state unchanged, setting status bit 1.

NOTE reads back FF after a CPU write. Repeated equal writes are commands, but commands within one control tick collapse to the latest desired state. Release cancels a pending trigger; retrigger while gate is off has no audible effect. Retrigger starts the envelope from zero; phase restart is separately controlled by FLAGS bit 2.

A gate-off/on pulse entirely between control ticks can disappear. Use NOTE or the explicit retrigger command for a new hit. NOTE does not change waveform, envelope configuration, routing, pan or effects. Image loading clears command actions; configured gates may be on without treating initial NOTE bytes as commands.

Envelopes

Each operator has an output envelope. Choose compact ADSR or a custom four-segment record. Guest-written mixer gains and additive weights can provide additional independent envelopes through their response controls.

Compact ADSR

AD contains attack/decay rate indices; SR contains sustain/release. Sustain is its nibble divided by 15. Attack rises linearly to 1, decay approaches sustain, and release approaches zero.

Rate indices and nominal times in seconds
Index Attack Decay / release Index Attack Decay / release
0 0.002 0.006 8 0.100 0.300
1 0.008 0.024 9 0.250 0.750
2 0.016 0.048 A 0.500 1.500
3 0.024 0.072 B 0.800 2.400
4 0.038 0.114 C 1.000 3.000
5 0.056 0.168 D 3.000 9.000
6 0.068 0.204 E 5.000 15.000
7 0.080 0.240 F 8.000 24.000

Linear decay/release times describe a full-scale change; smaller changes take proportionally less time. With FLAGS bit 3 set, the nominal time reduces the remaining error to 0.1%. This ADSR timing differs from the 10%-remaining definition of exponential parameter responses.

Custom envelope record

+0 level 0   +1 time 0
+2 level 1   +3 time 1
+4 level 2   +5 time 2
+6 level 3   +7 time 3
+8 flags

Levels are 0–255. Time code 0 is immediate; otherwise T = 0.001 × 2^((t − 1) / 16) seconds, up to about 60 seconds. Flag bits 0–3 choose exponential curves for the corresponding segments; bits 4–5 choose the sustain segment; bit 6 enables sustain; bit 7 loops the first three segments while held. Release enters segment 3.

A nonzero pointer must be 0600–FFF7, so all nine bytes fit guest RAM. Writing its high byte commits the record; a word store commits once. The CPU snapshots nine bytes at instruction retirement, costing nine additional virtual CPU DMA cycles. Audio consumes the snapshot, not later RAM edits.

The latest valid snapshot becomes the next-trigger configuration at a control tick; committing does not itself retrigger. A held note keeps its active record. Edit RAM and recommit to change the next record. Pointer zero selects compact ADSR on the next trigger. An invalid pointer sets status bit 0 and preserves the last valid configuration.

Additive partials

BANK bits Meaning
7 Enable additive mode
6 Extension bank: attach to the leader selected at +11
5 Normalized sum feedback; clear for fundamental-only feedback
3–4 Preset: 0 flat, 1 saw-like, 2 odd harmonics, 3 triangle-like
0–2 Active partial count minus one, giving 1–8 partials

Flat gives equal base weights; saw-like uses 1/n; odd uses 1/n on odd harmonics only; triangle-like uses alternating signs on odd 1/n² harmonics. Each weight nibble attenuates that base weight: 15 = 0 dB, 14 = −3 dB, down to 1 = −42 dB; 0 is off.

f(n) = n × f(1) × sqrt((1 + B × n²) / (1 + B)) × 2^(cents / 1200)
B = stiffness word × 10^−7
cents = signed tuning nibble × 4

Each partial has its own running phase. Weights fade above 22 kHz and reach zero at 24 kHz. Phase skew and feedback can create sidebands; there is no oversampling mode. Pan nibble 8 is center, 0 hard left and 15 near right. EXTRA bit i reverses partial i's right-channel polarity.

Extension banks

An extension attaches directly to a non-extension additive leader. It inherits the leader's pitch, stiffness, trigger and output envelope, while keeping its own weights, weight response, tuning and pan. It consumes an operator but no additional output mixer slot. All extensions participate in the leader evaluation regardless of their register index.

FIRST = 9 extends the harmonic range; FIRST = 1 adds another layer over the same harmonic numbers. Self-links and links to non-leaders are invalid and set status bit 1.

Feedback and modulation

With BANK bit 5 clear, feedback uses the fundamental. With it set, feedback uses the weighted combined bank, normalized by max(1, sum(abs(weights))). It is sample-delayed and taken before stereo panning. Additive AM affects only the bank's first partial.

Parameter responses

One byte describes how a parameter moves toward its next target. This encoding is shared by additive weights, shared-mixer gain/pan, and noise cutoff/gain.

q = byte & 63
T = 2^(q / 5) / 600 seconds
Top two bits Response Meaning of T
00 Damped spring Characteristic response time; damping ratio 0.69; overshoot allowed
01 Linear Arrives at target after T
10 S-curve Arrives after T, with eased start and end
11 Exponential Remaining error falls to 10% after T

Special case: byte 00 means immediate, not spring. For example, 40 is a 1.667 ms linear ramp, and 4C is about 8.797 ms.

New targets start from the current value. Repeating an unchanged target with the same response does not restart motion. Spring motion preserves velocity across target changes. Responses advance at 48 kHz while targets latch at 600 Hz. Noise cutoff moves in Hz, gain in linear amplitude and mixer pan in signed linear position. Pan is clamped at output.

Responses describe movement of individual parameters. Structural crossfades instead blend two complete sound paths when a configuration change would abruptly change the sound.

Filtered-noise generators

Generator n starts at 0500 + n × 10, for n = 0–7.

Offset Field Meaning
+00–01 High-pass cutoff Hz; zero bypasses
+02–03 Low-pass cutoff Hz; zero or ≥24,000 bypasses
+04–05 Gain Unsigned U4.12 amplitude; 4,096 = 1
+06 High-pass response Response byte
+07 Low-pass response Response byte
+08 Gain response Response byte
+09 Control Bit 0 enable; bit 6 structural-smoothing opt-out; bit 7 reset strobe
+0A Filter stages Bits 0–1 high-pass stages minus one; bits 2–3 low-pass stages minus one
+0B–0F Reserved No audio function
Independent white-noise stream
    → high-pass cascade → low-pass cascade → gain → mixer source

Each generator has an independent deterministic xorshift32 stream, uniform in [−1, 1). Filters use trapezoidal state-variable integration at 48 kHz, with second-order Butterworth sections, Q = 1/√2.

Each cascade has 1–4 sections at one cutoff, giving 12, 24, 36 or 48 dB/octave. Each section contributes −3 dB at its cutoff. Active cutoff is clamped to 5–21,600 Hz. Cutoffs are independent: an inverted band attenuates both sides rather than swapping them.

Disable outputs zero and freezes the random stream and filter history. Parameter responses keep advancing. Generator outputs are mixer source IDs 16–23 and capture IDs 10–17.

What does noise reset mean?

Writing bit 7 of +09 requests a reset at the next control tick. It clears the high-pass and low-pass filter histories and restores that generator's initial random seed. The command bit is then cleared. It is distinct from disabling a generator, setting gain to zero, or restarting an operator envelope.

Reset participates in the 80-sample structural crossfade while the generator stays enabled, unless the program opts out. The outgoing path keeps its filters, random stream and gain response. The incoming path clears its filter histories, restores its initial seed and starts at the newly requested gain. See state handling.

Mixers

Mixers select sources independently of synthesis. The same source may feed multiple slots. Mixer gain includes a fixed factor of 1/3; the full-volume master adds a factor of 1/2. Signed pan −127 is left, 0 center, +127 right; −128 is treated as −127. Mixer panning is linear, with unity per channel at center.

Eight operator-only slots

Slot n: 0300 + n × 5.

Offset Meaning
+00–01 Low four bits: operator index. Upper 12 bits: gain, 0–4,095 mapped to 0–1
+02 Signed pan
+03 Route: 1–3 shared filters; otherwise dry stereo bus
+04 Delay send, 0–255 mapped to 0–1, on dry routes

Sixteen shared-source slots

Slot n: 0480 + n × 8.

Offset Meaning
+00 Bit 7 enable; bits 0–4 source ID: 0–15 operators, 16–23 filtered noise, 24–31 reserved/silent
+01 Signed pan
+02–03 Gain, 0–65,535 mapped to 0–1
+04 Route: 1–3 shared filters; otherwise dry stereo bus
+05 Delay send, 0–255 mapped to 0–1, on dry routes
+06 Gain response
+07 Pan response

An additive leader's dry route preserves its partial stereo image. Its effect send receives the stereo average. Routing through a shared mono filter collapses stereo. Select the additive leader, not its extension, to mix the combined bank.

Three shared filters

Filter n: 0328 + n × 9, for n = 0–2. Mixer routes 1–3 select these filters. All slots on one route sum into that filter.

Offset Meaning
+00–01 Cutoff on the musical pitch scale; 8000 = 440 Hz
+02 Resonance, 0–255; damping coefficient k = 2 − 1.96 × value / 255
+03 Mode bits: 0 low-pass, 1 band-pass, 2 high-pass; selected outputs sum. Zero bypasses
+04 Output level, 0–255 mapped to 0–1
+05 Signed pan; equal-power output panning
+06 Delay send, 0–255 mapped to 0–1
+07 Bit 7 enables cutoff modulation; low nibble selects operator
+08 Modulation depth; source × depth × 48 pitch steps added to cutoff

These are trapezoidal state-variable filters with audio-rate cutoff modulation. They are separate from the dedicated high-pass/low-pass cascades inside each noise generator. Shared-filter parameters have no response-byte fields.

Eight-line delay network

Line n: 0344 + n × 16. Each 22-byte line has two taps. A shared mono effect-send bus feeds the lines; taps return signed stereo output and can feed any of the eight lines. Delay, chorus, flanger, echo and reverb are guest configurations of this network.

Offset Meaning
+00 Input gain, 0–255 mapped to 0–1
+01 Damping: zero bypasses; otherwise one-pole coefficient 1 − value / 256
+02 Mode bit 0: first tap operates as an allpass
+03 Signed allpass gain / 128
+04–0C Tap 0, nine bytes
+0D–15 Tap 1, nine bytes

Tap fields

Tap offset Meaning
+00–01 Fractional delay position, encoded below
+02 / +03 Signed left / right output gain, each divided by 128
+04 Signed feedback gain / 128
+05 Feedback route mask: bit j sends to line j
+06 Negative mask: invert feedback for the corresponding destination
+07 Bit 7 enables position modulation; low nibble selects operator
+08 Modulation depth; source × depth × 2 samples added to position

Position uses a four-bit exponent and twelve-bit mantissa, in units of 1/256 sample:

e = word >> 12; m = word & 4095
samples = e == 0 ? m / 256 : (4096 + m) × 2^(e − 1) / 256

Positions are clamped to 1…524,286 samples and read with linear interpolation. Each line has 524,288 samples of internal storage, about 10.9 seconds. The eight float buffers total 16 MiB of chip working memory.

Feedback reaches its destination one sample later. Damping acts on the input plus feedback before writing the line. In allpass mode, tap 0 uses written = input + g × delayed and output = delayed − g × written. Large feedback gains can build unstable loops; the output limiter protects the final bus, not the contents of the delay buffers.

Master volume and output protection

Address Meaning
0343 Coarse master: low nibble / 15
03F7 Fine master: byte / 255
03F8 Mode: bit 0 limiter off; bit 1 soft clip on
03F9 Ceiling: byte / 256 of full scale; zero selects 243/256, about 95%
03FA Limiter release: byte × 10 ms; zero selects 100 ms

Master scaling is 0.5 × coarse / 15 × fine / 255, applied to the combined dry and effect signal before output protection.

Mode Path
0, default Look-ahead limiter
1 Raw output, clamped to ±1
2 Limiter, then soft clip
3 Soft clip only

The limiter uses a 96-sample look-ahead window, approximately 2 ms, to lower gain before a peak arrives. Signals below the ceiling pass unchanged. Every mode delays output by 95 samples and ends with a ±1 clamp, so changing mode does not shift timing.

For soft clipping above ceiling c, t = (|x| − c) / (1 − c) and output magnitude is c + (1 − c) × t / (1 + t); the original sign is retained.

Structural crossfades

Design rule: smoothly exchange complete sound paths when a waveform switch, filter-stage change, reset or another structural operation would otherwise cause an abrupt sound change. Keep ordinary parameter responses for controls that already move continuously.

Old configuration + running state → old sound → fade out ─┐
                                                         ├→ mixer
New configuration + running state → new sound → fade in ──┘

output = (1 − w) × old sound + w × new sound

The crossfade lasts exactly one control tick: 80 samples, or 1/600 second. A precomputed S-curve starts at exactly 0 and ends at exactly 1. Both paths keep running during the transition. The incoming path starts immediately, without a one-tick wait. After sample 80, discard the outgoing path.

At most two versions of a unit run. Another change on the next tick starts a new transition without accumulating copies. Downstream modulation, mixing, effects and output protection receive the blended result.

Required behavior and current coverage

Change Current implementation Required behavior / open work
Classic waveform selection Crossfades CONTROL bits 4–7 and EXTRA bits 0–1 Covered
Classic combination method Crossfades EXTRA bits 6–7 Covered
Noise filter stage counts Crossfades complete paths when the generator stays enabled, including resets Covered
Noise reset Crossfades the outgoing path into the reset state at the newly requested gain Covered while enabled; opt-out preserves hard reset
Noise cutoff changes Instant changes crossfade; explicitly ramped changes use their response bytes Covered while enabled, including switching an unfinished ramp to instant
Enable/disable or cutoff bypass Instant cutoff changes into/out of bypass crossfade while enabled Enable/disable and bypass crossings during ramps remain open
Entering/leaving additive mode No structural crossfade Coverage still open
Other abrupt changes No universal structural detector Enumerate triggers and state handling explicitly; the broad design rule is not yet complete coverage

Current limitation: structural smoothing covers the cases above, not every possible abrupt register change. Enable/disable and additive-mode transitions remain open work.

State sharing and opt-out

Operator FLAGS bit 5 and noise control bit 6 disable structural smoothing for deliberate hard switches. Smoothing is enabled by default. There is no global switch or adjustable crossfade duration. The first control tick initializes directly.

A classic waveform transition shares phase, pitch, envelope and modulation controls. Each path retains its waveform configuration and colored-noise history. Both paths read the same modulation-source output; source chains are not duplicated. The blend drives feedback and downstream modulation.

For noise transitions, the outgoing path retains its filters, random stream and running responses. The incoming path copies that state, clears newly added filter stages, and accepts the new cutoff targets. Its gain starts at the newly requested value; the structural S-curve replaces the gain response for this transition so old gain cannot pass through new filters. A reset also clears all incoming filter histories and restores its initial seed. Both paths advance independently. Later gain-only updates use their ordinary response and do not restart the crossfade.

Work budget

Worst case: a guest changes every eligible generator on every 600 Hz tick, so both paths run continuously. Capacity must be measured on the user's real device while sustaining the virtual CPU clock. The real-device cost of that worst case has not yet been measured. Additional transition state is chip working memory, not guest instrument content.

Audio capture

Two descriptors start at 00D0 and 00DC. Each captures a selected internal source into guest RAM from an 8,192-sample history buffer.

Offset Meaning
+00 Source: 00–0F operators, 10–17 noise, 20–22 shared filters, 30 left, 31 right, 32 stereo average
+01 Format: 0 mapped unsigned byte, 1 signed 16-bit little-endian
+02–03 Destination address
+04–05 Sample count; at most 4,096 and bounded by history/interval
+06–07 Destination stride; zero selects format width
+08 Sample interval; zero means one
+09 / +0A Byte-format mapping endpoints for −1 and +1
+0B Bit 0 enable, bit 1 one-shot, bit 7 done

Capture occurs at 400-sample machine frame boundaries, 120 Hz, independently of guest musical timers. Both channels end at the same frame. Capture clamps to ±1; signed format maps full scale to ±32,767. Writes below 0600, including wrapped low addresses, are skipped. One-shot clears enable after completion.

Status and reset defaults

03F6 bit 0 reports an invalid envelope pointer; bit 1 reports an invalid NOTE or additive leader. CPU writes clear the written bits; zero clears all. 03F4–03F5 remain fixed at 600 Hz.

Operators reset to raw frequency zero, pulse width 0800, saw selected with gate off, AD 00, SR F3, EXTRA zero, depth/feedback zero, Shape 80, pointer zero, FLAGS zero and NOTE FF. FIRST is 1; partial pans are centered and weights are zero.

Default modulation sources for operators 0–2 are 2/0/1; other operators select the preceding operator. The eight operator mixer slots select operators 0–7 at full gain, centered, with no effects send. Coarse and fine master are full. Shared mixer and noise registers/states reset to zero except deterministic stream seeds. Capture defaults to left and right output, disabled. The limiter is enabled.

Compact register aliases

0040–0054 provide three seven-byte groups for operators 0–2, mapping frequency, pulse width, CONTROL, AD and SR to the same underlying operators. Writing an aliased frequency selects raw-frequency mode.

0058 sets the coarse master through its low nibble. At 005B, bits 0–2 enable sine for operators 0–2 respectively. Other addresses in this alias region do not add sound controls. Use the full operator bank for modulation, custom envelopes and additive synthesis.