TL;DR an example .ino file for MSQ and SPI at the same time on teensy 4.0

I'm developing a project on a Teensy 3.6. The project centers around a small housing. It uses the DAC for audio and SPI ports for a display.

Over the weekend, I got the last of the components in the mail and soon discovered that they won't all fit in the housing. Fortunately, I had a Teensy 4.0, which solves the space problem. But what about the DAC?

I need mono audio and the 4.0 can output audio from both the MSQL and MSQR pins. But the TFT display also needs those pins, or else I'll have to solder to the bottom pads ... which I don't want to do.

It turns out, you can mix and match SPI and Audio pins.

These are the three lines of code that make it work:
Code:
  unsigned prev_pin10_config = CORE_PIN10_CONFIG; // 21
  AudioOutputMQS mqs;
  CORE_PIN10_CONFIG = prev_pin10_config;
When the AudioOutputMQS object is created it changes the MSQR (10) pin. The above code changes it back so that the display can use it.

Another gotcha is that all of the audio examples out there use AudioOutputMqs, but the correct name is AudioOutputMQS.

Hope somebody finds this useful!