↘ drag the bottom-right corner to resize — content scales with the box
Plot data generation — formula chain
original 14-bit sine → ×1.5 float → −5000 offset → MSB-flip read as 14-bit signed (wrapped) · sampled at f
s
= 1 Hz (t = n·1 s)
A =
8191
P = 50/1.5 ≈
33.33
G =
1.5
OFF =
5000
f
s
=
1 Hz
n =
0 … 200
1
original 14-bit signed sine (quantized samples)
x[n] = round( A · sin(2πn / P) )
2
to float, multiply ×1.5, round back to fixed (→ 15-bit signed)
y[n] = round(
G
· x[n] ) = round( 1.5 · x[n] )
3
subtract DC offset 5000
z[n] = y[n] −
OFF
= round(1.5·x[n]) − 5000
4
{ ~z[13], z[12:0] } read as 14-bit signed = wrap into [−8192, +8191] (plotted value)
a[n] = wrap( z[n] ) = ( ( z[n] + 8192 ) mod 16384 ) − 8192
nonneg modulo: x mod m = ((x % m) + m) % m
5
overflow flag (red dots = wrapped samples)
folded[n] = ( | z[n] | > 8191 )
~
reference envelope (green dashed) — no round, no wrap
z
ideal
(t) = 1.5·8191·sin(2πt/P) − 5000
xy
data → SVG pixel mapping
x
px
= M
X
+ (t / t
max
)·P
W
y
px
= TOP + ((y
max
−v)/(y
max
−y
min
))·P
H
t
max
=200, y
min
=−17900, y
max
=7900
representative values (envelope extremes)
sin
x
y=1.5x
z=y−5000
a=wrap(z)
0
0
0
−5000
−5000
+1
8191
12287
+7287
+7287
−1
−8191
−12286
−17286
−902 (fold)
one-line composite
a[n] = ( ( round(1.5·round(8191·sin(2πn/33.33))) − 5000 + 8192 ) mod 16384 ) − 8192