Console Sound Quantified

1

nathanielbabiak 2025-01-05 07:17 (Edited)

While sound occurs per the manual descriptions, the manual lacks quantitative detail for the ENVELOPE and LFO instructions.

The pseudocode below is based on reviewing the console source code. While the console accepts parameters 0-15, representing fractions 0/15-15/15, i.e., 0%-100%, the pseudocode formulas are performed internally by the console with additional precision. (They are not kept accurate merely to the nearest 1/15th fraction.)

ENVELOPE

ENVELOPE v,[a],[d],[s],[r]

Times in milliseconds for a, d, and r, 0-15 respectively:

0.002 0.03 0.06 0.09 0.14 0.21 0.31 0.47
0.7   1    1.6  2.4  3.5  5    8   12

Time in 60ths of a second (different units):

  0.12   1.8   3.6   5.4
  8.4   12.6  18.6  28.2
 42     60    96   144
210    300   480   720

The voice level is a fraction, and is used as the ADSR peak level (which occurs between a and d). The sustain s is a fraction of the voice level:

sustain_Level = voice_Level * s

If two notes are played consecutively on the same voice before the first note's envelope has had a chance to fully release, the initial level of the second note will be the sum of the second note's envelope and the remaining voice level from the first note.

LFO

LFO v,[r],[fr],[vol],[pw]

Rate in Hz for r, 0-15 respectively:

0.12 0.16 0.23 0.32 0.44 0.62 0.87 1.2
1.7  2.4  3.3  4.7  6.6  9.2 12.9 18

Rate in 60ths of a second (different units):

500   375   260.9   187.5
136.4  96.8  69.0    50.0
 35.3  25.0  18.2    12.8
  9.1   6.5   4.7     3.3

Frequency, volume, and pulse width are fractions. Waveform is used in the formulas below, it's developed by the console, and a fraction too.

If invert is enabled:

If the new values are out-of-range, they will be reset to the minimum or maximum allowable values.


SP4CEBAR 2025-01-05 07:59 (Edited)

Quoting from "sustain":

new_Level = old_Level * s


What is meant by "old_Level", is it a constant (15) or is it a dynamic value (like the last known value of new_Level)?

The following code:

FOR I=0 TO 3
  'Print the "envelope 2" audio register contents from voice 0
  PRINT PEEK($FF47)
  ENVELOPE 0,,,1,
NEXT I

Printed:

15
1
1
1

This implies that "old_Level" must be a constant 15.


Sylveon 2025-01-05 14:22

Thanks :3


nathanielbabiak 2025-01-05 16:28

Sp4cebar, good catch, I was unclear. I was trying to keep all the variable naming consistent in the pseudocode, but it didn't make much sense! It's revised now, check it out. :-)


Log in to reply.