Skip to content

Commit

Permalink
fix CRT voice count sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
chinenual committed Jun 17, 2024
1 parent a2d271f commit ac79d5e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion data/crt.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,18 @@ type crtCursor struct {
VoiceOffset int64
}

func countVoices(vces []*VCE) (result int) {
result = 0
for _, vce := range vces {
if vce != nil {
result += 1
}
}
return result
}

func WriteCrt(buf io.WriteSeeker, vces []*VCE) (err error) {
if len(vces) < 1 || len(vces) > 24 {
if countVoices(vces) < 1 || countVoices(vces) > 24 {
err = errors.Errorf("Must have at least 1 and no more than 24 voices")
return
}
Expand Down

0 comments on commit ac79d5e

Please sign in to comment.