Prezzodaman/pymod

Error playing shaded_love by h0ffman

DidierMalenfant opened this issue · 2 comments

This one crashes pymod with:

Traceback (most recent call last)       
  File "/Users/didier/Documents/Code/Python/pymod/pymod/__main__.py", line 65, in main
    module.play()
  File "/Users/didier/Documents/Code/Python/pymod/pymod/pymod.py", line 1765, in play
    self._run()
  File "/Users/didier/Documents/Code/Python/pymod/pymod/pymod.py", line 852, in _run
    mod_finetune_temp[channel] = mod_samples[sample_number - 1]["finetune"]
IndexError: list index out of range

The playpos at that moment is Order 28/65, Pattern 22, Line 11.

I'll look into this one but again, making a note here.

It looks like a garbage instrument number in the mod. Checking with the author to make sure.

This line:

sample_number = (mod_file[mod_pointer] & 0xf0) + (mod_file[mod_pointer + 2] >> 4)

propagates the issue because it's and-ing with 0xf0 but there can only be 31 instruments.

Proposed fix would be:

sample_number = (mod_file[mod_pointer] & 0xf0) + (mod_file[mod_pointer + 2] >> 4)
if sample_number > mod_samples_amount:
    sample_number = 0

This is fixed by #24