M5Stack user macsbug made this audio spectrum display project with his M5Stack. It displays the audio spectrum on the screen of the M5Stack either from input of the internal mic on M5Stack Fire or M5GO, or alternatively by using an external sound sensor such as the FC-04 if you have an original M5Stack core device with no internal mic.
In that case the sound is received by the FC-04 sound detection sensor on pin 36 of the m5stack and output on the screen. See the picture below for wiring.
Before uploading the sketch make sure you have your M5Stack set up with the Arduino environment, to do so follow this guide here
This sketch was ported from an esp32 Audio spectrum visualiser which you could also use if you have a regular esp32 with screen attached https://github.com/tobozo/ESP32-Audio-Spectrum-Waveform-Display/tree/wrover-kit
This code was also based on the audio spectrum code by https://github.com/G6EJD, a big thanks to those guys.
The sketch also requires this Arduino FFT library by kosme which you will need to make sure you install in your libraries folder before you compile the sketch.