scaleGenerator

Generates a copy of the scalings of the scalebank module onto your SDcard in the file "0:/scalebank.tab". After using this module once (ever), you can use the scalebank2 module to automatically load this file. This prevents to having to load the whole array into sram, filling up constly memory that could be used for more modules.
Author: Remco van der Most
License: GPL
Github: sss/harmony/scaleGenerator.axo

Inlets

None

Outlets

None

Declaration
static const uint32_t LENGTH = 552;

int8_t note[552] = {
    0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,  11, 0, 0, 2, 2, 4, 5, 5, 7, 8, 8, 11, 11,
    0, 0, 2, 2, 4, 5, 6, 6, 8, 8, 10, 10, 0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 9,  10,
    0, 0, 2, 2, 4, 4, 7, 7, 9, 9, 11, 11, 0, 0, 0, 3, 3, 5, 5, 7, 7, 7, 10, 10,
    0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 10, 10, 0, 1, 1, 3, 3, 5, 6, 6, 8, 8, 10, 10,
    0, 0, 2, 3, 3, 5, 5, 7, 8, 8, 11, 11, 0, 0, 2, 3, 3, 5, 5, 7, 7, 9, 9,  11,
    0, 0, 2, 3, 3, 5, 5, 7, 7, 8, 8,  10, 0, 0, 2, 3, 3, 5, 6, 6, 8, 9, 9,  11,
    0, 0, 3, 3, 4, 4, 4, 7, 8, 8, 8,  11, 0, 0, 2, 2, 4, 6, 6, 8, 8, 9, 9,  11,
    0, 1, 1, 4, 4, 5, 7, 7, 8, 8, 10, 10, 0, 1, 1, 3, 3, 5, 5, 7, 8, 8, 10, 10,
    0, 0, 2, 2, 4, 4, 6, 6, 9, 9, 10, 10, 0, 0, 2, 2, 4, 6, 6, 7, 7, 9, 10, 10,
    0, 1, 1, 3, 3, 4, 6, 6, 8, 8, 10, 10, 0, 0, 2, 2, 4, 5, 5, 7, 8, 9, 9,  11,
    0, 0, 2, 2, 4, 5, 5, 7, 7, 9, 10, 11, 0, 0, 4, 4, 5, 6, 6, 7, 7, 7, 10, 10,
    0, 0, 2, 3, 3, 5, 5, 7, 7, 9, 10, 10, 0, 0, 2, 3, 3, 6, 6, 7, 7, 9, 10, 10,
    0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,  11, 0, 1, 1, 4, 4, 6, 6, 8, 9, 9, 10, 11,
    0, 1, 1, 1, 4, 5, 5, 7, 8, 8, 8,  10, 0, 0, 2, 3, 3, 6, 6, 7, 8, 8, 10, 10,
    0, 0, 2, 3, 3, 5, 6, 6, 8, 8, 10, 10, 0, 0, 3, 3, 4, 5, 5, 7, 7, 9, 9,  9,
    0, 0, 0, 4, 4, 4, 6, 6, 7, 7, 11, 11, 0, 0, 2, 3, 3, 6, 6, 7, 8, 8, 11, 11,
    0, 0, 2, 3, 3, 6, 6, 7, 8, 8, 10, 10, 0, 0, 1, 1, 1, 5, 5, 5, 7, 7, 8,  8,
    0, 0, 1, 1, 5, 5, 5, 7, 7, 7, 10, 10, 0, 0, 1, 1, 3, 3, 4, 4, 6, 6, 7,  7,
    0, 0, 1, 1, 1, 5, 5, 6, 6, 6, 10, 10, 0, 1, 1, 3, 3, 5, 5, 7, 8, 8, 11, 11,
    0, 1, 1, 3, 3, 4, 6, 7, 7, 9, 10, 10, 0, 0, 2, 3, 3, 5, 6, 6, 8, 9, 9,  10,
    0, 1, 1, 3, 3, 6, 6, 7, 8, 8, 10, 10, 0, 1, 1, 1, 4, 5, 6, 6, 8, 8, 10, 10,
    0, 0, 2, 2, 2, 5, 5, 7, 7, 7, 9,  9,  0, 1, 1, 4, 4, 6, 6, 7, 7, 7, 10, 10,
    0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 0, 0, 0, 3, 3, 5, 5, 7, 7, 7, 10, 10,
};
Init
FIL FileObject;
FRESULT err;
UINT bytes_written;
err = f_open(&FileObject, "0:/scalebank.tab", FA_WRITE | FA_CREATE_ALWAYS);
if (err != FR_OK) {
  report_fatfs_error(err, "0:/scalebank.tab");
  return;
}
int rem_sz = sizeof(*note) * LENGTH;
int offset = 0;
while (rem_sz > 0) {
  if (rem_sz > sizeof(fbuff)) {
    memcpy((char *)fbuff, (char *)(&note[0]) + offset, sizeof(fbuff));
    err = f_write(&FileObject, fbuff, sizeof(fbuff), &bytes_written);
    rem_sz -= sizeof(fbuff);
    offset += sizeof(fbuff);
  } else {
    memcpy((char *)fbuff, (char *)(&note[0]) + offset, rem_sz);
    err = f_write(&FileObject, fbuff, rem_sz, &bytes_written);
    rem_sz = 0;
  }
}
if (err != FR_OK)
  report_fatfs_error(err, "0:/scalebank.tab");
err = f_close(&FileObject);
if (err != FR_OK)
  report_fatfs_error(err, "0:/scalebank.tab");

Privacy

© 2024 Zrna Research