getTrackCount() is defined to return an int
.
int playdate->sound->sequence->getTrackCount(SoundSequence* sequence)
However get/setTrackAtIndex use an unsigned int.
void playdate->sound->sequence->setTrackAtIndex(SoundSequence* sequence, SequenceTrack* track, unsigned int idx)
SequenceTrack* playdate->sound->sequence->getTrackAtIndex(SoundSequence* sequence, unsigned int idx)
This means if you set a track at index 0xf0000000 or more, the value returned from getTrackCount() must overflow - which is defined to be Undefined Behaviour. And if negative, will probably crash/panic things built on the API.
I think the return type just likely needs to be changed to an unsigned int?