mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-14 20:20:30 +00:00
b048b6666d
Speakers can now play arbitrary PCM audio, sampled at 48kHz and with a resolution of 8 bits. Programs can build up buffers of audio locally, play it using `speaker.playAudio`, where it is encoded to DFPWM, sent across the network, decoded, and played on the client. `speaker.playAudio` may return false when a chunk of audio has been submitted but not yet sent to the client. In this case, the program should wait for a speaker_audio_empty event and try again, repeating until it works. While the API is a little odd, this gives us fantastic flexibility (we can play arbitrary streams of audio) while still being resilient in the presence of server lag (either TPS or on the computer thread). Some other notes: - There is a significant buffer on both the client and server, which means that sound take several seconds to finish after playing has started. One can force it to be stopped playing with the new `speaker.stop` call. - This also adds a `cc.audio.dfpwm` module, which allows encoding and decoding DFPWM1a audio files. - I spent so long writing the documentation for this. Who knows if it'll be helpful! |
||
---|---|---|
.. | ||
speaker_audio.md |