PeriodicWave
We can define OscillatorNode for any periodic function f(t), defined by the domain [0, 2π), using PeriodicWave:
const ω = new OscillatorNode(
audioContext,
{
type: "custom",
frequency: frequency,
periodicWave: new PeriodicWave(
audioContext,
{real: a, imag: b}
),
}
);
where a and b are Float32Arrays.
APU-like Triangle
NES's pseudo-triangle wave repeats FEDCBA9876543210 and 0123456789ABCDEF:
| begin | end | value |
|---|---|---|
| 0 | π/16 | 1 |
| π/16 | π/8 | 13/15 |
| π/8 | 3/16 π | 11/15 |
| 3/16 π | π/4 | 3/5 |
| π/4 | 5/16 π | 7/15 |
| 5/16 π | 3/8 π | 1/3 |
| 3/8 π | 7/16 π | 1/5 |
| 7/16 π | π/2 | 1/15 |
| π/2 | 9/16 π | -1/15 |
| 9/16 π | 5/8 π | -1/5 |
| 5/8 π | 11/16 π | -1/3 |
| 11/16 π | 3/4 π | -7/15 |
| 3/4 π | 13/16 π | -3/5 |
| 13/16 π | 7/8 π | -11/15 |
| 7/8 π | 15/16 π | -13/15 |
| 15/16 π | π | -1 |
As a result, we obtain follows:
Top comments (0)