better smallmode documentation
This commit is contained in:
parent
34fcd7f941
commit
b0c388efff
27
smallmode
27
smallmode
|
@ -1,27 +0,0 @@
|
|||
// true/false
|
||||
|
||||
mode & 0x80: statement/expression
|
||||
mode & 0x40: function/number
|
||||
mode & 0x20: sec/sample
|
||||
mode & 0x10: clip/wrap
|
||||
|
||||
num = mode & 0x0f
|
||||
if (num < 11) {
|
||||
// integer
|
||||
|
||||
2**(num >> 1) bit depth output
|
||||
mode & 1: unsigned/signed
|
||||
} else {
|
||||
// float
|
||||
// 5 states (11 <= num < 16)
|
||||
if (num == 11) {
|
||||
// unused, feel free to use (mode & 0xf0) for whatever
|
||||
} else if (num) {
|
||||
byte & 2: (currently unused, normal is 0. maybe float32/float64?)
|
||||
byte & 1: unsigned/signed (min = -1.0 or min = 0)
|
||||
} else {
|
||||
// unused, feel free to use (mode & 0xf0) for whatever
|
||||
}
|
||||
}
|
||||
|
||||
total 8 bits!
|
|
@ -0,0 +1,36 @@
|
|||
smallmode is a method to store a bytebeat "mode" (bytebeat, floatbeat, funcbeat) in a single byte.
|
||||
the tiny data is great for encoding into a small url or file.
|
||||
it allows a ton of things and has plenty of unused areas in case you want to add more features.
|
||||
|
||||
no player has all of these features yet but i considered everything that seemed reasonable to implement.
|
||||
i will not change anything already defined in the format because i already made my urls and backwards compatibility should stay forever.
|
||||
|
||||
some pseudo javascript to show how the format works:
|
||||
```js
|
||||
mode & 0x80 ? /* code is statements */ : /* code is an expression */
|
||||
mode & 0x40 ? /* returns a function */ : /* returns a number */
|
||||
mode & 0x20 ? /* time as seconds */ : /* time as sample number */
|
||||
mode & 0x10 ? /* clip out of range samples */ : /* wrap out of range samples */
|
||||
|
||||
const num = mode & 0x0f;
|
||||
if (!num) {
|
||||
// unused, would be 1 bit signed but that's a pretty stupid mode
|
||||
// 0x00 is an invalid mode and will NEVER be standardized
|
||||
// if you want an unusual custom mode, i highly suggest using 0x00 and putting some extra data after it
|
||||
} else if (num < 11) {
|
||||
// integer
|
||||
|
||||
2**(num >> 1) // bit depth of output
|
||||
mode & 0x01 ? /* unsigned output */ : /* signed output */
|
||||
// when unsigned, the output is in the range [0, 2**2**(num >> 1))
|
||||
// when signed, the output is in the range [-(2**2**(num >> 1)), 2**2**(num >> 1) / 2)
|
||||
} else if (num === 11) {
|
||||
// unused, would be 32 bit unsigned but javascript doesn't support that for normal numbers
|
||||
} else if (num < 13) {
|
||||
// float
|
||||
|
||||
mode & 0x01 ? /* from 0.0 to 1.0 */ : /* from -1.0 to 1.0 */
|
||||
} else {
|
||||
// unused
|
||||
}
|
||||
```
|
|
@ -2,7 +2,7 @@ import { deflateSync, inflateSync } from "fflate";
|
|||
import { from89 } from "./base89.ts";
|
||||
import type { Song, SongMode } from "../common.ts";
|
||||
|
||||
// see smallmode text file
|
||||
// see smallmode.md
|
||||
const smallmode_table = {
|
||||
Bytebeat: 0b00000111,
|
||||
"Signed Bytebeat": 0b00000110,
|
||||
|
|
Loading…
Reference in New Issue