https://github.com/CmST0us/PeripheryKit/blob/main/Sources/PeripheryKit/Buzzer.swift
In my code, I use DispatchQueue to create pwm modulation and use linux gpio interface to control digital output.
But linux is not real-time system, so the it sounds not great.
But I can still recognize the lyric “Twinkle Twinkle Little Star”。