A 44 kHz sample rate guarantees accurate 22 kHz triangle wave reproduction if a reconstruction filter with linear interpolation is used on the output, and accurate amplitude of same signal if samples happen to align somewhat with the peaks of the waveform.
That's exactly why linear interpolation is not used.
The Nyquist-Shannon sampling theorem says that you can perfectly reconstruct any sampled signal as long as the input signal was bandlimited to 1/2 the sampling rate. Using a low-pass filter to bandlimit your 22 kHz triangle wave will remove all the (inaudible) overtones, leaving you with a single 22 kHz sine wave as input to your ADC. The reconstruction filter on the output DAC will then output a perfect 22 kHz sine wave, with the correct amplitude too!
There are no "issues" with the square wave at 44kHz. Yes, a square wave sampled at 44kHz and converted back to analog does have visible ringing on an oscilloscope, but that's because you're looking at a perfect reconstruction of a band-limited square wave. Before sampling, the square wave is filtered to remove all of the overtones above 22kHz, which are not audible (as that's above the upper limit of human hearing) and would cause aliasing issues in the sampled signal.
In other words, the ringing is an artifact of low-pass-filtering on the square wave, not the sampling process itself. A purely analog system with a 22kHz low-pass filter would have the same "ringing", and your ears couldn't tell either way because they can't detect information above 15-20 kHz. It's not even possible to have a "perfect" square wave in the real world because that would require the speaker cone, air molecules, and your eardrum to teleport instantly from one spot to another -- so you will always have some low-pass filtering, and therefore ringing, on any real-world approximation of a square wave.
Thank you for your detailed comment. Disclaimer, I don't think I fully understand this topic or your comment in entirety.
When you say
> Before sampling, the square wave is filtered to remove all of the overtones above 22kHz, which are not audible (as that's above the upper limit of human hearing) and would cause aliasing issues in the sampled signal.
Do you mean that the human ear "hears" (for lack of a better word) in sine waves because of fourier transforms? So, a pure squarewave signal (cut off above 20khz due to human ear limits) sounds identical to an "imperfect"/wavey sq.wave made from harmonics lacking higher frequency parts?
A perfect square wave has infinite bandwidth. The phase change from high to low theoretically happens instantaneously. Practically nothing moves that fast in the real world. Voltages take time to go up and down because of inductance and what not in the circuit, the cone of the speaker needs to start accelerating to move, etc. A speaker cone doesn't move instantaneously from its high point in the wave to the low point in the wave, it takes time for it to move and actually push the air around. Plus, the air itself is kind of springy, so even if the speaker did move instantaneously (which it can't, it would have to move at infinite acceleration) the resulting pressure wave wouldn't be nearly as sharp of a transition.
Your ears don't experience pure square waves. They can't. They'll get the approximation of a square wave as close as they can experience them, but your ear drum doesn't immediately warp from one point to another. It gradually moves. The fluid in your ear has its own springiness. The hairs which do the final detection don't just instantly move either, they're being vibrated by the motion of the fluid in your ear.
And yeah, technically your eardrums can be moved by waves higher than 20kHz. But its not just the motion of your ear drums that give you hearing, its lots of tiny hairs in your inner ear that resonate at different frequencies that gives you the detection of certain audio frequencies that are present. Normal humans (read: practically everyone) tend to only have the equipment to accurately sense up to ~20kHz pressure waves with our ears as sound. As you age the areas which detect higher frequency sounds get less sensitive first, so you start losing the ability to hear those higher frequency sounds first.
It does seem like you're missing a bit of knowledge about signal theory though. That would really help you understand what I mean when I say a real square wave has infinite bandwidth. A very rough and basic idea to help here is that a wave can be thought of as a sum of fundamental sine waves. So a square wave is essentially the sum of all the component fundamentals, each fundamental gets sharper and sharper edges of the square. But the only way for the sine wave to have a truly vertical edge is to be infinite frequency, right? And what are the edges of a square wave? Vertical lines. So to keep adding these fundamentals together to achieve a square output, you'd need to add an infinite sum of sines together to make an actually perfect square. Monty touches on this in that video a bit, but it goes pretty quick.
Thanks again for your detailed comment. I think I understand it now. The only thing slightly puzzling me is why waves are broken up (be it Fourier or in our ears) into sine waves, and not say sawtooth (or some other, like a semicircle as in https://math.stackexchange.com/questions/1019005/what-kind-o...) waveform.
I understand how a squarewave needs infinite bandwidth for decomposing into sine waves, but a wave like the semicircle one has a vertical tangent and would not need an infinite bandwidth. Btw you're right, I've never had any signal theory classes (studied mech engg).
I'm mostly just an amateur myself, so I totally get where you're coming from.
FWIW, the graph at the top of that article (as mentioned in the comments) does not have vertical tangents. They're not true semicircles. Most of the answers given to make actual semicircles become non-continuous signals (y >= 0 if ... answer) or infinite sum. The one which doesn't just says they look like semicircles. I don't really have the time (or immediate knowledge, I'm admittedly bad at math) to dig all the math but my gut instinct suggests those aren't true semicircles and don't truly have vertical tangents.
And this is kind of how a signal generator can get away making square waves and sawtooths and what not; internally its not always truly "discrete" signals its just quickly flipping a switch from one thing to another. It flips from the high state to the low state fast enough that for your 50MHz oscope it looks pretty continuous, and its probably designed to try and draw a connected line.
This all kind of makes some sense when you get into how we actually make electrical signals. We're normally just modulating the electric "vibrations" of some crystal or accelerating some magnet through a loop back and fourth. These things move in continuous waves. As mentioned, things don't have infinite acceleration they take time to shift between states. So you're never going to get something that goes from high to low in zero time. And most home owners will tell you there's no such thing as a right angle.
I'd like to mention though, you're imaging the wave as being "broken up" into sine waves, which IMO isn't quite the right way to be looking at it. Its not "breaking up" the signal into sine waves, the signals were always sine waves. Remember my comment, truly square waves don't really exist. We can have things that kinda look square-ish when you squint your eyes, but they're not really square waves. A truly square wave in reality requires infinite acceleration or its not continuous. Fill a bathtub and try to make square waves. Its just not going to happen.
I know I'm not fully answering your question, I don't fully know the answer myself. So far in my stumbling around the closest thing I can answer is because that's just how nature and waves are, at least as much as our monkey brains can reason about them. Think about a string in a guitar or a wave in the water or throwing a ball. They all moves in ways which can be described by sine waves. Its just like the nature of how things accelerate and move, changing between states. Why do we see the golden ratio in so many places? Why are circles so special? Good luck on digging for more truth.