While not direct midi to bytebeat, many users export MIDI from Beepbox, then use a converter script (like midi2bytebeat.py found on GitHub) to map the pitches to a wavetable.
Below is a conceptual C-style pseudo-code illustrating how a MIDI event updates a Bytebeat formula. midi to bytebeat
Global Variables:
uint32_t t = 0; // Time counter
int current_note = 0; // The note being held
int velocity = 0; // Volume/Intensity
bool gate = false; // Is a key pressed?
The MIDI Event Handler (Input):
void onMidiEvent(int note, int vel)
if (vel > 0)
current_note = note;
velocity = vel;
gate = true;
else
gate = false;
The Bytebeat Audio Loop (Output): This function runs 8000 to 44100 times per second. While not direct midi to bytebeat , many
uint8_t computeSample() (t >> grit)) & 0xFF;
// 4. Apply Velocity Volume
output = (output * velocity) >> 7;
return output;
MIDI notes are logarithmic. Note number 69 = A4 = 440Hz. To get a frequency ratio, we use: freq = 440 * 2^((note - 69)/12). The MIDI Event Handler (Input): void onMidiEvent(int note,
In Bytebeat, we generate pitch by wrapping a phase accumulator: sine(phase) or a triangle wave. The phase increments by freq / SR.