Bruh...if he's such a genius with magic, and even had the foresight to put up a sound proof barrier, can't he just put up a barrier that notifies him if there's a presence in his room? I mean, all the strategic thinking on top of years (assuming) of "guarding his secret" and he slips up, in someone else's territory no less. It just seems like the author is trying to force the duke's daughter into being with the prince.