union aica_sandbox_channel {
  struct {
    int instrument;
    int loop;
    int note;

    int krs;
    int ar;
    int d1r;
    int d2r;
    int rr;
    int dl;

    int lfof;
    int plfows;
    int alfows;
    int plfos;
    int alfos;

    int disdl;
    int dipan;

    int kyonb;
  };
  int field[16];
};

struct aica_sandbox_state {
  int channel_ix;
  union aica_sandbox_channel channel[64];
  int pointer_row;
};

struct aica_sandbox_state sandbox_state = {};

struct key_offset_value {
  const char * label;
  const char * description;
  int min;
  int max;
};

const key_offset_value sandbox_labels[] = {
  {"instrument", NULL, 1, max_instruments},
  {"loop", NULL, 0, 1},
  {"note", NULL, 0, 97},
  {"krs", "key rate scaling", 0, 0xf},
  {"ar", "attack rate", 0, 0x1f},
  {"d1r", "decay 1 rate", 0, 0x1f},
  {"d2r", "decay 2 rate", 0, 0x1f},
  {"rr", "release rate", 0, 0x1f},
  {"dl", "decay level", 0, 0x1f},
  {"lfof", "LFO frequency", 0, 0x1f},
  {"plfows", "pitch LFO waveform select", 0, 3},
  {"alfows", "amplitude LFO waveform select", 0, 3},
  {"plfos", "pitch LFO sensitivity", 0, 7},
  {"alfos", "amplitude LFO sensitivity", 7},
  {"disdl", "direct send level", 0xf},
  {"dipan", "direct panpot", 0x1f},
};
const int sandbox_labels_length = (sizeof (sandbox_labels)) / (sizeof (sandbox_labels[0]));
