Our great sponsors
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Sound data is double-buffered by the operating system. The OS gives you one buffer to write into while it plays the other, and then they swap. If you want to write real-time audio (i.e. a program that will actually play sound itself with no libraries), you need to either read up on your operating system's kernel API for audio, or use a thin abstraction layer like libsoundio. You could also use a fully fledged library like IrrKlang that just does everything for you.
I'm putting a pause on this project for the moment. I definitely think I've hit the limit of the hardware. I have some TL02CP amplifiers. But the datasheet shows you split the signal into negative and positive (which I think makes a lot of sense. I can direct the negative signals of the wave to the negative input and the positive to the positive input) But the raspberry pi limits true hardware PWM to just one pin. Or at least, the wiringPi library does. pinout.xyz shows there are three pins for PWM which seems like it should allow for hardware PWM but I rest my case on that.