Kudos to github copilot!
I wrote this:
// Verify that for each indiividual midi state, the states with notes on form a dense cluster.
for _, ms := range o.States {
And copilot suggested this:
// Verify that for each indiividual midi state, the states with notes on form a dense cluster.
for _, ms := range o.States {
// Get the slots with notes on.
var slots []int
for _, ts := range ms.TackStates {
if len(ts.Notes) > 0 {
slots = append(slots, ts.Slot)
}
}
// Verify that the slots form a dense cluster.
if len(slots) > 0 {
sort.Ints(slots)
for i := 0; i < len(slots)-1; i++ {
if slots[i+1]-slots[i] != 1 {
return fmt.Errorf("slots not dense: %s", goutiljson.MustColorMarshal(ms))
}
}
}
}