54 lines
1.4 KiB
Markdown
54 lines
1.4 KiB
Markdown
# libbytebeat
|
|
|
|
A [bytebeat](https://bytebeat.ficial.net/) playback library (no
|
|
affiliation with the linked site). Can be embedded in a C
|
|
application via the C API or in a JavaScript one by vendoring
|
|
`src/bblib.js`. Features:
|
|
|
|
- seems to work
|
|
- custom metadata format
|
|
- automatically fixes DC offset with a high-pass filter
|
|
- two-phase multithreaded playback (does not work with some songs, but
|
|
they can be adapted to the two-phase system). First phase generates
|
|
samples and possibly a numbers array of auxiliary data and is
|
|
multithreaded, second phase is single-threaded, linear, processes
|
|
generated samples further. First-phase is expected to be a pure
|
|
function and should not depend on side effects from previous samples
|
|
(except the 0th one), second phase may do this however and is thus
|
|
useful for reverbs and other filters.
|
|
|
|
## Try it out
|
|
|
|
Build it (dependencies: webkitgtk, glib, GNU Autotools):
|
|
|
|
```
|
|
( autoreconf --install &&
|
|
mkdir -p build &&
|
|
cd build &&
|
|
../configure && make )
|
|
```
|
|
|
|
Run it:
|
|
|
|
```
|
|
build/bytebeat-gen < example-song.js | ./parse.sh
|
|
```
|
|
|
|
Or (no build required):
|
|
|
|
```
|
|
node parse.js example-song.js
|
|
```
|
|
|
|
## C API
|
|
|
|
see `src/bytebeat.h`, also `src/bytebeat-gen.c` for an example usage
|
|
|
|
## Exotic ByteBeat APIs
|
|
|
|
`p2f(function(t, sampleRate, p1Sample, p2s_numbers) { ... })`: Register
|
|
a function for the second phase.
|
|
|
|
`p2s(type: "u8"|"u16"|...|"i8"|...|"f32"|"f64", ...numbers)`: Pass data
|
|
to the function registered with `p2f`.
|