CompressedAudio
A single chunk of a compressed audio bitstream
Panel support
CompressedAudio is used in the Audio panel.
Schema
| field | type | description |
|---|---|---|
timestamp | Timestamp | Timestamp of the start of the audio chunk |
data | bytes | Compressed audio data. Packet duration is determined by the codec during encoding. Messages should generally contain approximately 20 ms of audio. |
format | string | Format of the audio data. See the data field description for supported values. Consumers may support a subset of these formats. |
data
For each format value, the data field contains compressed audio data serialized as follows:
opus:- Each message must contain a complete raw Opus packet, without Ogg, WebM, or other container framing, as described in RFC 6716 section 3.
- Each packet contains all information necessary for decoding, and may be decoded at any sample rate supported by Opus (8, 12, 16, 24, or 48 kHz).
- A single raw Opus packet represents mono or stereo audio; multichannel Opus requires multistream or container metadata and is not supported by this schema.
mp4a.40.2:- Each message must contain a complete MPEG-4 AAC-LC ADTS frame, including the ADTS header, as described in section 1.A.3.2 of ISO/IEC 14496-3:2019.
- The ADTS header supplies stream parameters such as sample rate and channel configuration.
g726-16,g726-24,g726-32, andg726-40:- Each message must contain raw G.726 codewords without WAV, RTP, or other container framing. Codewords may not span messages.
- Audio is mono at 8 kHz. The suffix specifies the bitrate in kbps and therefore the number of bits per sample: 2, 3, 4, or 5 respectively.
- Codewords are packed beginning with the least-significant bit, as described in RFC 3551 section 4.5.4.
- Codewords may cross octet boundaries. To keep every codeword within one message, the message length must be a multiple of 1, 3, 1, or 5 octets for
g726-16,g726-24,g726-32, andg726-40respectively, holding 4, 8, 2, or 8 codewords. - Messages form a continuous encoded stream and preserve G.726 predictor and quantizer state across message boundaries.
aal2-g726-16,aal2-g726-24,aal2-g726-32, andaal2-g726-40:- These formats have the same requirements as the corresponding
g726-*formats, except codewords use the opposite bit-packing order specified for AAL2.
- These formats have the same requirements as the corresponding
Reference implementations
Foxglove messages are framework-agnostic, and can be implemented using any supported message encoding:
| encoding | schema |
|---|---|
| ROS 1 | foxglove_msgs/CompressedAudio |
| ROS 2 | foxglove_msgs/msg/CompressedAudio |
| JSON | foxglove.CompressedAudio |
| Protobuf | foxglove.CompressedAudio |
| FlatBuffers | foxglove.CompressedAudio |
| OMG IDL | foxglove::CompressedAudio |
You must use the schema names specified above for Foxglove to recognize the schema.