file_size

Fetches the size of a file in 16 bit samples
Author: Are Leistad
License: BSD
Github: drj/file/file_size.axo

Inlets

charptr32 filename

bool32.rising Trigger to read file size

Outlets

int32.positive Filesize in 16 bit samples

Declaration
int32_t start_sequence;
int32_t old_inlet_trig;
int32_t file_size;
Init
start_sequence = 0;
Control Rate
if (start_sequence == 0 || inlet_trig != 0 && old_inlet_trig == 0) {
  FIL FileObject;
  int32_t err;

  err = f_open(&FileObject, inlet_filename, FA_READ);
  if (err != FR_OK) {
    report_fatfs_error(err, inlet_filename);
    file_size = 0;
  } else {
    file_size = f_size(&FileObject) >> 1;
    f_close(&FileObject);
  }

  if (start_sequence == 0) {
    start_sequence++;
  }
}

old_inlet_trig = inlet_trig;
outlet_samples = file_size;

Privacy

© 2024 Zrna Research