SampleScanner icon indicating copy to clipboard operation
SampleScanner copied to clipboard

Got ZeroDivisionError with high sample path...

Open nandoflorestan opened this issue 7 years ago • 1 comments

The file leveler.py sometimes has run into a ZeroDivisionError, printing out the line "Got ZeroDivisionError with high sample path"... But I don't know what this means exactly, so here are a couple of questions:

  • How does the leveler work?
  • Why is there a division by zero issue?
  • Is there any way we could recover from that error automatically?
  • If not, can we at least let the user know how to work around the error?

nandoflorestan avatar Feb 05 '18 02:02 nandoflorestan

That error message is certainly confusing! That could be made simpler.

  • The leveler works according to this algorithm. Because SampleScanner doesn't normalize its output, the leveler performs the following algorithm:
    1. Determine the layer RMS volumes in decibels.
    2. For each layer below the loudest, determine the difference in decibels -- ddd.
    3. Calculate the equivalent velocity: sqrt( 127^2 / arclog( ddd / 20 ) ) and call this vvv.
    4. Tag each layer with lovel=xxx, hivel=vvv and amp_velcurve_vvv=1, where xxx is one more than the lower layer's hivel, as usual.
  • The ZeroDivisionError comes about if the peak_rms of the higher sample is 0, which basically means it's silent. This can happen in exceptional conditions, and SampleScanner doesn't have any logic to catch and ignore empty samples at the moment.
  • We can recover from that error automatically by changing that code path to produce different operators when one or more of the samples is blank, or more completely, by changing the code path so we exclude empty samples anyways.

psobot avatar Apr 03 '18 03:04 psobot