nish 0.46.0 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/AI.md +29 -18
- package/package.json +5 -5
- package/runtime/nish.h +1 -0
- package/runtime/runtime-bytes.c +167 -7
- package/runtime/runtime-net.c +69 -25
- package/runtime/runtime-uring.c +111 -62
- package/runtime/sqlite/nish-sqlite.c +166 -39
- package/std/README.md +2 -2
- package/std/base64.ts +28 -30
- package/std/crypto/aes.ts +81 -45
- package/std/crypto/bcrypt-batch.ts +23 -4
- package/std/crypto/bcrypt.ts +36 -11
- package/std/crypto/chacha20poly1305.ts +93 -52
- package/std/crypto/x25519.ts +7 -4
- package/std/host/game.ts +52 -20
- package/std/host/ring.ts +115 -31
- package/std/host/text.ts +9 -3
- package/std/json.ts +83 -0
- package/std/math.ts +161 -131
- package/std/net/http1-server.ts +36 -11
- package/std/net/prefork.ts +1 -2
- package/std/net/static.ts +7 -2
- package/std/random.ts +34 -51
- package/std/raster.ts +360 -110
- package/std/regex.ts +46 -15
- package/std/release.ts +19 -13
- package/std/sqlite.ts +380 -16
- package/std/synth.ts +11 -2
- package/std/temporal.ts +740 -363
- package/std/term-io.ts +81 -33
- package/std/term-pixels.ts +287 -112
- package/std/term-probe.ts +7 -3
- package/std/term-rate.ts +142 -66
- package/std/term.ts +782 -406
- package/std/testing.ts +14 -7
package/std/synth.ts
CHANGED
|
@@ -101,11 +101,19 @@ export const synthTone = (
|
|
|
101
101
|
}
|
|
102
102
|
const from: i32 = toI32(start * rate)
|
|
103
103
|
const n: i32 = toI32(length * rate)
|
|
104
|
+
// Never true: `start` is not negative here. The test is what proves `from + i`
|
|
105
|
+
// stays a sample index.
|
|
106
|
+
if (from < 0) {
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
const size: i32 = toI32(out.length)
|
|
104
110
|
const ratio: f64 = Math.log(f1 / f0)
|
|
105
111
|
let phase: f64 = 0.0
|
|
106
112
|
let noise: i32 = SYNTH_NOISE_SEED
|
|
107
113
|
let held: f64 = 0.0
|
|
108
|
-
|
|
114
|
+
// `at` is `from + i`, counted on its own so the test against `size` bounds it.
|
|
115
|
+
let at: i32 = from
|
|
116
|
+
for (let i: i32 = 0; i < n && at < size; i++) {
|
|
109
117
|
const t: f64 = toF64(i) / rate
|
|
110
118
|
const f: f64 = f0 * Math.exp((ratio * toF64(i)) / toF64(n))
|
|
111
119
|
const before: f64 = phase
|
|
@@ -128,7 +136,8 @@ export const synthTone = (
|
|
|
128
136
|
}
|
|
129
137
|
const attack: f64 = Math.min(t / 0.002, 1.0)
|
|
130
138
|
const release: f64 = Math.min((length - t) / 0.005, 1.0)
|
|
131
|
-
out[
|
|
139
|
+
out[at] = out[at] + v * volume * attack * release * Math.exp(-t * decay)
|
|
140
|
+
at = at + 1
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
143
|
|