# LFO and noise Citation forms: [start-here.md](start-here.md). Line numbers are IKAOPM 08a5b40's. ## LFO rate | Rule | Evidence | | --- | --- | | LFRQ (8 bits) sets the rate from about 53 Hz (0xFF) to about 0.008 Hz (0x00) at fM 3.579545 MHz; Fig. 2.16 lists all 256 | DOC (AM p.12, p.22, Fig. 2.16) | | The listed rates are exactly period = 2^30 / ((16 + LFRQ bits 3-0) << LFRQ bits 7-4) samples (sample = 64 / fM); e.g. 0xFF 52.9127 Hz, 0xF0 27.3098 Hz, 0xC0 3.4137 Hz | DOC (Fig. 2.16); the formula is ymfm's (ymfm 81aec25, ymfm_opm.cpp:195-199: "matches exactly the frequencies in the application manual") | | In the die: a 4-bit prescaler counts twice per sample; each carry advances a 15-bit counter preloaded from LFRQ bits 7-4; each of its overflows is one LFO clock, and a 4-bit counter of overflows adds extra clocks in the proportion LFRQ bits 3-0 / 16. One LFO cycle is 256 clocks | DIE (IKAOPM_lfo.v:72-216) | | Measured on the closed box (square AM, rising edges): 0xFF 1,056.8 samples (formula 1,057.03), 0xF8 1,365.6 (1,365.33), 0xF0 2,048, 0xE0 4,096, 0xD0 8,192, 0xC0 16,384 | OBSERVED (Nuked-OPM f209e6e, `reference/referee-measure.txt`) | | Half period from an LFO reset: 0x1F 8,650,667 samples, 0x0F 17,301,419 samples (formula 8,659,208 and 17,318,417; ratio 2.0000) | OBSERVED (Nuked-OPM f209e6e, `scripts/referee_survey.py`) | **C6.** For LFRQ 0x00-0x0F, IKAOPM's counter preload (0x1000 where the formula needs 0x0000; IKAOPM_lfo.v:127) gives 7/8 of the period. The manual's table (0x00: 0.0008 Hz, 0x0F: 0.0016 Hz) and the closed box (ratio 2.0000 between 0x0F and 0x1F, where IKAOPM gives 1.75) agree with each other against IKAOPM. The core follows the manual (DOC); IKAOPM's own run under Verilator is to be asked before rung 4 (decision 5). | Rule | Evidence | | --- | --- | | Test bit 1 holds the LFO in reset (the wave restarts from its start when released) | DOC (AM p.13, "TEST (LFO RESET)"); DIE (IKAOPM_lfo.v:251-279); OBSERVED (Nuked-OPM f209e6e: with bit 1 set the AM stays at one level) | | Test bit 2 makes the LFO (and both timers) clock every cycle; test bit 3 makes the 15-bit LFO counter count every cycle and puts the LFO clock on the CT1 pin (register bit 6) | DIE (IKAOPM_lfo.v:140, :215; IKAOPM_reg.v:442; IKAOPM_timer.v:53, :93) | | A write to LFRQ reloads the 15-bit counter | DIE (IKAOPM_lfo.v:143-151) | ## LFO waves and depth | Rule | Evidence | | --- | --- | | W 0 saw, 1 square, 2 triangle, 3 noise; AM is unsigned (0 = no attenuation), PM is signed; the manual's drawings fix each wave's start and direction | DOC (AM p.12, figure) | | AM and PM come from the same 8-bit LFO phase; the wave value (7 bits) is multiplied by AMD or PMD (7 bits, a fixed-point 1.6 number) by shift-and-add: the sum over k = 0..6 of (depth bit 6-k) x (value >> k), so each partial product is truncated | DIE (IKAOPM_lfo.v:233-509) | | The results are an 8-bit unsigned AM value and a sign + 7-bit PM value, refreshed alternately; PMD = 0 forces PM to 0 | DIE (IKAOPM_lfo.v:513-547) | | The noise wave takes bits from the noise generator, latched on LFO clocks | DIE (IKAOPM_lfo.v:288-296, IKAOPM_noise.v:74-75) | | Depth resolution 1/128; PMD and AMD share register 0x19 | DOC (AM p.12) | Where AM and PM go: [envelope.md](envelope.md) (AMS) and [phase-generator.md](phase-generator.md) (PMS). ## Noise | Rule | Evidence | | --- | --- | | NE = 1 turns channel 7's C2 (the 32nd slot) into the noise slot; its envelope still applies | DOC (AM p.11) | | Noise frequency fM / (32 (32 - NFRQ)): about 3.5 kHz (NFRQ 0) to 111.9 kHz (NFRQ 31); period of the sequence (2^17 - 1) / f | DOC (AM p.11, range and period; the printed formula reads "32 (NFRQ)", which contradicts its own range: C4) | | In the die: a 5-bit counter steps twice per sample and the noise register advances when it reaches 31 - NFRQ, i.e. every 32 - NFRQ half-samples; the register is a 17-bit maximal-length shift register (16 stages plus one), kept out of the all-zero state | DIE (IKAOPM_noise.v:39-75) | | Measured sign changes per sample 1/(32 - NFRQ) for NFRQ 0-30 (half the step rate of a random sequence), 0.4995 at NFRQ 31; the sign sequence at NFRQ 31 repeats after exactly 131,071 samples with 65,536 positive | OBSERVED (Nuked-OPM f209e6e, `reference/referee-measure.txt`) | | The noise slot's output is +-(the inverted attenuation level), linear in the level, sign from the noise bit: no log-sine or exponent | DOC (AM p.11: "transformations are not logarithmic"); DIE (IKAOPM_noise.v:90-130) | | On the closed box the readout is linear in the level: TL 0 reads +2040 / -2044, TL 1 2024 / -2028, TL 64 1016 / -1018, and it moves in steps of 8 per 4 units | OBSERVED (Nuked-OPM f209e6e, same file) | **U7.** At NFRQ 31 the die advances the noise twice per sample; output is taken once per sample, so the closed box's sign sequence cannot show whether it is two steps or one. **C5 (decision 9).** A muted noise slot (attenuation 1023, e.g. never keyed): IKAOPM outputs exactly 0 (IKAOPM_noise.v:83-86, :128); the closed box outputs -8 or 0 with the noise sign (`referee-measure.txt`: "never keyed ... [-8, 0]"). Decision 9 follows the referee and keeps the claim open; IKAOPM's vote, from reading, is "0", and its run gets a vote before rung 4. **C8.** ymfm models the noise register as clocked continually and sampled at the noise rate (ymfm 81aec25, ymfm_opm.cpp:175-191); IKAOPM advances it only at the noise rate. The two give different sequences per NFRQ; ymfm is a detector here and IKAOPM's reading is followed. A closed-box comparison of the exact sequence is owed to rung 3.