DhrBaksteen / ArduinoOPL2

Arduino library for use with the OPL2 board (YM3812) and OPL3Duo (YMF262)
MIT License
198 stars 39 forks source link

Bug: setInstrument uses invalid registers #36

Closed stople closed 5 years ago

stople commented 5 years ago

Thanks for a cool project! I am making an OPL synthesizer connected to my digital piano.

SetInstrument uses invalid registers when i == 5. You should change it to something like this (I guess it applies to percussion instruments as well):

    default:    // Melodic instruments...
        for (byte i = 0; i < 11; i ++) {
            byte reg;
            if (i == 5)
                reg = 0xC0 + max(0x00, min(channel, 0x08));
            else
                reg = instrumentBaseRegs[i % 6] + getRegisterOffset(channel, i > 5);

            setRegister(
                reg,

...

DhrBaksteen commented 5 years ago

Thanks for pointing it out! Register 0xC0 is indeed channel based and not operator based :face_palm:

DhrBaksteen commented 5 years ago

Issue is fixed by #38