Error when outputting a WAV using dro player - "ValueError: buffer too small (min 2 samples)"

Issue #13 resolved
jestar jokin repo owner created an issue

Reported by a user:

I have been experiencing a problem with certain .DRO files written by Dosbox. When I use Dro Player to play the song, it only plays a certain portion of it before the program closes.

If I try to record a .WAV, it gives me the following error at the same time it would crash:

DRO Song: test.dro
Format: v2
OPL Type: Dual OPL-2
Length (ms): 58839
00:41 / 00:58Exception in thread Thread-1:
Traceback (most recent call last):
  File "threading.pyc", line 551, in __bootstrap_inner
  File "", line 45, in inner_func
  File "", line 484, in run
  File "", line 117, in render
  File "", line 247, in render
ValueError: buffer too small (min 2 samples)
00:58 / 00:58

Comments (4)

  1. jestar jokin reporter

    I couldn't reproduce the problem with the same test file. However, looking at the code, I think I see where the problem could occur.

    PyOPL only supports buffers of length 2 or greater. The render code checks if the number of requested samples is less than 2 and aborts. Otherwise, it will loop, filling up buffers of the configured buffer size.

    If the number of samples requested is 1 more than the buffer size, then the player attempts to render a buffer with size 1, triggering the error in PyOPL.

    The fix is to change the loop condition so it runs while the number of samples to render is greater than 1, rather than 0.

    We already track the "sample overflow" for such situations, so the next call to render should take care of the sample that couldn't be rendered in this call.

  2. Log in to comment