readFromChunk static method

List<SampleHeader> readFromChunk(
  1. BinaryReader reader,
  2. int size
)

Implementation

static List<SampleHeader> readFromChunk(BinaryReader reader, int size)
{
    if (size % 46 != 0)
    {
        throw "The sample header list is invalid.";
    }

    int count = (size ~/ 46) - 1;

    // The last one is the terminator.
    List<SampleHeader> headers = [];

    for (int i = 0; i < count; i++)
    {
      headers.add(
        SampleHeader.fromReader(reader),
      );
    }

    // The last one is the terminator.
    SampleHeader.fromReader(reader);

    return headers;
}