aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-20 17:05:52 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-02-20 17:05:52 -0500
commitfb3ec828f6da432c0cea2c8df465397d6a58093e (patch)
tree1dde1815b943032055bfbdcfb49aa2505c5aec00
parentbfaff369b3592826bc7d4e5aaba7161815733eea (diff)
Fix sign handling on integer wave file read
-rw-r--r--wav.bqn3
1 files changed, 2 insertions, 1 deletions
diff --git a/wav.bqn b/wav.bqn
index 5ac83aa..b35362f 100644
--- a/wav.bqn
+++ b/wav.bqn
@@ -66,7 +66,8 @@ _audioConvert ← {
_withInv_ ← {F _𝕣_ G: {π•Š:F𝕩 ; π•ŠβΌ:G𝕩}}
# Convert 𝕗-byte sequences to ints
_int ← {
- b ← 256 β‹„ (+⟜(bβŠΈΓ—)Λβˆ˜β‰βŒŠβ€Ώπ•—β₯ŠβŠ’) _withInv_ (β₯Šβˆ˜β‰βˆ˜>b|⌊∘÷⟜b⍟(↕𝕗))
+ b ← 256
+ (+⟜(bβŠΈΓ—)˝˜⟜(-(bΓ·2)≀¯1⊸⊏)Β·β‰βŒŠβ€Ώπ•—β₯ŠβŠ’) _withInv_ (β₯Šβˆ˜β‰βˆ˜>b|⌊∘÷⟜b⍟(↕𝕗))
}
# Convert int to float
_float ← {eβ€Ώmβ€Ώb←𝕗 # exponent and mantissa length in bits; bias