Wohlstand / libOPNMIDI

A Software MIDI Synthesizer library with OPN2 (YM2612) emulator
GNU Lesser General Public License v3.0
96 stars 6 forks source link

Chip base #29

Closed jpcima closed 6 years ago

jpcima commented 6 years ago

This is a tiny reorganization in order to improve efficiency.

I redo OPNChipBase in F-bounded generics (aka CRTP in common C++ lingo). Here is an explanation of the goal of doing this:

Currently, it permits to eliminate the virtual calls in the generate32 fallback. These kinds of virtual calls are to avoid because they are invoked on a frame by frame basis.

But later, this will allow me, with the same efficiency benefit, to generalize to all chips the resampling method. All a chip will have to do is to provide a generator function for the next frame at native rate. So, all chip implementations will be able to be simplified and be kept fast, while moving the common code into the Chip Base.

And then, there will be a true and efficient way to drive chips for frame-by-frame work, and it will facilitate the implementation of portamento (which has to interleave Upd_Pitch between generation of frames at near audio rate).

Remark: I'm also getting rid of copy constructors, as it's not only useless but also copy gets complicated when resampler variables are getting involved