I too had this need with my Core 2 Stack, so I wrote a few little routines that make sounds based on the M5Stack Atom Speaker code examples. The code is at, https://github.com/Hagtronics/M5Stack-Core2/tree/main/Sound