Skip to content
Boyney edited this page Feb 6, 2023 · 2 revisions

Spryg has limited support for the speaker. It can currently create a tone of a certain frequency, and play it for a certain amount of time. That's it.

There are only two methods you need to take advantage of Spryg's entire audio system: spryg.make_tone and spryg.make_audio.

make_tone takes a given frequency and outputs a tone at that frequency. I'd recommend constructing a tone, saving it, and then playing it to avoid delay while the Pico is processing, but for many circumstances this isn't necessary.

play_audio takes two arguments, which are the aforementioned tone outputted by make_tone, and an amount of time to play it (in milliseconds). Currently, play_audio is blocking, and you'll have to see for yourself whether or not it's thread safe.

Here's a simple audio playback example:

game.py

def run(spryg):
    spryg.play_audio(spryg.make_tone(1000), 1000)

Clone this wiki locally