there’s a lot to ‘unpack’ here…
I think we should start away from the assumption that there is a bug in what the pyramid is sending…
not because it may not be the case, but reading above… its is I believe colouring your analysis.
(ie. we are are trying to prove there is a bug, rather than determine if there is a bug)
some observations, from my side, partly as a developer… partly as a midi user.
these hanging notes are NOT happening with every synth over DIN, if they did this forum would be flooded with complaints… rather than a few users, with a specific setups.
also the pyramid has been around for years, so it would be a well known problem.
I know this doesn’t help YOUR situation, but it has to some how frame what’s going on.
why does it work for others and not you? what’s different?
from your description, your usage of the pyramid seems same as others - similarly its ok to other synths for you and via usb, so its something to do with hardware its being sent to, some ‘incompatibility’ between your synth and the pyramid… we just don’t know where/why.
I think you statement ‘it does not depend on synthesiser’ is basically false… I think its very much DIN OUT to the P12 thats the issue.
Im not saying, its 100% only the P12, we do not know how many synths it affects … just its not an issue will all (majority of ?) synths using DIN OUT.
USB midi works fine - ok, this is zero surprise to me.
the reason is DIN has many more bandwidth issues, and at the lowest level handled rather different.
e.g. DIN is strictly serial, whereas usb uses 4 byte packets for every message.
the ‘sequencer engine’ code on the Pyramid will send exactly the same message via USB or DIN.
so if message are missed via DIN and not USB, then this is at the transport layer not the engine.
MIDI DIN is very slow (compared to USB), too many messages WILL overrun receiving buffers on synths (how much buffer there is dependent on synths!) … that buffer is shared for ALL messages, clocks, notes, cc… any overrun will corrupt other messages but its true that missing note on/off are always the most noticeable… hence why transport issues are usually reported as hanging notes… probably other data is also corrupted BUT its just not so obvious.
re-writing midi…
yup, this is absolutely normal for almost anything with a microcontroller - so routers, computers, sequencers etc…
this is also done when your synth is doing ‘soft thru’
of course, the ‘thing’ will then re-write the midi message, not necessarily as it comes it, but rather as the developer interpreted the midi spec.
the main difference I see with this is in an area called ‘running state’. because midi din was so slow, there is are some optimisations which allow ‘repeated bytes’ to be omitted… particularly useful for CCs.
Ive seen devices that just don’t bother with this optimisations, even routers - I think just because we have more processing/memory resources so its felt less necessary. (and its completely irrelevant for USB)
how does this related to the problem at hand?
the issue is, its hard to say…
id say odds-on, the sequencer code for the pyramid is sending the right messages.
what I suspect is happening is either some hardware issue ( * ) over the DIN connection, or some timing issue.
this is not uncommon, I noticed a while back that my iConnectivity mioXM seem to fix some communication issues I had between a couple of midi devices (not pyramid related) .
I really don’t know if this was because the XM was re-writing the message, or has a larger send/receive buffer… its unfortunately impossible to know.
but from a user perspective, it was similar, both devices worked fine with other devices - just they didn’t like talking to each other 
(similarly I had an issue with my Virus, sending SysEx out that would baulk another device on the network, and had to use the XM to filter it)
This point also leads to another observation… which may be affecting why some users have more problems that others.
The pyramid allows for 64 tracks and a lot of complexity, so it is often used in larger setups.
however, the pyramid has very limited midi IO - no usb hosting, and 1 midi input and 2 midi outputs (and some cv)
SO, I think many pyramid users supplement the midi routing with various routers, splitters, mergers.
if you look over this forum, lots of topics / posts would support that assumption.
in my case, (and I think @CreepyPants ? ) , whilst I do often use the pyramid on its own directly connected to instruments (as a kind of portable setup) - id say 80% of the time its connected to a router.
how much impact does this have? we have no idea… but I do suspect some oddities with some instruments might be masked, because routers are being used.
I recognise its not a ‘solution’, but from a practical standpoint, Id recommend trying with a midi router - things like the iConnectivity, MidiHub , BomeBox - I think add so much extra value to the pyramid generally - and if they solve the odd issue like this , then thats a bonus 
(perhaps you can borrow one, or order from some where that allows returns to see if it helps - as there are no guarantees since I don’t have a P12)
( *) above some talked of the optocoupler, I did review that post, and Id urge some caution.
in that specific case, Squarp said it ‘seems’ like the optocoupler could possibly be the issue.
this was taken as ‘an acknowledged’ problem by Squarp.
my interpretation was more… given the details provided by the user, Squarp thought it was a possibility, but they have no way to verify it.
that being the case, that throws up questions like… was it a particular pyramid issue? if not, how many instruments does it affect? more questions than answers unfortunately?!
of course, if there were some oddities between two optocouplers , then sure a router/splitter would provide an intermediary that might fix the issue … though its not the only reason why a router might help.