shiguredo-audio-toolbox

Encode PCM audio to AAC-LC and decode AAC-LC, MP3, and Opus on macOS via Audio Toolbox.

Updated Feb 25, 2026
One-click install
npx skills add https://github.com/shiguredo/audio-toolbox-rs --skill shiguredo-audio-toolbox-shiguredo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shiguredo-audio-toolbox
Source: https://github.com/shiguredo/audio-toolbox-rs/tree/main/skills/shiguredo-audio-toolbox
Command: npx skills add https://github.com/shiguredo/audio-toolbox-rs --skill shiguredo-audio-toolbox-shiguredo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Working with Apple's Audio Toolbox APIs from Rust requires unsafe FFI bindings, manual AudioConverter lifecycle management, and deep knowledge of packet-based audio formats. This Skill provides the complete API reference and usage patterns for the shiguredo_audio_toolbox crate so you can encode and decode audio correctly on the first attempt. ## Core Features & Use Cases - AAC-LC Encoding: Convert interleaved i16 PCM into AAC-LC frames with configurable sample rate, channels, bitrate, bitrate control mode, and codec quality. - Multi-Codec Decoding: Decode AAC-LC, MP3, and Opus packets into fixed stereo 16-bit PCM output. - Codec Capability Query: Use supported_codecs() to inspect which codecs and bitrate control modes the current system supports. - Use Case: Build a macOS audio pipeline that captures microphone PCM, encodes it to AAC-LC at 128 kbps, and muxes it into an MP4 file with shiguredo_mp4, as demonstrated by the sine_to_mp4 example. ## Quick Start Ask the AI to write Rust code using shiguredo_audio_toolbox that encodes 48 kHz stereo PCM to AAC-LC at 128 kbps and then decodes the packets back to PCM.

Frequently Asked Questions about shiguredo-audio-toolbox

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I encode PCM audio to AAC-LC in Rust on macOS?

Create an Encoder with EncoderConfig specifying codec AacLc, sample rate, channels, and optional bitrate, then call encode with interleaved i16 PCM and drain results via next_frame. Call finish() at the end to flush buffered samples.

How do I decode AAC, MP3, or Opus audio packets in Rust?

Create a Decoder with DecoderConfig specifying the codec, input sample rate, and channels, then pass one compressed packet per decode call and read PCM via next_frame until it returns None. Output is always stereo 16-bit PCM at the input sample rate.

Does shiguredo_audio_toolbox work on Linux or Windows?

No, the crate is macOS-only because it binds directly to Apple's Audio Toolbox framework, and it emits a compile error on other platforms. Only documentation generation is possible elsewhere using DOCS_RS=1 cargo doc.

Why does Decoder::decode return a 'previous packet not consumed' error?

The decoder accepts exactly one packet per decode call, so you must drain the previous packet with next_frame until it returns Ok(None) before decoding again. Concatenating multiple packets into one call causes incorrect frame counts.

Can I encode Opus, FLAC, or HE-AAC with this crate?

No, encoding supports only AAC-LC through EncoderCodec. FLAC is unavailable because AudioConverter does not support it, and HE-AAC or Opus encoding is not exposed even though decoding covers AAC-LC, MP3, and Opus.

Is the Encoder or Decoder safe to move between threads?

No, both types are intentionally !Send because Apple does not document whether AudioConverter can move across threads. Use them on a single thread or serialize access yourself if cross-thread transfer is required.