freezy / dmd-extensions

A toolbox for virtual pinball dot matrix displays.
GNU General Public License v2.0
128 stars 54 forks source link

Sound hangs / doubles with 128x16 sized dmd #124

Closed kds70 closed 5 years ago

kds70 commented 6 years ago

Good morning,

i´m using a cabinet setup (PinUp Popper, VPX 10.5 final, 40", 28", GF 1050ti) with a pin2dmd (via freezys v1.7.1). All is (was) working fine until i´ve installed the new TMNT Table release which uses a 128x16 pixel sized DMD displayed at my pin2dmd.

Table link: https://vpinball.com/VPBdownloads/teenage-mutant-ninja-turtles-data-east/

I´ve noticed sound laggs / doubles with freezys 1.7.1. I´ve tested my last dmddevice.dll (lucky) and the sound doubles / laggs were gone. Tested it on my working computer too (no pin2dmd); there were sound laggs too with freezys 1.7.1 and this table / dmd.

My solution for now is the TMNT colorization which uses a upscaled DMD (to 128x32) and the sound laggs are gone with freezys 1.7.1 too.

So, all is fine now. Are there issues known with freezys and 128x16 dmd´s ?

Greedings from germany, Kai

djrobx commented 6 years ago

I worked with Kai to try to help him with this. It seems like there is some performance issue when the DLL tries to display a "natural" uncolored 128x16 DMD on a Pin2DMD.

From his report the issue goes away when 128x32 colorizations are in use, which get upsized by different code.

freezy commented 5 years ago

@djrobx any idea which upsizing code is fast and which is slow? :)

djrobx commented 5 years ago

This code in dmddevice.cs is working fine (his "workaround" is to use a colorization which activates this code)

if (_gray2Colorizer != null && width == 128 && height == 16 && _gray2Colorizer.Has128x32Animation)
        {
            // Pin2DMD colorization may have 512 byte masks with a 128x16 source, 
            // indicating this should be upsized and treated as a centered 128x32 DMD.
            height *= 2;
            _gray2Colorizer.SetDimensions(width, height);
            if (_upsizedFrame == null)
                _upsizedFrame = new byte[width * height];
            Buffer.BlockCopy(frame, 0, _upsizedFrame, 8*width, frame.Length);
            _vpmGray2Source.NextFrame(width, height, _upsizedFrame);
        }

I don't really know where in your code a 128x16 source gets "upscaled" to fit a 128x32 Pin2DMD. It doesn't seem to be an issue on the virtual DMD.

freezy commented 5 years ago

Yep, no optimizations here, converting to bmp, resizing and converting back to 2-bit:

var bmp = ImageUtil.ConvertFromGray2(width, height, frame, 0, 1, 1);
var transformedBmp = TransformationUtil.Transform(bmp, dest.DmdWidth, dest.DmdHeight, Resize, FlipHorizontally, FlipVertically);
var transformedFrame = ImageUtil.ConvertToGray2(transformedBmp);

Checking how to make this better.

freezy commented 5 years ago

Can you try this if it's better?

DmdDevice-124.zip

kds70 commented 5 years ago

@freezy : :+1: hey ... sorry for my late reply. it seems to work now ... testet with a Data East Table (Star Trek 25th Annivisary), cooooooool thank you.