Wohlstand / OPL3BankEditor

A small cross-platform editor of the OPL3 FM banks of different formats (Downloads in README below)
GNU General Public License v3.0
140 stars 12 forks source link

Key on/off time estimator #29

Open jpcima opened 6 years ago

jpcima commented 6 years ago

I started an experimental branch to make an estimation of envelope times and compare with real times. It's unclean code but here for experiment purposes. link.

This estimate method is more oriented towards precision than performance. There is some difficulty in finding an exact result, but I have expectation for error to be in the magnitude of milliseconds.

I have some questions, probably stupid

  1. how to launch delay measurements? "Recalculate all sounding delays" seems not to do anything
  2. when I launch the emulator benchmark I have very significant variations of results. what to do about this?
Attack time (ms) 3313 real, 3333 estimate
Attack time (ms) 4540 real, 3333 estimate
Attack time (ms) 0 real, 3333 estimate
  1. do instruments have a definition of the field NTS/Note-Sel (from OPL3 register 08)? do I set 0 for NTS?
Wohlstand commented 6 years ago

Recalculate all sounding delays

It does calculation of non-empty voices. And when voices are presented, it works very long if it uses Nuked (it is used by default). Empty non-sounding voices are skipping to don't waste time on them.

Also, I have made the thing to detect 5 seconds of silence and then break the scan. That usually happens when no sound was produced.

when I launch the emulator benchmark I have very significant variations of results. what to do about this?

That because of error which is caused by capturing of data from the generated wave analysis and it's not accurate as you see.

do instruments have a definition of the field NTS/Note-Sel (from OPL3 register 08)? do I set 0 for NTS?

I think, it's just unused as I see...

jpcima commented 6 years ago

I have just continued progress on this, and now I also have the model for the release phase. This part of implementation will be easier but must take into account the starting level defined by the sustain parameter.

For a validation basis, it would be great if I can run it over all instruments, and instruct it to compare the normal measurement vs estimate.

I think, it's just unused as I see...

NTS has impact on computing the effective envelope rate. I think it controls how note frequency affects the scaling. I think, as I just copied the computation out of Nuked code.

release

EDIT this is envelope rate computation according to NTS:

    unsigned effective_rate = 4 * rate;
    if (!ksr)
        effective_rate += block >> 1;
    else
        effective_rate += (block << 1) | ((fnum >> (9 - nts)) & 1);
jpcima commented 6 years ago

I have made a quick and dirty write-up to explain math in the time estimation code, since it's not really obvious to understand at the first look. For reference here it is. https://github.com/jpcima/opl3-time-measurement/blob/master/docs/master.pdf