Hello David,
After much experimentation with settings, I have now
got the sound from
Qtractor back to the headphones. The distortion is still there. I
would be tempted to think it might be a fault with my Raspberry Pi, but
the sound is fine when using 'aplay', so clearly the sound system on
the Pi is fundamentally OK.
Comparing the settings in QJackCtl in the Parameters and Advanced tabs,
they are the essentially the same both on the Pi and on my HP laptop
running Ubuntu 18.04.
I'm stumped.
You might want to check out
https://wiki.linuxaudio.org/wiki/raspberrypi#on-board_audio
The onboard audio is still PWM and < 16-bit as far as I know so maybe
that's the cause of the distortion.
Best,
Jeremy