mirror of
https://gitlab.com/80486DX2-66/gists
synced 2024-11-08 08:54:34 +05:30
bytebeat-render.js: constrainValue
: floatbeat: fix?
This commit is contained in:
parent
427cca3e4c
commit
c989b8d2d9
@ -71,6 +71,8 @@ const generateAudio = t => {
|
||||
return t&t>>8
|
||||
}
|
||||
|
||||
const clamp = (a, b, c) => max(min(a, c), b)
|
||||
|
||||
let lastCorrectSample = 127 // FIXME: guessed value
|
||||
|
||||
const constrainValue = sample => {
|
||||
@ -85,7 +87,9 @@ const constrainValue = sample => {
|
||||
case TYPE_SIGNED_BYTEBEAT:
|
||||
return ((sample + 127) & 255) - 128
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user