sightEarEchoChunks function

List<List<int>> sightEarEchoChunks(
  1. int total,
  2. int sub, {
  3. int? size,
})

Divide os total compassos de uma frase em trechos consecutivos do tamanho do subnĂ­vel sub (0 a 3), ou de size compassos, se dado. O Ășltimo trecho pode ser menor. A frase inteira vira trechos: nenhum compasso fica de fora do eco.

Implementation

List<List<int>> sightEarEchoChunks(int total, int sub, {int? size}) {
  size ??= kEarEchoChunkMeasures[sub];
  return [
    for (var start = 0; start < total; start += size)
      [for (var m = start; m < min(start + size, total); m++) m],
  ];
}