The APIs on this page will only work with SDK 4.9+.
Controlling the speaker
The Speaker API provides calls that let you play sounds through the watch's speaker. You can play simple note sequences (melodies), single tones, or stream raw PCM audio.
Note sequences are compact representations of melodies using MIDI-like note definitions, supporting 4 basic waveforms: sine, square, triangle, and sawtooth.
Raw PCM streaming allows apps to generate arbitrary audio in configurable formats.
Play a sequence of notes on the speaker.
Array of SpeakerNote structs defining the melody
Number of notes in the array
Playback volume (0-100)
true if playback started successfully
Play N monophonic tracks in parallel, mixed (polyphony).
Array of track descriptors (notes + optional sample).
Number of tracks. Must be >= 1 and <= 4.
Playback volume (0-100).
true if playback started successfully.
Play a single tone on the speaker (convenience wrapper).
Tone frequency in Hz
Tone duration in milliseconds (max 10000)
Playback volume (0-100)
Waveform to use
true if playback started successfully
Open a raw PCM stream for app-generated audio.
PCM format specifying sample rate and bit depth
Playback volume (0-100)
true if stream opened successfully
Close the PCM stream. Buffered data will be played before stopping.
Stop any active speaker playback immediately.
Set the speaker volume.
Volume level (0-100)
Register a callback invoked when speaker playback ends. The callback runs on the app task.
Callback to invoke, or NULL to unregister.
User context passed back to cb.
A single note in a sequence. midi_note: MIDI note number (0-127, 60=C4). 0 = rest (silence). waveform: SpeakerWaveform value. duration_ms: Note duration in ms (max 10000). velocity: Volume 0-127 (0 = use global volume).
A raw PCM sample that can be pitch-shifted when played by a track. data: mono signed PCM in the given format. num_bytes: size of data in bytes. format: sample rate + bit depth (see SpeakerPcmFormat). base_midi_note: the MIDI note at which the sample plays unshifted (e.g. 60 = C4). Notes above/below this value are produced by resampling. loop: if true, the sample restarts from the beginning each time it runs out, and keeps playing until the owning note's duration elapses.
A single monophonic voice. Multiple tracks are mixed together by speaker_play_tracks() to produce polyphony. notes: array of notes to play sequentially. num_notes: length of the notes array. sample: if non-NULL, notes are played by pitch-shifting this sample; note.waveform is ignored. If NULL, notes use their waveform field.
PCM audio format for speaker streaming. Bit layout: bit0 = sample rate (0=8kHz, 1=16kHz), bit1 = bit depth (0=8-bit, 1=16-bit). All formats are mono signed PCM (8-bit samples are signed [-128,127], not unsigned).
8kHz 8-bit signed (1 byte/sample)
16kHz 8-bit signed (1 byte/sample)
8kHz 16-bit signed little-endian (2 bytes/sample)
16kHz 16-bit signed little-endian (2 bytes/sample)
Speaker status.
Reason reported when speaker playback ends.
Playback completed naturally.
Playback was stopped by the app.
Preempted by higher priority source.
An error occurred.
Callback invoked when playback finishes.
Why playback ended
User context
Do you have questions about the Pebble SDK?
Do you need some help understanding something on this page?
You can either take advantage of our awesome developer community and check out the SDK Help forums, or you can join us on the Discord!