mirror of
https://gitlab.com/80486DX2-66/gists
synced 2025-05-31 08:31:41 +05:30
bytebeat-render.js: constrainValue
: floatbeat: fix?
This commit is contained in:
@@ -71,6 +71,8 @@ const generateAudio = t => {
|
|||||||
return t&t>>8
|
return t&t>>8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const clamp = (a, b, c) => max(min(a, c), b)
|
||||||
|
|
||||||
let lastCorrectSample = 127 // FIXME: guessed value
|
let lastCorrectSample = 127 // FIXME: guessed value
|
||||||
|
|
||||||
const constrainValue = sample => {
|
const constrainValue = sample => {
|
||||||
@@ -85,7 +87,9 @@ const constrainValue = sample => {
|
|||||||
case TYPE_SIGNED_BYTEBEAT:
|
case TYPE_SIGNED_BYTEBEAT:
|
||||||
return ((sample + 127) & 255) - 128
|
return ((sample + 127) & 255) - 128
|
||||||
case TYPE_FLOATBEAT:
|
case TYPE_FLOATBEAT:
|
||||||
return floor(sample * 127) + 127
|
// NOTE: temporary fix copied from a code by lehandsomeguy, see https://
|
||||||
|
// www.reddit.com/r/bytebeat/comments/48r00a/floatbeat_test/
|
||||||
|
return floor((clamp(sample, -0.9999, 0.9999) * 128) + 128)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user