Open RiedleroD opened 2 years ago
Here's a demonstration project for this bug: https://lmms.io/lsp/?action=show&file=20372
The click is because you have channel-3 active without anything drawed in the window. Draw a pattern and retry.
@musikBear Nah, it's happening without also. I found this was happening with everything disabled while looking into the freeboy, and thought it was intentional- with the vague plan of using it for something. Channel 3 is disabled. I didn't notice it when any instruments were turned on. I guess I never tried this. It occurs to me that in some cases not making this backward compatible could change the sound, given how easy it is to trigger. What did the original gameboy do?
I already wrote what the original gameboy did. I wasn't completely right, but close enough I think.
It seems the gameboy digital to analog converters convert values from 0 to 15 to -1 to 1. This means that a digital signal of 0 produces an analog one of -1. It additionally has a highpass filter (capacitor) to remove DC offset after the initial click. Not sure if all models have this, as it's listed in "obscure behaviour" with mention of the DMG.
There's also a line saying "In general, all units in the channels are always running.", implying that channels that aren't in use are still running at volume 0. This means if they do have a DC offset, it doesn't cause clicking on note start/end on the hardware, but when the gameboy is actually turned on or off.
Source: https://gbdev.gg8.se/wiki/articles/Gameboy_sound_hardware
However, I want to note that LMMS shouldn't go for "true to the original", but for sound output that's intuitive and sounds good. There's trackers for people who want to make music true to the original. Freeboy even has channel polyphony, so it's already not even close to the hardware.
Bug Summary
A signal offset is causing clicking on note start/end and sometimes even Clipping, when too many notes are playing at once. If you set bass to something greater than 0, the offset gets filtered out after the first few sample, causing the clicks to only appear at note start.
I believe this has to do with how gameboy audio worked - it was strictly subtractive instead of having a signal center. This also causes clicking when turning a gameboy on or off, which is what I assume LMMS is doing every time a note starts and ends. Treble and Bass filtering isn't possible on gameboy hardware, so I assume that's post processing being done by LMMS.
Steps to reproduce
play some notes inside freeboy with all channels disabled
Expected behavior
No sound output
Actual behavior
Clicking on note start, caused by the offset
Woraround
By playing the exact same notes on a second freeboy instance with the same bass setting with all instruments disabled and the signal inverted via the stereo matrix effect, the clicking and offset are mostly cancelled out.
Affected LMMS versions
At least master and 1.2.2