nukeykt / Nuked-SC55

Roland SC-55 series emulation
Other
285 stars 33 forks source link

Save SRAM on exit #46

Open NicknineTheEagle opened 2 months ago

NicknineTheEagle commented 2 months ago

This saves the contents of SRAM into a file on exit and loads them on startup to emulate the real module's behavior where SRAM is preserved during power down using a battery.

...granted, I don't know much about how the real SC-55 module works, I just made an educated guess and this code does seem to result in correct behavior. This also avoids the annoying bug carried over from real hardware where the module becomes out of tune if powered up with no battery until you reset it.

Fixes https://github.com/nukeykt/Nuked-SC55/issues/23, fixes https://github.com/nukeykt/Nuked-SC55/issues/45.

Falcosoft commented 2 months ago

Hi, https://github.com/nukeykt/Nuked-SC55/issues/6 still remains relevant even after this patch. With saving at exit and loading SRAM at startup you will not get a clean default state like after a proper reset. Instead you will get an arbitrary state defined by the last used Midi track/game.

NicknineTheEagle commented 2 months ago

Hi, #6 still remains relevant even after this patch. With saving at exit and loading SRAM at startup you will not get a clean default state like after a proper reset. Instead you will get an arbitrary state defined by the last used Midi track/game.

https://github.com/nukeykt/Nuked-SC55/issues/6 specifically references the pitch bug which is resolved by this PR:

If the reset bug isn't able to be fixed or will take a while

Auto-reset was proposed as a workaround. As such, I reasoned that the issue is not relevant in that particular scope anymore.

Falcosoft commented 2 months ago

This way if the last used Midi used custom tuning you can get the same "out of tune" effect at startup. At the middle/end of https://github.com/nukeykt/Nuked-SC55/issues/45 there are a few proposal how to solve this problem (e.g. by always loading a clean saved state). There should be at least an option for this.

NicknineTheEagle commented 2 months ago

This way if the last used Midi used custom tuning you can get the same "out of tune" effect at startup.

That wouldn't be a bug anymore, no? That's how the module is intended to work, whatever settings you make persist until a reset command is issued.

Falcosoft commented 2 months ago

The current behavior is not a "bug" either in this sense. It perfectly emulates a unit without battery. But in practice this perfectly emulated behavior is not too desirable. I'm arguing that something similar is also true for this patch. None of the software synths (even Munt that is also a close to the hardware emulator) preserves the last state but always starts in a clean default state.

NicknineTheEagle commented 2 months ago

Right, I suppose auto-reset is a useful option to have.

nukeykt commented 2 months ago

I will add configurable behavior once config file support is added, default will be saving and loading data from/to SRAM as real unit with battery will do. Also keep in mind that only SC-55mk1/mk2 have battery, CM-300 and 55st don't have one

NicknineTheEagle commented 2 months ago

Also keep in mind that only SC-55mk1/mk2 have battery, CM-300 and 55st don't have one

Ah, I need to add a check for that then.